Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv13135/SQLObject
Modified Files:
DBConnection.py
Log Message:
Took out Firebird auto-class generation methods that were just
copies of Postgres's
Index: DBConnection.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** DBConnection.py 7 Sep 2003 07:17:50 -0000 1.45
--- DBConnection.py 7 Sep 2003 07:25:58 -0000 1.46
***************
*** 818,880 ****
column.dbName))
- def columnsFromSchema(self, tableName, soClass):
- #let's punt for now!!!
- return
- keyQuery = """
- SELECT pg_catalog.pg_get_constraintdef(oid) as condef
- FROM pg_catalog.pg_constraint r
- WHERE r.conrelid = '%s'::regclass AND r.contype = 'f'"""
-
- colQuery = """
- SELECT a.attname,
- pg_catalog.format_type(a.atttypid, a.atttypmod), a.attnotnull,
- (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
- WHERE d.adrelid=a.attrelid AND d.adnum = a.attnum)
- FROM pg_catalog.pg_attribute a
- WHERE a.attrelid ='%s'::regclass
- AND a.attnum > 0 AND NOT a.attisdropped
- ORDER BY a.attnum"""
-
- keyData = self.queryAll(keyQuery % tableName)
- keyRE = re.compile("\((.+)\) REFERENCES (.+)\(")
- keymap = {}
- for (condef,) in keyData:
- match = keyRE.search(condef)
- if match:
- field, reftable = match.groups()
- keymap[field] = reftable.capitalize()
- colData = self.queryAll(colQuery % tableName)
- results = []
- for field, t, notnull, defaultstr in colData:
- if field == 'id':
- continue
- colClass, kw = self.guessClass(t)
- kw['name'] = soClass._style.dbColumnToPythonAttr(field)
- kw['notNone'] = notnull
- if defaultstr is not None:
- kw['default'] = getattr(SQLBuilder.const, defaultstr)
- if keymap.has_key(field):
- kw['foreignKey'] = keymap[field]
- results.append(colClass(**kw))
- return results
-
- def guessClass(self, t):
- # ditto on the punting
- return
- if t.count('int'):
- return Col.IntCol, {}
- elif t.count('varying'):
- return Col.StringCol, {'length': int(t[t.index('(')+1:-1])}
- elif t.startswith('character('):
- return Col.StringCol, {'length': int(t[t.index('(')+1:-1]),
- 'varchar': False}
- elif t=='text':
- return Col.StringCol, {}
- elif t.startswith('datetime'):
- return Col.DateTimeCol, {}
- else:
- return Col.Col, {}
-
-
########################################
## File-based connections
--- 818,821 ----
|