diff options
Diffstat (limited to 'lib')
| -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): |
