]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
has_table wasnt handling case-sensitive table names
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Jan 2007 02:10:28 +0000 (02:10 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Jan 2007 02:10:28 +0000 (02:10 +0000)
lib/sqlalchemy/databases/postgres.py

index 6f22113b6b11219b39203635a7fff585de4f643d..e3ac3ae2c6b31d3c5256500f8318c640082da0c1 100644 (file)
@@ -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):