From 9ae821ee660a2d03cae591798c05cfdbd8bb3ca6 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Thu, 22 Oct 2009 03:29:52 +0000 Subject: [PATCH] Removed references to sequence in MSSQL Implicit identities in mssql work the same as implicit sequences on any other dialects. Explicit sequences are enabled through the use of "default=Sequence()". See the MSSQL dialect documentation for more information. --- CHANGES | 5 +++++ README.unittests | 5 +++++ lib/sqlalchemy/dialects/mssql/base.py | 5 ++++- lib/sqlalchemy/engine/reflection.py | 2 +- test/dialect/test_mssql.py | 7 ++++--- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 480350fdf2..86baaa78a4 100644 --- a/CHANGES +++ b/CHANGES @@ -519,6 +519,11 @@ CHANGES case, so there's no point in having a flag. - using new dialect.initialize() feature to set up version-dependent behavior. + - removed references to sequence which is no longer used. + implicit identities in mssql work the same as implicit + sequences on any other dialects. Explicit sequences are + enabled through the use of "default=Sequence()". See + the MSSQL dialect documentation for more information. - types - The construction of types within dialects has been totally diff --git a/README.unittests b/README.unittests index ac1b7a18e6..9084efb7aa 100644 --- a/README.unittests +++ b/README.unittests @@ -50,6 +50,11 @@ intersesting: RUNNING INDIVIDUAL TESTS ------------------------- +Any directory of test modules can be run at once by specifying the directory +path: + + $ nosetest test/dialect + Any test module can be run directly by specifying its module name: $ nosetests test.orm.test_mapper diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 76846b6b43..ae9834a393 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -138,6 +138,9 @@ would yield:: Note that the ``start`` and ``increment`` values for sequences are optional and will default to 1,1. +Implicit ``autoincrement`` behavior works the same in MSSQL as it +does in other dialects and results in an ``IDENTITY`` column. + * Support for ``SET IDENTITY_INSERT ON`` mode (automagic on / off for ``INSERT`` s) @@ -1082,7 +1085,7 @@ class MSDDLCompiler(compiler.DDLCompiler): # install a IDENTITY Sequence if we have an implicit IDENTITY column if seq_col is column: - sequence = getattr(column, 'sequence', None) + sequence = isinstance(column.default, sa_schema.Sequence) and column.default if sequence: start, increment = sequence.start or 1, sequence.increment or 1 else: diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index d88a0a3d29..0bd1e955d0 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -300,7 +300,7 @@ class Inspector(object): colargs.append(sa_schema.DefaultClause(sql.text(col_d['default']))) if 'sequence' in col_d: - # TODO: whos using this ? + # TODO: mssql, maxdb and sybase are using this. seq = col_d['sequence'] sequence = sa_schema.Sequence(seq['name'], 1, 1) if 'start' in seq: diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py index 68f3816a56..b57bc426b8 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -322,8 +322,9 @@ class ReflectionTest(TestBase, ComparesTables): meta2 = MetaData(testing.db) try: table2 = Table('identity_test', meta2, autoload=True) - assert table2.c['col1'].sequence.start == 2 - assert table2.c['col1'].sequence.increment == 3 + sequence = isinstance(table2.c['col1'].default, schema.Sequence) and table2.c['col1'].default + assert sequence.start == 2 + assert sequence.increment == 3 finally: table.drop() @@ -799,7 +800,7 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): (types.Time, [], {}, 'DATETIME', ['<', (10,)], mssql.MSDateTime), (mssql.MSTime, [], {}, - 'DATETIME', ['<', (10,)], mssql.MSDateTime), + 'TIME', ['>=', (10,)]), (mssql.MSSmallDateTime, [], {}, 'SMALLDATETIME', []), -- 2.47.2