From 4605686ced3b334147db5f64518b97364934a5f5 Mon Sep 17 00:00:00 2001 From: larkee Date: Tue, 14 Nov 2023 10:23:55 +1100 Subject: [PATCH 1/5] feat: add support for PG.OID in parameterized queries --- google/cloud/spanner_v1/param_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google/cloud/spanner_v1/param_types.py b/google/cloud/spanner_v1/param_types.py index 9b1910244d..3499c5b337 100644 --- a/google/cloud/spanner_v1/param_types.py +++ b/google/cloud/spanner_v1/param_types.py @@ -33,6 +33,7 @@ JSON = Type(code=TypeCode.JSON) PG_NUMERIC = Type(code=TypeCode.NUMERIC, type_annotation=TypeAnnotationCode.PG_NUMERIC) PG_JSONB = Type(code=TypeCode.JSON, type_annotation=TypeAnnotationCode.PG_JSONB) +PG_OID = Type(code=TypeCode.INT64, type_annotation=TypeAnnotationCode.PG_OID) def Array(element_type): From 23f41e1536b2e94d97d9b746079c84596242e1f9 Mon Sep 17 00:00:00 2001 From: larkee Date: Tue, 14 Nov 2023 10:25:25 +1100 Subject: [PATCH 2/5] test: add tests for PG.OID bindings --- tests/system/test_session_api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index 6f1844faa9..5a188fca17 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -2348,6 +2348,18 @@ def test_execute_sql_w_jsonb_bindings( ) +def test_execute_sql_w_jsonb_bindings( + not_emulator, not_google_standard_sql, sessions_database, database_dialect +): + _bind_test_helper( + sessions_database, + database_dialect, + spanner_v1.param_types.PG_OID, + 123, + [123, 456], + ) + + def test_execute_sql_w_query_param_struct(sessions_database, not_postgres): name = "Phred" count = 123 From 83914f8b3bec9f89c5a5c4233d05b9b333001bcc Mon Sep 17 00:00:00 2001 From: larkee Date: Tue, 14 Nov 2023 10:26:06 +1100 Subject: [PATCH 3/5] test: add test to check that the PG.OID param type is correct --- tests/unit/test_param_types.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/unit/test_param_types.py b/tests/unit/test_param_types.py index 645774d79b..827f08658d 100644 --- a/tests/unit/test_param_types.py +++ b/tests/unit/test_param_types.py @@ -70,3 +70,20 @@ def test_it(self): found = param_types.PG_JSONB self.assertEqual(found, expected) + + +class Test_OidParamType(unittest.TestCase): + def test_it(self): + from google.cloud.spanner_v1 import Type + from google.cloud.spanner_v1 import TypeCode + from google.cloud.spanner_v1 import TypeAnnotationCode + from google.cloud.spanner_v1 import param_types + + expected = Type( + code=TypeCode.INT64, + type_annotation=TypeAnnotationCode.PG_OID, + ) + + found = param_types.PG_OID + + self.assertEqual(found, expected) From d097169d6d58a2ac4fbb01b75b0f8e440bfe194a Mon Sep 17 00:00:00 2001 From: larkee Date: Tue, 14 Nov 2023 11:47:28 +1100 Subject: [PATCH 4/5] lint: fix lint --- tests/system/test_session_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index 5a188fca17..44940ef2d8 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -2349,7 +2349,7 @@ def test_execute_sql_w_jsonb_bindings( def test_execute_sql_w_jsonb_bindings( - not_emulator, not_google_standard_sql, sessions_database, database_dialect + not_emulator, not_google_standard_sql, sessions_database, database_dialect ): _bind_test_helper( sessions_database, From 73c687de491b8603afb53002c9eb9bd4d87f79a9 Mon Sep 17 00:00:00 2001 From: larkee Date: Tue, 14 Nov 2023 12:35:25 +1100 Subject: [PATCH 5/5] test: correct new test name --- tests/system/test_session_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py index 44940ef2d8..5cba7441a4 100644 --- a/tests/system/test_session_api.py +++ b/tests/system/test_session_api.py @@ -2348,7 +2348,7 @@ def test_execute_sql_w_jsonb_bindings( ) -def test_execute_sql_w_jsonb_bindings( +def test_execute_sql_w_oid_bindings( not_emulator, not_google_standard_sql, sessions_database, database_dialect ): _bind_test_helper(