]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixed reflection of unicode, [ticket:881]
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Nov 2007 05:37:57 +0000 (05:37 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Nov 2007 05:37:57 +0000 (05:37 +0000)
lib/sqlalchemy/databases/postgres.py

index 1cae31b537a79c14d69429de561137125ba09cff..4203814d017ab995f903499b25cf564ad55a97c2 100644 (file)
@@ -406,12 +406,13 @@ class PGDialect(default.DefaultDialect):
         preparer = self.identifier_preparer
         if table.schema is not None:
             schema_where_clause = "n.nspname = :schema"
+            schemaname = table.schema
+            if isinstance(schemaname, str):
+                schemaname = schemaname.decode(self.encoding)
         else:
             schema_where_clause = "pg_catalog.pg_table_is_visible(c.oid)"
-
-        ## information schema in pg suffers from too many permissions' restrictions
-        ## let us find out at the pg way what is needed...
-
+            schemaname = None
+            
         SQL_COLS = """
             SELECT a.attname,
               pg_catalog.format_type(a.atttypid, a.atttypmod),
@@ -431,8 +432,10 @@ class PGDialect(default.DefaultDialect):
         """ % schema_where_clause
 
         s = sql.text(SQL_COLS, bindparams=[sql.bindparam('table_name', type_=sqltypes.Unicode), sql.bindparam('schema', type_=sqltypes.Unicode)], typemap={'attname':sqltypes.Unicode, 'default':sqltypes.Unicode})
-        c = connection.execute(s, table_name=table.name,
-                                  schema=table.schema)
+        tablename = table.name
+        if isinstance(tablename, str):
+            tablename = tablename.decode(self.encoding)
+        c = connection.execute(s, table_name=tablename, schema=schemaname)
         rows = c.fetchall()
 
         if not rows: