[SQL-CVS] r997 - SQLObject/trunk/sqlobject/postgres
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-09-20 20:48:37
|
Author: phd
Date: 2005-09-20 20:48:30 +0000 (Tue, 20 Sep 2005)
New Revision: 997
Modified:
SQLObject/trunk/sqlobject/postgres/pgconnection.py
Log:
Aplied a patch by Tomas <To...@ze...> that uses UnicodeCol instead of StringCol
in case fromDatabase = True and "unicodeCols" flag was passed in the connection arguments.
Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-09-20 15:58:41 UTC (rev 996)
+++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-09-20 20:48:30 UTC (rev 997)
@@ -13,7 +13,7 @@
schemes = [dbName, 'postgresql', 'psycopg']
def __init__(self, dsn=None, host=None, port=None, db=None,
- user=None, passwd=None, usePygresql=False,
+ user=None, passwd=None, usePygresql=False, unicodeCols=False,
**kw):
global psycopg, pgdb
self.usePygresql = usePygresql
@@ -78,6 +78,7 @@
dsn.append('port=%d' % port)
dsn = ' '.join(dsn)
self.dsn = dsn
+ self.unicodeCols = unicodeCols
DBAPI.__init__(self, **kw)
# Server version cache
@@ -220,10 +221,15 @@
colData = self.queryAll(colQuery % self.sqlrepr(tableName))
results = []
+ if self.unicodeCols:
+ client_encoding = self.queryOne("SHOW client_encoding")[0]
for field, t, notnull, defaultstr in colData:
if field == primaryKey:
continue
colClass, kw = self.guessClass(t)
+ if self.unicodeCols and colClass == col.StringCol:
+ colClass = col.UnicodeCol
+ kw['dbEncoding'] = client_encoding
kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
kw['dbName'] = field
kw['notNone'] = notnull
|