summaryrefslogtreecommitdiff
path: root/test/dialect/test_mssql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-22 19:17:21 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-22 19:17:21 -0500
commit21870c750302704890f5fc7a4e15c7e27c3e512f (patch)
tree2227f81e9689a022b22b29c60d6644ec9dcc9a2c /test/dialect/test_mssql.py
parent82e4bc2f52f2d420842819d0ffe548ca968bf54e (diff)
downloadsqlalchemy-21870c750302704890f5fc7a4e15c7e27c3e512f.tar.gz
- [bug] Adjusted the regexp used in the
mssql.TIME type to ensure only six digits are received for the "microseconds" portion of the value, which is expected by Python's datetime.time(). Note that support for sending microseconds doesn't seem to be possible yet with pyodbc at least. [ticket:2340]
Diffstat (limited to 'test/dialect/test_mssql.py')
-rw-r--r--test/dialect/test_mssql.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py
index 75e9510eb..94609d953 100644
--- a/test/dialect/test_mssql.py
+++ b/test/dialect/test_mssql.py
@@ -10,6 +10,7 @@ from sqlalchemy.orm import *
from sqlalchemy.sql import table, column
from sqlalchemy.databases import mssql
from sqlalchemy.dialects.mssql import pyodbc, mxodbc, pymssql
+from sqlalchemy.dialects.mssql.base import TIME
from sqlalchemy.engine import url
from test.lib import *
from test.lib.testing import eq_, emits_warning_on, \
@@ -1108,6 +1109,22 @@ class ParseConnectTest(fixtures.TestBase, AssertsCompiledSQL):
'Unrecognized server version info',
engine.connect)
+class TimeTypeTest(fixtures.TestBase):
+
+ def test_result_processor_no_microseconds(self):
+ expected = datetime.time(12, 34, 56)
+ self._assert_result_processor(expected, '12:34:56')
+
+ def test_result_processor_too_many_microseconds(self):
+ # microsecond must be in 0..999999, should truncate (6 vs 7 digits)
+ expected = datetime.time(12, 34, 56, 123456)
+ self._assert_result_processor(expected, '12:34:56.1234567')
+
+ def _assert_result_processor(self, expected, value):
+ mssql_time_type = TIME()
+ result_processor = mssql_time_type.result_processor(None, None)
+ eq_(expected, result_processor(value))
+
class TypesTest(fixtures.TestBase, AssertsExecutionResults, ComparesTables):
__only_on__ = 'mssql'