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 diff --git a/tests/test_introspection.py b/tests/test_introspection.py index 7de4236f..56f1d7a3 100644 --- a/tests/test_introspection.py +++ b/tests/test_introspection.py @@ -190,3 +190,26 @@ 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; + ''')