From 32ce703a98eba8a7685e609b4a7ca86b79dd0904 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 21 Aug 2018 20:59:04 -0400 Subject: Strip quotes from format_type in addition to other characters Fixed bug in PostgreSQL ENUM reflection where a case-sensitive, quoted name would be reported by the query including quotes, which would not match a target column during table reflection as the quotes needed to be stripped off. Fixes: #4323 Change-Id: I668f3acccc578e58f23b70c82d31d5c1ec194913 --- lib/sqlalchemy/dialects/postgresql/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index ad15cb0ea..7db26e4c0 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2599,6 +2599,9 @@ class PGDialect(default.DefaultDialect): # with time zone, geometry(POLYGON), etc. attype = re.sub(r'\(.*\)', '', format_type) + # strip quotes from case sensitive enum names + attype = re.sub(r'^"|"$', '', attype) + # strip '[]' from integer[], etc. attype = attype.replace('[]', '') @@ -3128,7 +3131,6 @@ class PGDialect(default.DefaultDialect): 'labels': [enum['label']], } enums.append(enum_rec) - return enums def _load_domains(self, connection): -- cgit v1.2.1