diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-08-15 16:36:30 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-08-16 13:38:33 -0400 |
| commit | 9a5be7bb92de692c13215ea9b336c831400d5a5e (patch) | |
| tree | c9041cc483a6e22e84d259a31e0e64604e1948b6 /lib/sqlalchemy/testing | |
| parent | dfa47b454a1d873b5746263f638d757c70edd3e1 (diff) | |
| download | sqlalchemy-9a5be7bb92de692c13215ea9b336c831400d5a5e.tar.gz | |
Add test support for #4036
Add a test that asserts MySQL can't implicitly treat a decimal
bound parameter without context and everyone else can.
Change-Id: I40e24a463d6eb03fd677195895891e73624776c3
Diffstat (limited to 'lib/sqlalchemy/testing')
| -rw-r--r-- | lib/sqlalchemy/testing/requirements.py | 21 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_types.py | 29 |
2 files changed, 42 insertions, 8 deletions
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 19d80e028..2a5262e4e 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -629,6 +629,27 @@ class SuiteRequirements(Requirements): return exclusions.closed() @property + def implicit_decimal_binds(self): + """target backend will return a selected Decimal as a Decimal, not + a string. + + e.g.:: + + expr = decimal.Decimal("15.7563") + + value = e.scalar( + select([literal(expr)]) + ) + + assert value == expr + + See :ticket:`4036` + + """ + + return exclusions.open() + + @property def nested_aggregates(self): """target database can select an aggregate from a subquery that's also using an aggregate diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 04e0b3b23..27c7bb115 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -483,14 +483,27 @@ class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase): ) eq_(val, expr) - # TODO: this one still breaks on MySQL - # def test_decimal_coerce_round_trip(self): - # expr = decimal.Decimal("15.7563") - # - # val = testing.db.scalar( - # select([literal(expr)]) - # ) - # eq_(val, expr) + # this does not work in MySQL, see #4036, however we choose not + # to render CAST unconditionally since this is kind of an edge case. + + @testing.requires.implicit_decimal_binds + @testing.emits_warning(r".*does \*not\* support Decimal objects natively") + def test_decimal_coerce_round_trip(self): + expr = decimal.Decimal("15.7563") + + val = testing.db.scalar( + select([literal(expr)]) + ) + eq_(val, expr) + + @testing.emits_warning(r".*does \*not\* support Decimal objects natively") + def test_decimal_coerce_round_trip_w_cast(self): + expr = decimal.Decimal("15.7563") + + val = testing.db.scalar( + select([cast(expr, Numeric(10, 4))]) + ) + eq_(val, expr) @testing.requires.precision_numerics_general def test_precision_decimal(self): |
