diff options
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 6f22113b6..e3ac3ae2c 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -301,9 +301,9 @@ class PGDialect(ansisql.ANSIDialect): def has_table(self, connection, table_name, schema=None): # seems like case gets folded in pg_class... if schema is None: - cursor = connection.execute("""select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=current_schema() and relname=%(name)s""", {'name':table_name.lower()}); + cursor = connection.execute("""select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=current_schema() and lower(relname)=%(name)s""", {'name':table_name.lower()}); else: - cursor = connection.execute("""select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=%(schema)s and relname=%(name)s""", {'name':table_name.lower(), 'schema':schema}); + cursor = connection.execute("""select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where n.nspname=%(schema)s and lower(relname)=%(name)s""", {'name':table_name.lower(), 'schema':schema}); return bool( not not cursor.rowcount ) def has_sequence(self, connection, sequence_name): |