diff options
author | Rick Morrison <rickmorrison@gmail.com> | 2009-01-23 00:53:32 +0000 |
---|---|---|
committer | Rick Morrison <rickmorrison@gmail.com> | 2009-01-23 00:53:32 +0000 |
commit | 0caf97126394f059d94bffb5c2fdf49c4680cba1 (patch) | |
tree | 8b8c77c9f3992add3c869ab83107a8a7c7cabbdf /lib/sqlalchemy/databases | |
parent | fc7de2aafd8caf1354b81a1a34817f1622302957 (diff) | |
download | sqlalchemy-0caf97126394f059d94bffb5c2fdf49c4680cba1.tar.gz |
mssql: modified table reflection code to use only kwargs when constructing coldefs.
Diffstat (limited to 'lib/sqlalchemy/databases')
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index ddd130679..ae3612513 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -1148,32 +1148,28 @@ class MSSQLDialect(default.DefaultDialect): if include_columns and name not in include_columns: continue - args = [] - for a in (charlen, numericprec, numericscale): - if a is not None: - args.append(a) coltype = self.ischema_names.get(type, None) kwargs = {} if coltype in (MSString, MSChar, MSNVarchar, MSNChar, MSText, MSNText): + kwargs['length'] = charlen if collation: - kwargs.update(collation=collation) + kwargs['collation'] = collation + if coltype == MSText or (coltype in (MSString, MSNVarchar) and charlen == -1): + kwargs.pop('length') - if coltype == MSText or (coltype == MSString and charlen == -1): - coltype = MSText(**kwargs) - else: - if coltype is None: - util.warn("Did not recognize type '%s' of column '%s'" % - (type, name)) - coltype = sqltypes.NULLTYPE - - elif coltype in (MSNVarchar,) and charlen == -1: - args[0] = None - coltype = coltype(*args, **kwargs) + if coltype in (MSNumeric,): # TODO: include MSMoney? + kwargs['scale'] = numericscale + kwargs['precision'] = numericprec + + if coltype is None: + util.warn("Did not recognize type '%s' of column '%s'" % (type, name)) + coltype = sqltypes.NULLTYPE + + coltype = coltype(**kwargs) colargs = [] if default is not None: colargs.append(schema.DefaultClause(sql.text(default))) - table.append_column(schema.Column(name, coltype, nullable=nullable, autoincrement=False, *colargs)) if not found_table: |