From 7054e1aadfe14b1eeab337d3e7a2ddc8318e765f Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 6 Oct 2022 02:05:49 +0100 Subject: [PATCH] test: add test to verify register_range() with names requiring escape Unlike for register_composite(), this works already. --- tests/test_types_extras.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_types_extras.py b/tests/test_types_extras.py index 0b103633..85c9b18b 100755 --- a/tests/test_types_extras.py +++ b/tests/test_types_extras.py @@ -1660,6 +1660,22 @@ class RangeCasterTestCase(ConnectingTestCase): ra3 = register_range('r3', 'r3', cur2) self.assertEqual(ra3.typecaster.values[0], rars3.typecaster.values[0]) + @skip_if_no_composite + def test_rang_weird_name(self): + cur = self.conn.cursor() + cur.execute(""" + select nspname from pg_namespace + where nspname = 'qux.quux'; + """) + if not cur.fetchone(): + cur.execute('create schema "qux.quux";') + + cur.execute('create type "qux.quux"."foo.range" as range (subtype=text)') + r = psycopg2.extras.register_range( + '"qux.quux"."foo.range"', "foorange", cur) + cur.execute('''select '[a,z]'::"qux.quux"."foo.range"''') + self.assertEqual(cur.fetchone()[0], r.range('a', 'z', '[]')) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__)