From 66a74c136fbb16e81efeb3e4e42c8e6dc7519dd1 Mon Sep 17 00:00:00 2001 From: Rick Morrison Date: Thu, 15 Feb 2007 00:22:07 +0000 Subject: [PATCH] revert old unittest patch for MSSQL --- lib/sqlalchemy/databases/mssql.py | 2 ++ test/engine/transaction.py | 2 +- test/orm/session.py | 14 -------------- test/tables.py | 9 --------- test/testbase.py | 16 +++++++--------- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 2957791735..abdb670d68 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -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): diff --git a/test/engine/transaction.py b/test/engine/transaction.py index 16667c1e05..c89bf4b145 100644 --- a/test/engine/transaction.py +++ b/test/engine/transaction.py @@ -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), diff --git a/test/orm/session.py b/test/orm/session.py index 148bcd2b5d..7d2a472aaf 100644 --- a/test/orm/session.py +++ b/test/orm/session.py @@ -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): diff --git a/test/tables.py b/test/tables.py index f9c131653e..7f7cebd05e 100644 --- a/test/tables.py +++ b/test/tables.py @@ -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 = [ diff --git a/test/testbase.py b/test/testbase.py index b35c5e7ff4..1dbd654c71 100644 --- a/test/testbase.py +++ b/test/testbase.py @@ -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()) + -- 2.47.2