]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Exploit literal() instead of hardcoding the SQL
authorLele Gaifax <lele@metapensiero.it>
Mon, 31 Oct 2022 08:14:04 +0000 (09:14 +0100)
committerLele Gaifax <lele@metapensiero.it>
Mon, 31 Oct 2022 08:14:04 +0000 (09:14 +0100)
test/dialect/postgresql/test_dialect.py

index 0e65167d9bf7c6be809c9f6f40d96c8874d1bbb2..608843b5966329572ca47b4994b16e97b1450a1d 100644 (file)
@@ -1232,8 +1232,8 @@ class TestRange(fixtures.TestBase):
     )
     def test_contains_value(self, connection, rrepr, v):
         q = select(
-            literal_column(f"'{rrepr}'::int4range", INT4RANGE),
-            literal_column(f"{v} <@ '{rrepr}'::int4range"),
+            literal(rrepr, INT4RANGE),
+            literal(rrepr, INT4RANGE).contains(v),
         )
         r, expected = connection.execute(q).first()
         eq_(r.contains(v), expected)