[SQL-CVS] r1130 - SQLObject/trunk/sqlobject/postgres
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-10-20 16:07:07
|
Author: phd
Date: 2005-10-20 16:06:43 +0000 (Thu, 20 Oct 2005)
New Revision: 1130
Modified:
SQLObject/trunk/sqlobject/postgres/pgconnection.py
Log:
Applied a patch by gary ng <li...@ga...> to guess more column types.
Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-19 03:07:59 UTC (rev 1129)
+++ SQLObject/trunk/sqlobject/postgres/pgconnection.py 2005-10-20 16:06:43 UTC (rev 1130)
@@ -248,7 +248,7 @@
def guessClass(self, t):
if t.count('int'):
return col.IntCol, {}
- elif t.count('varying'):
+ elif t.count('varying') or t.count('varchar'):
if '(' in t:
return col.StringCol, {'length': int(t[t.index('(')+1:-1])}
else: # varchar without length in Postgres means any length
@@ -256,10 +256,16 @@
elif t.startswith('character('):
return col.StringCol, {'length': int(t[t.index('(')+1:-1]),
'varchar': False}
+ elif t.count('float') or t.count('real') or t.count('double'):
+ return col.FloatCol, {}
elif t == 'text':
return col.StringCol, {}
+ elif t.startswith('timestamp'):
+ return col.DateTimeCol, {}
elif t.startswith('datetime'):
return col.DateTimeCol, {}
+ elif t.startswith('date'):
+ return col.DateCol, {}
elif t.startswith('bool'):
return col.BoolCol, {}
elif t.startswith('bytea'):
|