diff options
| author | Jacobo de Vera <devel@jacobodevera.com> | 2015-11-13 16:57:41 +0100 |
|---|---|---|
| committer | Jacobo de Vera <devel@jacobodevera.com> | 2015-11-13 20:51:05 +0100 |
| commit | 80ce23f6fd0f14ab656d3ec82773bd0cffbd4791 (patch) | |
| tree | 867b5f48d77aa22b0cdd6d82321651a9535aa5d7 | |
| parent | 3370cbde509b3e230c46a503956f11f78df74b88 (diff) | |
| download | sqlalchemy-pr/213.tar.gz | |
Pass precision value to mssql.DATETIME2 when it is 0pr/213
The simple check on the precision results in DATETIME2(0) generating a
DATETIME2 column, with default precision, which is 7.
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 2 | ||||
| -rw-r--r-- | test/dialect/mssql/test_types.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 37e798014..9e39ca9f2 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -773,7 +773,7 @@ class MSTypeCompiler(compiler.GenericTypeCompiler): def visit_DATETIME2(self, type_, **kw): precision = getattr(type_, 'precision', None) - if precision: + if precision is not None: return "DATETIME2(%s)" % precision else: return "DATETIME2" diff --git a/test/dialect/mssql/test_types.py b/test/dialect/mssql/test_types.py index e782bd5e5..d8a82630b 100644 --- a/test/dialect/mssql/test_types.py +++ b/test/dialect/mssql/test_types.py @@ -464,6 +464,8 @@ class TypeRoundTripTest( (mssql.MSDateTime2, [], {}, 'DATETIME2', ['>=', (10,)]), + (mssql.MSDateTime2, [0], {}, + 'DATETIME2(0)', ['>=', (10,)]), (mssql.MSDateTime2, [1], {}, 'DATETIME2(1)', ['>=', (10,)]), |
