Merge "repair broken truediv test suite; memusage" into main

This commit is contained in:
mike bayer
2022-01-20 23:04:24 +00:00
committed by Gerrit Code Review
5 changed files with 33 additions and 10 deletions
+7 -1
View File
@@ -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:
+20 -2
View File
@@ -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,13 +578,29 @@ 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"
)
+2 -2
View File
@@ -458,7 +458,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed):
@testing.emits_warning("Compiled statement cache for lazy loader.*")
@testing.crashes("sqlite", ":memory: connection not suitable here")
def test_orm_many_engines(self):
metadata = MetaData(self.engine)
metadata = MetaData()
table1 = Table(
"mytable",
@@ -485,7 +485,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed):
Column("col3", Integer, ForeignKey("mytable.col1")),
)
metadata.create_all()
metadata.create_all(self.engine)
m1 = self.mapper_registry.map_imperatively(
A,
-1
View File
@@ -1843,7 +1843,6 @@ class MixedEntitiesTest(QueryTest, AssertsCompiledSQL):
q2 = q.values(func.count(User.name))
assert next(q2) == (4,)
@testing.fails_on("mssql", "FIXME: unknown")
def test_values_specific_order_by(self):
User = self.classes.User
+4 -4
View File
@@ -2244,7 +2244,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
(value_tbl.c.val2 - value_tbl.c.val1) / value_tbl.c.val1,
),
"SELECT values.id, (values.val2 - values.val1) "
"/ CAST(values.val1 AS NUMERIC) AS anon_1 FROM values",
"/ CAST(values.val1 AS FLOAT) AS anon_1 FROM values",
)
self.assert_compile(
@@ -2253,7 +2253,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
),
"SELECT values.id FROM values WHERE "
"(values.val2 - values.val1) / "
"CAST(values.val1 AS NUMERIC) > :param_1",
"CAST(values.val1 AS FLOAT) > :param_1",
)
self.assert_compile(
@@ -2264,8 +2264,8 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
> 2.0,
),
"SELECT values.id FROM values WHERE "
"(values.val1 / CAST((values.val2 - values.val1) AS NUMERIC)) "
"/ CAST(values.val1 AS NUMERIC) > :param_1",
"(values.val1 / CAST((values.val2 - values.val1) AS FLOAT)) "
"/ CAST(values.val1 AS FLOAT) > :param_1",
)
def test_percent_chars(self):