]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add tests to confirm no issue w/ pg json keys
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Jun 2022 23:04:23 +0000 (19:04 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Jun 2022 23:04:23 +0000 (19:04 -0400)
Change-Id: Ie91e5efb217c309bc40c3933f538bcf29c1fd87b
References: #8112

test/dialect/postgresql/test_types.py

index ddb199aa42a79a88b45d259d0a3976cb50c81772..266263d5fb9e3b6968faf7d43c9cb2407c9cffdf 100644 (file)
@@ -3839,6 +3839,33 @@ class JSONRoundTripTest(fixtures.TablesTest):
         ).fetchall()
         eq_([d for d, in data], [None])
 
+    @testing.combinations(
+        "key",
+        "réve🐍 illé",
+        'name_with"quotes"name',
+        "name with spaces",
+        "name with ' single ' quotes",
+        'some_key("idx")',
+        argnames="key",
+    )
+    def test_indexed_special_keys(self, connection, key):
+        data_table = self.tables.data_table
+        data_element = {key: "some value"}
+
+        connection.execute(
+            data_table.insert(),
+            {
+                "name": "row1",
+                "data": data_element,
+                "nulldata": data_element,
+            },
+        )
+
+        row = connection.execute(
+            select(data_table.c.data[key], data_table.c.nulldata[key])
+        ).one()
+        eq_(row, ("some value", "some value"))
+
     def test_reflect(self, connection):
         insp = inspect(connection)
         cols = insp.get_columns("data_table")