]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
mssql unit test fixes
authorPaul Johnston <paj@pajhome.org.uk>
Sun, 19 Aug 2007 15:30:02 +0000 (15:30 +0000)
committerPaul Johnston <paj@pajhome.org.uk>
Sun, 19 Aug 2007 15:30:02 +0000 (15:30 +0000)
test/orm/assorted_eager.py
test/sql/testtypes.py
test/testlib/testing.py

index 59fa2891ee2f57984821ea3d965c9b3153061ade..c98ffeb962e33d642eb143c79f6728b5e390070a 100644 (file)
@@ -717,10 +717,10 @@ class EagerTest8(ORMTest):
                                 )
 
     def setUp(self):
-        testbase.db.execute("INSERT INTO prj (title) values('project 1');")
-        testbase.db.execute("INSERT INTO task_status (id) values(1);")
-        testbase.db.execute("INSERT INTO task_type(id) values(1);")
-        testbase.db.execute("INSERT INTO task (title, task_type_id, status_id, prj_id) values('task 1',1,1,1);")
+        testbase.db.execute(project_t.insert(), {'id':1})
+        testbase.db.execute(task_status_t.insert(), {'id':1})
+        testbase.db.execute(task_type_t.insert(), {'id':1})
+        testbase.db.execute(task_t.insert(), {'title':'task 1', 'task_type_id':1, 'status_id':1, 'prj_id':1})
 
     def test_nested_joins(self):
         # this is testing some subtle column resolution stuff,
index 4ffb4c5916bf53311325369b84763e702bdb7d31..e355436ec147a39187fa0894e7749cdd8a6ce23c 100644 (file)
@@ -356,8 +356,8 @@ class DateTest(AssertMixin):
             ]
 
             if db.engine.name == 'mssql':
-                # MSSQL Datetime values have only a 3.33 milliseconds precision
-                insert_data[2] = [9, 'foo', datetime.datetime(2005, 11, 10, 11, 52, 35, 547000), datetime.date(1970,4,1), datetime.time(23,59,59,997000)]
+                # MSSQL can't reliably fetch the millisecond part
+                insert_data[2] = [9, 'foo', datetime.datetime(2005, 11, 10, 11, 52, 35), datetime.date(1970,4,1), datetime.time(23,59,59)]
             
             fnames = ['user_id', 'user_name', 'user_datetime', 'user_date', 'user_time']
 
index 58fd7c0d10adca60e3a59045861e49cbbe8e4261..0038fddfe916f12b41b5858f70d846364ad10417 100644 (file)
@@ -128,6 +128,8 @@ class ExecutionContextWrapper(object):
         ctx = self.ctx
         statement = unicode(ctx.compiled)
         statement = re.sub(r'\n', '', ctx.statement)
+        if config.db.name == 'mssql' and statement.endswith('; select scope_identity()'):
+            statement = statement[:-25]
         if testdata.buffer is not None:
             testdata.buffer.write(statement + "\n")
 
@@ -168,8 +170,6 @@ class ExecutionContextWrapper(object):
                 parameters = [p.get_original_dict() for p in ctx.compiled_parameters]
                     
             query = self.convert_statement(query)
-            if config.db.name == 'mssql' and statement.endswith('; select scope_identity()'):
-                statement = statement[:-25]
             testdata.unittest.assert_(statement == query and (params is None or params == parameters), "Testing for query '%s' params %s, received '%s' with params %s" % (query, repr(params), statement, repr(parameters)))
         testdata.sql_count += 1
         self.ctx.post_execution()