[SQL-CVS] r1814 - in SQLObject/trunk/sqlobject: mysql postgres
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2006-06-15 16:41:40
|
Author: phd Date: 2006-06-15 10:41:29 -0600 (Thu, 15 Jun 2006) New Revision: 1814 Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py SQLObject/trunk/sqlobject/postgres/pgconnection.py Log: A patch by Ivan Horvath <i.h...@al...> for use_unicode with fromDatabase. Modified: SQLObject/trunk/sqlobject/mysql/mysqlconnection.py =================================================================== --- SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2006-06-14 23:23:52 UTC (rev 1813) +++ SQLObject/trunk/sqlobject/mysql/mysqlconnection.py 2006-06-15 16:41:29 UTC (rev 1814) @@ -145,6 +145,9 @@ if field == 'id': continue colClass, kw = self.guessClass(t) + if self.kw['use_unicode'] and colClass is col.StringCol: + colClass = col.UnicodeCol + if self.client_encoding: kw['dbEncoding'] = self.client_encoding kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field) kw['notNone'] = not nullAllowed if default and t.startswith('int'): @@ -180,18 +183,18 @@ elif t.startswith('tinyblob'): return col.BLOBCol, {"length": 2**8-1} elif t.startswith('tinytext'): - return col.BLOBCol, {"length": 2**8-1, "varchar": True} + return col.StringCol, {"length": 2**8-1, "varchar": True} elif t.startswith('blob'): return col.BLOBCol, {"length": 2**16-1} elif t.startswith('text'): - return col.BLOBCol, {"length": 2**16-1, "varchar": True} + return col.StringCol, {"length": 2**16-1, "varchar": True} elif t.startswith('mediumblob'): return col.BLOBCol, {"length": 2**24-1} elif t.startswith('mediumtext'): - return col.BLOBCol, {"length": 2**24-1, "varchar": True} + return col.StringCol, {"length": 2**24-1, "varchar": True} elif t.startswith('longblob'): return col.BLOBCol, {"length": 2**32} elif t.startswith('longtext'): - return col.BLOBCol, {"length": 2**32, "varchar": True} + return col.StringCol, {"length": 2**32, "varchar": True} else: return col.Col, {} Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py =================================================================== --- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2006-06-14 23:23:52 UTC (rev 1813) +++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2006-06-15 16:41:29 UTC (rev 1814) @@ -238,7 +238,7 @@ if field == primaryKey: continue colClass, kw = self.guessClass(t) - if self.unicodeCols and colClass == col.StringCol: + if self.unicodeCols and colClass is col.StringCol: colClass = col.UnicodeCol kw['dbEncoding'] = client_encoding kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field) @@ -327,7 +327,6 @@ conn.close() - # Converter for psycopg Binary type. def PsycoBinaryConverter(value, db): assert db == 'postgres' |