diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-06-22 23:51:52 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-06-26 11:05:38 -0400 |
| commit | 1776597131ef96472b5188cebc72c31a387c90f4 (patch) | |
| tree | e158f177c7da7999323175263719216085a616d3 /test/sql | |
| parent | 83c1e03c5c74c69facfc371840ffae890f05c338 (diff) | |
| download | sqlalchemy-1776597131ef96472b5188cebc72c31a387c90f4.tar.gz | |
Coerce float Python type to Float; ensure Python float coming back
Added some extra strictness to the handling of Python "float" values
passed to SQL statements. A "float" value will be associated with the
:class:`.Float` datatype and not the Decimal-coercing :class:`.Numeric`
datatype as was the case before, eliminating a confusing warning
emitted on SQLite as well as unecessary coercion to Decimal.
Change-Id: I1bb1810ff1d198c0d929ccba5656e55401d74119
Fixes: #4017
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_types.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/sql/test_types.py b/test/sql/test_types.py index f46ef21cd..9107adaca 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -2025,6 +2025,23 @@ class ExpressionTest( expr = column('foo', CHAR) == "asdf" eq_(expr.right.type.__class__, CHAR) + def test_actual_literal_adapters(self): + for data, expected in [ + (5, Integer), + (2.65, Float), + (True, Boolean), + (decimal.Decimal("2.65"), Numeric), + (datetime.date(2015, 7, 20), Date), + (datetime.time(10, 15, 20), Time), + (datetime.datetime(2015, 7, 20, 10, 15, 20), DateTime), + (datetime.timedelta(seconds=5), Interval), + (None, types.NullType) + ]: + is_( + literal(data).type.__class__, + expected + ) + def test_typedec_operator_adapt(self): expr = test_table.c.bvalue + "hi" |
