dabo Commit
Revision 2615
Date: 2007-01-06 22:28:20 -0800 (Sat, 06 Jan 2007)
Author: Paul
Changed:
U branches/paul_sandbox/dabo/db/dBackend.py
U branches/paul_sandbox/dabo/db/dCursorMixin.py
U branches/paul_sandbox/dabo/db/dbSQLite.py
U branches/paul_sandbox/dabo/db/test/test_dCursorMixin.py
Log:
Reverted my prior switch to use getFields() for DataStructure, because
getFields() doesn't take into account derived fields, or fields in other
joined tables, which was the whole reason we added getStructureDescription
in the first place.
Fixed getStructureDescription() to be generic (no need for a separate
one in dbSQLite anymore) and to return consistent formats for sqlite
and mysql. Still need to add unit tests for the other databases to
make sure everything still works. In the meantime, if users of Firebird
(Uwe?) and Postgres (John?) could check out the paul_sandbox branch and
see if it works with their apps that would be most helpful.
Diff:
Modified: branches/paul_sandbox/dabo/db/dBackend.py
===================================================================
--- branches/paul_sandbox/dabo/db/dBackend.py 2007-01-07 01:44:47 UTC (rev
2614)
+++ branches/paul_sandbox/dabo/db/dBackend.py 2007-01-07 06:28:20 UTC (rev
2615)
@@ -394,6 +394,28 @@
or (b[5] != s[5]) or (b[6] != s[6]) ]
+ def getStructureDescription(self, cursor):
+ """Return the basic field structure."""
+ field_structure = {}
+ field_names =[]
+
+ for field_info in cursor.FieldDescription:
+ field_name = field_info[0]
+ field_type = self.getDaboFieldType(field_info[1])
+ field_names.append(field_name)
+ field_structure[field_name] = (field_type, False)
+
+ standard_fields = cursor.getFields()
+ for field_name, field_type, pk in standard_fields:
+ if field_name in field_names:
+ field_structure[field_name] = (field_type, pk)
+
+ ret = []
+ for field in field_names:
+ ret.append( (field, field_structure[field][0],
field_structure[field][1]) )
+ return tuple(ret)
+
+
########## Created by Echo ##############
def isExistingTable(self, table):
"""Returns whether or not the table exists."""
Modified: branches/paul_sandbox/dabo/db/dCursorMixin.py
===================================================================
--- branches/paul_sandbox/dabo/db/dCursorMixin.py 2007-01-07 01:44:47 UTC
(rev 2614)
+++ branches/paul_sandbox/dabo/db/dCursorMixin.py 2007-01-07 06:28:20 UTC
(rev 2615)
@@ -1880,7 +1880,7 @@
# Nothing we can do. We are probably an
AuxCursor
pass
else:
- ds = self.getFields()
+ ds =
self.BackendObject.getStructureDescription(self)
for field in ds:
field_name, field_type, pk =
field[0], field[1], field[2]
try:
Modified: branches/paul_sandbox/dabo/db/dbSQLite.py
===================================================================
--- branches/paul_sandbox/dabo/db/dbSQLite.py 2007-01-07 01:44:47 UTC (rev
2614)
+++ branches/paul_sandbox/dabo/db/dbSQLite.py 2007-01-07 06:28:20 UTC (rev
2615)
@@ -91,19 +91,19 @@
def getFields(self, tableName):
tempCursor = self._connection.cursor()
-
- # Get the field info
tempCursor.execute("pragma table_info('%s')" % tableName)
rs = tempCursor.fetchall()
fields = []
for rec in rs:
typ = rec[2].lower()
- if typ == "integer":
+ if typ[:3] == "int":
fldType = "I"
- elif typ == "real":
+ elif typ[:3] == "dec" or typ[:4] == "real":
fldType = "N"
elif typ == "blob":
fldType = "L"
+ elif typ[:4] == "clob" or typ[:8] == "longtext":
+ fldType = "M"
else:
# SQLite treats everything else as text
fldType = "C"
Modified: branches/paul_sandbox/dabo/db/test/test_dCursorMixin.py
===================================================================
--- branches/paul_sandbox/dabo/db/test/test_dCursorMixin.py 2007-01-07
01:44:47 UTC (rev 2614)
+++ branches/paul_sandbox/dabo/db/test/test_dCursorMixin.py 2007-01-07
06:28:20 UTC (rev 2615)
@@ -30,6 +30,8 @@
ds = self.cur.DataStructure
self.assertEqual(ds[0], ("pk", "I", True, self.temp_table_name,
"pk", None))
self.assertEqual(ds[1], ("cField", "C", False,
self.temp_table_name, "cField", None))
+ self.assertEqual(ds[2], ("iField", "I", False,
self.temp_table_name, "iField", None))
+ self.assertEqual(ds[3], ("nField", "N", False,
self.temp_table_name, "nField", None))
def testMementos(self):
cur = self.cur
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev