('polygon', 604, 1027, 'polygon', ','),
('record', 2249, 2287, 'record', ','),
('refcursor', 1790, 2201, 'refcursor', ','),
+ ('regclass', 2205, 2210, 'regclass', ','),
+ ('regcollation', 4191, 4192, 'regcollation', ','),
+ ('regconfig', 3734, 3735, 'regconfig', ','),
+ ('regdictionary', 3769, 3770, 'regdictionary', ','),
+ ('regnamespace', 4089, 4090, 'regnamespace', ','),
+ ('regoper', 2203, 2208, 'regoper', ','),
+ ('regoperator', 2204, 2209, 'regoperator', ','),
+ ('regproc', 24, 1008, 'regproc', ','),
+ ('regprocedure', 2202, 2207, 'regprocedure', ','),
+ ('regrole', 4096, 4097, 'regrole', ','),
+ ('regtype', 2206, 2211, 'regtype', ','),
('text', 25, 1009, 'text', ','),
('tid', 27, 1010, 'tid', ','),
('time', 1083, 1183, 'time without time zone', ','),
def test_array_register(conn):
- # unknown for real
cur = conn.cursor()
- cur.execute("select '{postgres=arwdDxt/postgres}'::aclitem[]")
- res = cur.fetchone()[0]
- assert res == "{postgres=arwdDxt/postgres}"
+ cur.execute("create table mytype (data text)")
+ cur.execute("""select '(foo)'::mytype, '{"(foo)"}'::mytype[]""")
+ res = cur.fetchone()
+ assert res[0] == "(foo)"
+ assert res[1] == "{(foo)}"
array.register(
- builtins["aclitem"].array_oid, builtins["aclitem"].oid, context=conn
+ cur.description[1].type_code, cur.description[0].type_code, context=cur
)
- cur.execute("select '{postgres=arwdDxt/postgres}'::aclitem[]")
- res = cur.fetchone()[0]
- assert res == ["postgres=arwdDxt/postgres"]
+ cur.execute("""select '(foo)'::mytype, '{"(foo)"}'::mytype[]""")
+ res = cur.fetchone()
+ assert res[0] == "(foo)"
+ assert res[1] == ["(foo)"]
+
+
+def test_array_of_unknown_builtin(conn):
+ # we cannot load this type, but we understand it is an array
+ val = "postgres=arwdDxt/postgres"
+ cur = conn.cursor()
+ cur.execute(f"select '{val}'::aclitem, array['{val}']::aclitem[]")
+ res = cur.fetchone()
+ assert cur.description[0].type_code == builtins["aclitem"].oid
+ assert res[0] == val
+ assert cur.description[1].type_code == builtins["aclitem"].array_oid
+ assert res[1] == [val]
@pytest.mark.xfail