[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7715 - in trunk/gnue-common/src/datasources/drivers/sql: sqlite2
From: |
johannes |
Subject: |
[gnue] r7715 - in trunk/gnue-common/src/datasources/drivers/sql: sqlite2 sqlite3 |
Date: |
Fri, 8 Jul 2005 04:33:51 -0500 (CDT) |
Author: johannes
Date: 2005-07-08 04:33:50 -0500 (Fri, 08 Jul 2005)
New Revision: 7715
Modified:
trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py
Log:
Simplified behavior
Modified: trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py
2005-07-08 09:28:19 UTC (rev 7714)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite2/Behavior.py
2005-07-08 09:33:50 UTC (rev 7715)
@@ -102,6 +102,7 @@
self._type2native.update ({'boolean' : 'integer',
'datetime': 'timestamp'})
+ self._passThroughTypes = ['date', 'datetime', 'time']
# ---------------------------------------------------------------------------
@@ -248,7 +249,7 @@
elif typename.lower () == 'timestamp':
attrs ['type'] = 'datetime'
- elif typename.lower () in ['date', 'datetime', 'time']:
+ elif typename.lower () in self._passThroughTypes:
attrs ['type'] = typename.lower ()
else:
Modified: trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py
2005-07-08 09:28:19 UTC (rev 7714)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite3/Behavior.py
2005-07-08 09:33:50 UTC (rev 7715)
@@ -56,96 +56,4 @@
self._type2native.update ({'boolean' : 'boolean',
'datetime': 'timestamp'})
-
-
- # ---------------------------------------------------------------------------
- # Parse all fields from a given SQL code
- # ---------------------------------------------------------------------------
-
- def __parseFields (self, table, sql):
-
- result = {}
-
- # Replace all newlines by a single whitespace and take all the code in
- # between the first and last bracket
- code = ' '.join (sql.splitlines ())
- code = code [code.find ('(') + 1:code.rfind (')')]
-
- # Reduce multiple blanks to a single blank
- code = Base._BLANKS.sub (' ', code)
- # Make sure to have numeric arugments like '( 5 , 2)' given as '(5;2)'
- code = Base._REPCOMMAS.sub (r'(\1;\2)', code)
- # Realign arguments in parenthesis, i.e. from 'char( 7 )' to 'char (7)'
- code = Base._ALIGN.sub (r' (\1)', code)
-
- # we currently skip all constraints (primary key, unique, check)
- cma = Base._CONSTRAINTS.match (code)
- while cma is not None:
- constraint = cma.groups () [0]
- code = code.replace (constraint, '')
- cma = Base._CONSTRAINTS.match (code)
-
- for item in [i.strip () for i in code.split (',')]:
- if not len (item):
- continue
-
- parts = item.split ()
-
- if Base._PKFIELD.match (item) is not None:
- pk = table.findChildOfType ('GSPrimaryKey') or \
- GSchema.GSPrimaryKey (table, name = 'pk_%s' % table.name)
- GSchema.GSPKField (pk, name = parts [0])
-
- attrs = {'id' : "%s.%s" % (table.name, parts [0]),
- 'name': parts [0]}
-
- datatype = ' '.join (parts [1:])
-
- lsmatch = Base._LEN_SCALE.match (datatype)
- if lsmatch is not None:
- (typename, length, scale) = lsmatch.groups ()
- else:
- typename = parts [1]
- length = 0
- scale = 0
-
- nativetype = typename
- add = filter (None, [length, scale])
- nativetype += add and "(%s)" % ','.join (add) or ''
-
- attrs ['nativetype'] = nativetype
-
- if length:
- attrs ['length'] = int (length)
- if scale:
- attrs ['precision'] = int (scale)
-
- attrs ['nullable'] = Base._NOTNULL.match (item) is None
-
- if Base._TEXTTYPE.match (typename.upper ()):
- attrs ['type'] = 'string'
-
- elif typename.lower () == 'timestamp':
- attrs ['type'] = 'datetime'
-
- elif typename.lower () in ['date', 'datetime', 'time', 'boolean']:
- attrs ['type'] = typename.lower ()
-
- else:
- attrs ['type'] = 'number'
-
- fields = table.findChildOfType ('GSFields') or GSchema.GSFields (table)
- result [attrs ['id']] = GSchema.GSField (fields, **attrs)
-
- match = Base._DEFAULT.match (item)
- if match is not None:
- text = match.groups () [0].strip ()
- if text [0] in ["'", '"']:
- default = text [1:text.find (text [0], 1)]
- else:
- default = text.split () [0]
-
- result [attrs ['id']].defaultwith = 'constant'
- result [attrs ['id']].default = default
-
- return result
+ self._passThroughTypes.append ('boolean')
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7715 - in trunk/gnue-common/src/datasources/drivers/sql: sqlite2 sqlite3,
johannes <=