From f89b3fb68057c3dbb0043429a54e05fbd3f19eb3 Mon Sep 17 00:00:00 2001 From: Woodhams Date: Wed, 9 Feb 2022 10:22:50 +0000 Subject: [PATCH 1/5] Domain basetypes are introspected (#886) Domain encoding/decoding is handled by its basetype. This change forces those basetypes to be inspected and loaded to the client cache avoiding the issue where base types weren't encodable/decodable. --- asyncpg/introspection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asyncpg/introspection.py b/asyncpg/introspection.py index 175e0242..d62f39a0 100644 --- a/asyncpg/introspection.py +++ b/asyncpg/introspection.py @@ -109,6 +109,7 @@ (tt.elemtype IS NOT NULL AND ti.oid = tt.elemtype) OR (tt.attrtypoids IS NOT NULL AND ti.oid = any(tt.attrtypoids)) OR (tt.range_subtype IS NOT NULL AND ti.oid = tt.range_subtype) + OR (tt.basetype IS NOT NULL AND ti.oid = tt.basetype) ) SELECT DISTINCT @@ -232,6 +233,7 @@ (tt.elemtype IS NOT NULL AND ti.oid = tt.elemtype) OR (tt.attrtypoids IS NOT NULL AND ti.oid = any(tt.attrtypoids)) OR (tt.range_subtype IS NOT NULL AND ti.oid = tt.range_subtype) + OR (tt.basetype IS NOT NULL AND ti.oid = tt.basetype) ) SELECT DISTINCT From 2ed3ba97834aaa35d35821763e04b93d448ef869 Mon Sep 17 00:00:00 2001 From: Woodhams Date: Thu, 17 Feb 2022 11:28:39 +0000 Subject: [PATCH 2/5] Domain basetypes are introspected (#886) Add test for domain basetype introspections and loading --- tests/test_introspection.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_introspection.py b/tests/test_introspection.py index 7de4236f..980df384 100644 --- a/tests/test_introspection.py +++ b/tests/test_introspection.py @@ -190,3 +190,25 @@ async def wait_and_drop(): DROP DOMAIN intro_2_t; ''') await slow_intro_conn.close() + + @tb.with_connection_options(database='asyncpg_intro_test') + async def test_introspection_loads_basetypes_of_domains(self): + # Test that basetypes of domains are loaded to the client encode/decode + # cache + await self.con.execute(''' + DROP TABLE IF EXISTS test; + DROP DOMAIN IF EXISTS num_array; + CREATE DOMAIN num_array numeric[]; + CREATE TABLE test ( + num num_array + ); + ''') + + try: + # if domain basetypes are not loaded, this insert will fail + await self.con.execute('INSERT INTO test (num) VALUES ($1)', ([1, 2],)) + finally: + await self.con.execute(''' + DROP TABLE IF EXISTS test; + DROP DOMAIN IF EXISTS num_array; + ''') From 86278bb3f25c73509cbffe355a43067a5c6641c2 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Fri, 25 Mar 2022 15:41:57 -0700 Subject: [PATCH 3/5] Update tests/test_introspection.py --- tests/test_introspection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_introspection.py b/tests/test_introspection.py index 980df384..ceede200 100644 --- a/tests/test_introspection.py +++ b/tests/test_introspection.py @@ -193,8 +193,8 @@ async def wait_and_drop(): @tb.with_connection_options(database='asyncpg_intro_test') async def test_introspection_loads_basetypes_of_domains(self): - # Test that basetypes of domains are loaded to the client encode/decode - # cache + # Test that basetypes of domains are loaded to the + # client encode/decode cache await self.con.execute(''' DROP TABLE IF EXISTS test; DROP DOMAIN IF EXISTS num_array; From de89bcc895202b9cfff4185c5d12795c84507e0c Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Fri, 25 Mar 2022 15:42:01 -0700 Subject: [PATCH 4/5] Update tests/test_introspection.py --- tests/test_introspection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_introspection.py b/tests/test_introspection.py index ceede200..18c269cf 100644 --- a/tests/test_introspection.py +++ b/tests/test_introspection.py @@ -206,7 +206,8 @@ async def test_introspection_loads_basetypes_of_domains(self): try: # if domain basetypes are not loaded, this insert will fail - await self.con.execute('INSERT INTO test (num) VALUES ($1)', ([1, 2],)) + await self.con.execute( + 'INSERT INTO test (num) VALUES ($1)', ([1, 2],)) finally: await self.con.execute(''' DROP TABLE IF EXISTS test; From e65618464497ac479f064f2dc4ab7fdf87dbe2fe Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Fri, 25 Mar 2022 15:48:03 -0700 Subject: [PATCH 5/5] Update tests/test_introspection.py --- tests/test_introspection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_introspection.py b/tests/test_introspection.py index 18c269cf..56f1d7a3 100644 --- a/tests/test_introspection.py +++ b/tests/test_introspection.py @@ -193,7 +193,7 @@ async def wait_and_drop(): @tb.with_connection_options(database='asyncpg_intro_test') async def test_introspection_loads_basetypes_of_domains(self): - # Test that basetypes of domains are loaded to the + # Test that basetypes of domains are loaded to the # client encode/decode cache await self.con.execute(''' DROP TABLE IF EXISTS test;