]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
revert old unittest patch for MSSQL
authorRick Morrison <rickmorrison@gmail.com>
Thu, 15 Feb 2007 00:22:07 +0000 (00:22 +0000)
committerRick Morrison <rickmorrison@gmail.com>
Thu, 15 Feb 2007 00:22:07 +0000 (00:22 +0000)
lib/sqlalchemy/databases/mssql.py
test/engine/transaction.py
test/orm/session.py
test/tables.py
test/testbase.py

index 2957791735d46ade701e3cd12c0cf87194e9145f..abdb670d68c655de86c3a83222741051a935877d 100644 (file)
@@ -337,6 +337,8 @@ class MSSQLDialect(ansisql.ANSIDialect):
     def create_connect_args(self, url):
         opts = url.translate_connect_args(['host', 'database', 'user', 'password', 'port'])
         opts.update(url.query)
+        if opts.has_key('auto_identity_insert'):
+            self.auto_identity_insert = bool(int(opts['auto_identity_insert']))
         return make_connect_string(opts)
 
     def create_execution_context(self):
index 16667c1e05c5bc8b92846ba8bf451b1bde927856..c89bf4b145eee09e41e69286b8eb883feeda5013 100644 (file)
@@ -144,7 +144,7 @@ class AutoRollbackTest(testbase.PersistTest):
 class TLTransactionTest(testbase.PersistTest):
     def setUpAll(self):
         global users, metadata, tlengine
-        tlengine = create_engine(testbase.db_uri, strategy='threadlocal', **testbase.db_opts)
+        tlengine = create_engine(testbase.db_uri, strategy='threadlocal')
         metadata = MetaData()
         users = Table('query_users', metadata,
             Column('user_id', INT, primary_key = True),
index 148bcd2b5d88ba692a62d947f9d2a3426b8545ed..7d2a472aaf7f5fed9b1bb026e5742ad6c5a149ac 100644 (file)
@@ -162,20 +162,6 @@ class SessionTest(AssertMixin):
         assert s.query(Address).selectone().address_id == a.address_id
         assert s.query(User).selectfirst() is None
 
-    def test_fetchid(self):
-        # this is necessary to ensure the test fails on old versions of mssql        
-        if hasattr(autoseq.columns['autoseq_id'], 'sequence'):
-            del autoseq.columns['autoseq_id'].sequence
-        
-        mapper(Autoseq, autoseq)
-        s = create_session()
-        u = Autoseq()
-        s.save(u)
-        s.flush()
-        assert u.autoseq_id is not None
-        s.clear()
-        
-
         
 class OrphanDeletionTest(AssertMixin):
 
index f9c131653e1e4fd35e53c51a72071bae5f14d3f8..7f7cebd05ed7956a2c53c44eb2acbaddd37fd77f 100644 (file)
@@ -53,11 +53,6 @@ itemkeywords = Table('itemkeywords', metadata,
 #    Column('foo', Boolean, default=True)
 )
 
-autoseq = Table('autoseq', metadata,
-    Column('autoseq_id', Integer, primary_key = True),
-    Column('name', String)
-)
-
 def create():
     metadata.create_all()
 def drop():
@@ -170,10 +165,6 @@ class Keyword(object):
     def __repr__(self):
         return "Keyword: %s/%s" % (repr(getattr(self, 'keyword_id', None)),repr(self.name))
 
-class Autoseq(object):
-    def __init__(self):
-        self.autoseq_id = None
-
 user_result = [{'user_id' : 7}, {'user_id' : 8}, {'user_id' : 9}]
 
 user_address_result = [
index b35c5e7ff44cdd4c650799cb062671fad2203cba..1dbd654c7163a44b9b81b319c403be1b70b92ef2 100644 (file)
@@ -16,7 +16,6 @@ from sqlalchemy.orm import clear_mappers
 db = None
 metadata = None
 db_uri = None
-db_opts = {}
 echo = True
 
 # redefine sys.stdout so all those print statements go to the echo func
@@ -34,7 +33,7 @@ def echo_text(text):
 def parse_argv():
     # we are using the unittest main runner, so we are just popping out the 
     # arguments we need instead of using our own getopt type of thing
-    global db, db_uri, db_opts, metadata
+    global db, db_uri, metadata
     
     DBTYPE = 'sqlite'
     PROXY = False
@@ -62,9 +61,7 @@ def parse_argv():
     elif options.db:
         DBTYPE = param = options.db
 
-    if DBTYPE == 'mssql':
-        db_opts['auto_identity_insert'] = True    
-    
+    opts = {}
     if (None == db_uri):
         if DBTYPE == 'sqlite':
             db_uri = 'sqlite:///:memory:'
@@ -78,7 +75,7 @@ def parse_argv():
             db_uri = 'oracle://scott:tiger@127.0.0.1:1521'
         elif DBTYPE == 'oracle8':
             db_uri = 'oracle://scott:tiger@127.0.0.1:1521'
-            db_opts = {'use_ansi':False, 'auto_setinputsizes':True}
+            opts = {'use_ansi':False, 'auto_setinputsizes':True}
         elif DBTYPE == 'mssql':
             db_uri = 'mssql://scott:tiger@SQUAWK\\SQLEXPRESS/test'
         elif DBTYPE == 'firebird':
@@ -101,11 +98,11 @@ def parse_argv():
     with_coverage = options.coverage
     
     if options.enginestrategy is not None:
-        db_opts['strategy'] = options.enginestrategy    
+        opts['strategy'] = options.enginestrategy    
     if options.mockpool:
-        db = engine.create_engine(db_uri, poolclass=pool.AssertionPool, **db_opts)
+        db = engine.create_engine(db_uri, poolclass=pool.AssertionPool, **opts)
     else:
-        db = engine.create_engine(db_uri, **db_opts)
+        db = engine.create_engine(db_uri, **opts)
     db = EngineAssert(db)
     
     if options.topological:
@@ -421,3 +418,4 @@ def main():
     sys.exit(not result.wasSuccessful())
 
 
+