summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2023-01-09 14:53:20 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2023-01-09 14:53:20 +0000
commita8af0351fa9f29e18dacd3eee81221b35d801e3a (patch)
tree6d663ddb36a62af3fce6c1e850fd6ee9dfb6fc98 /test/dialect/postgresql
parent90b979a73bc6aa70ef5aba1394c644bce1b1d6d4 (diff)
parent6b0c3dd5fd0c0225636ce759bc4433c91c5efb83 (diff)
downloadsqlalchemy-a8af0351fa9f29e18dacd3eee81221b35d801e3a.tar.gz
Merge "Implement missing `#-`, `@?` and `@@` Postgres' JSONB operators." into main
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_types.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index e9d5e561f..22993ae7b 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -5683,6 +5683,24 @@ class JSONBTest(JSONTest):
lambda self: self.jsoncol.contained_by({"foo": "1", "bar": None}),
"test_table.test_column <@ %(test_column_1)s",
),
+ (
+ lambda self: self.jsoncol.delete_path(["a", "b"]),
+ "test_table.test_column #- CAST(ARRAY[%(param_1)s, "
+ "%(param_2)s] AS TEXT[])",
+ ),
+ (
+ lambda self: self.jsoncol.delete_path(array(["a", "b"])),
+ "test_table.test_column #- CAST(ARRAY[%(param_1)s, "
+ "%(param_2)s] AS TEXT[])",
+ ),
+ (
+ lambda self: self.jsoncol.path_exists("$.k1"),
+ "test_table.test_column @? %(test_column_1)s",
+ ),
+ (
+ lambda self: self.jsoncol.path_match("$.k1[0] > 2"),
+ "test_table.test_column @@ %(test_column_1)s",
+ ),
)
def test_where(self, whereclause_fn, expected):
super().test_where(whereclause_fn, expected)
@@ -5712,6 +5730,19 @@ class JSONBRoundTripTest(JSONRoundTripTest):
go("$.k1.k2", 0)
go("$.k1.r6v1", 1)
+ @testing.combinations(
+ ["k1", "r6v1", "subr", 1],
+ array(["k1", "r6v1", "subr", 1]),
+ argnames="path",
+ )
+ def test_delete_path(self, connection, path):
+ self._fixture_data(connection)
+ q = select(self.data_table.c.data.delete_path(path)).where(
+ self.data_table.c.name == "r6"
+ )
+ res = connection.scalar(q)
+ eq_(res, {"k1": {"r6v1": {"subr": [1, 3]}}})
+
class JSONBSuiteTest(suite.JSONTest):
__requires__ = ("postgresql_jsonb",)