diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-01-20 23:04:24 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-01-20 23:04:24 +0000 |
| commit | 952f480bfe401ca35ff3ec3d87fa57ad2a87cf37 (patch) | |
| tree | def4b777768a37b88cf027e24c2629d7776002e7 /lib/sqlalchemy | |
| parent | 297aebf2b686d17ad275d22e2dcacfb5884510ab (diff) | |
| parent | 867235e4902c91531095676e3a413d935181b0bd (diff) | |
| download | sqlalchemy-952f480bfe401ca35ff3ec3d87fa57ad2a87cf37.tar.gz | |
Merge "repair broken truediv test suite; memusage" into main
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_types.py | 22 |
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index af39f0672..8a3f26425 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1932,7 +1932,13 @@ class SQLCompiler(Compiled): # TODO: would need a fast cast again here, # unless we want to use an implicit cast like "+ 0.0" + self.process( - elements.Cast(binary.right, sqltypes.Numeric()), **kw + elements.Cast( + binary.right, + binary.right.type + if binary.right.type._type_affinity is sqltypes.Numeric + else sqltypes.Numeric(), + ), + **kw, ) ) else: diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 796de5d93..c51a66690 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -533,6 +533,8 @@ class CastTypeDecoratorTest(_LiteralRoundTripFixture, fixtures.TestBase): class TrueDivTest(fixtures.TestBase): + __backend__ = True + @testing.combinations( ("15", "10", 1.5), ("-15", "10", -1.5), @@ -576,14 +578,30 @@ class TrueDivTest(fixtures.TestBase): eq_( connection.scalar( select( - literal_column(left, type_=Numeric()) - / literal_column(right, type_=Numeric()) + literal_column(left, type_=Numeric(10, 2)) + / literal_column(right, type_=Numeric(10, 2)) ) ), decimal.Decimal(expected), ) @testing.combinations( + ("5.52", "2.4", 2.3), argnames="left, right, expected" + ) + def test_truediv_float(self, connection, left, right, expected): + """test #4926""" + + eq_( + connection.scalar( + select( + literal_column(left, type_=Float()) + / literal_column(right, type_=Float()) + ) + ), + expected, + ) + + @testing.combinations( ("5.52", "2.4", "2.0"), argnames="left, right, expected" ) def test_floordiv_numeric(self, connection, left, right, expected): |
