]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Use literal_column() instead of literal() in test 8707/head
authorLele Gaifax <lele@metapensiero.it>
Wed, 2 Nov 2022 07:32:55 +0000 (08:32 +0100)
committerLele Gaifax <lele@metapensiero.it>
Wed, 2 Nov 2022 07:32:55 +0000 (08:32 +0100)
This is an attempt to workaround an issue with asyncpg, where passing a
literal range as argument causes the following error:

<class 'asyncpg.exceptions.DataError'>: invalid input for query argument $1: 'empty' (list, tuple or Range object expected (got type <class 'str'>))

test/dialect/postgresql/test_dialect.py

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