summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sqlite/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite/base.py')
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py56
1 files changed, 31 insertions, 25 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index a1bd05d38..70caef1e4 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -857,24 +857,7 @@ class SQLiteDialect(default.DefaultDialect):
return columns
def _get_column_info(self, name, type_, nullable, default, primary_key):
- match = re.match(r'([\w ]+)(\(.*?\))?', type_)
- if match:
- coltype = match.group(1)
- args = match.group(2)
- else:
- coltype = ''
- args = ''
- coltype = self._resolve_type_affinity(coltype)
- if args is not None:
- args = re.findall(r'(\d+)', args)
- try:
- coltype = coltype(*[int(a) for a in args])
- except TypeError:
- util.warn(
- "Could not instantiate type %s with "
- "reflected arguments %s; using no arguments." %
- (coltype, args))
- coltype = coltype()
+ coltype = self._resolve_type_affinity(type_)
if default is not None:
default = util.text_type(default)
@@ -888,7 +871,7 @@ class SQLiteDialect(default.DefaultDialect):
'primary_key': primary_key,
}
- def _resolve_type_affinity(self, coltype):
+ def _resolve_type_affinity(self, type_):
"""Return a data type from a reflected column, using affinity tules.
SQLite's goal for universal compatability introduces some complexity
@@ -905,18 +888,41 @@ class SQLiteDialect(default.DefaultDialect):
DATE and DOUBLE).
"""
+ match = re.match(r'([\w ]+)(\(.*?\))?', type_)
+ if match:
+ coltype = match.group(1)
+ args = match.group(2)
+ else:
+ coltype = ''
+ args = ''
+
if coltype in self.ischema_names:
- return self.ischema_names[coltype]
+ coltype = self.ischema_names[coltype]
elif 'INT' in coltype:
- return sqltypes.INTEGER
+ coltype = sqltypes.INTEGER
elif 'CHAR' in coltype or 'CLOB' in coltype or 'TEXT' in coltype:
- return sqltypes.TEXT
+ coltype = sqltypes.TEXT
elif 'BLOB' in coltype or not coltype:
- return sqltypes.NullType
+ coltype = sqltypes.NullType
elif 'REAL' in coltype or 'FLOA' in coltype or 'DOUB' in coltype:
- return sqltypes.REAL
+ coltype = sqltypes.REAL
else:
- return sqltypes.NUMERIC
+ coltype = sqltypes.NUMERIC
+
+ if args is not None:
+ args = re.findall(r'(\d+)', args)
+ try:
+ coltype = coltype(*[int(a) for a in args])
+ except TypeError:
+ util.warn(
+ "Could not instantiate type %s with "
+ "reflected arguments %s; using no arguments." %
+ (coltype, args))
+ coltype = coltype()
+ else:
+ coltype = coltype()
+
+ return coltype
@reflection.cache
def get_pk_constraint(self, connection, table_name, schema=None, **kw):