diff options
author | Federico Caselli <cfederico87@gmail.com> | 2022-09-24 15:50:26 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-10-17 15:36:25 -0400 |
commit | 974b1bd0fc40e11fc2886b5a9fc333feeeebf546 (patch) | |
tree | 421f0545c13a203f40435c4646a0de664e0e9756 /lib/sqlalchemy/dialects/mssql/provision.py | |
parent | 665c94cc2f0340735515c4f4477e11b556d2bcd8 (diff) | |
download | sqlalchemy-974b1bd0fc40e11fc2886b5a9fc333feeeebf546.tar.gz |
Revert automatic set of sequence start to 1
The :class:`.Sequence` construct restores itself to the DDL behavior it
had prior to the 1.4 series, where creating a :class:`.Sequence` with
no additional arguments will emit a simple ``CREATE SEQUENCE`` instruction
**without** any additional parameters for "start value". For most backends,
this is how things worked previously in any case; **however**, for
MS SQL Server, the default value on this database is
``-2**63``; to prevent this generally impractical default
from taking effect on SQL Server, the :paramref:`.Sequence.start` parameter
should be provided. As usage of :class:`.Sequence` is unusual
for SQL Server which for many years has standardized on ``IDENTITY``,
it is hoped that this change has minimal impact.
Fixes: #7211
Change-Id: I1207ea10c8cb1528a1519a0fb3581d9621c27b31
Diffstat (limited to 'lib/sqlalchemy/dialects/mssql/provision.py')
-rw-r--r-- | lib/sqlalchemy/dialects/mssql/provision.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/provision.py b/lib/sqlalchemy/dialects/mssql/provision.py index f307c7140..a7ecf4aa3 100644 --- a/lib/sqlalchemy/dialects/mssql/provision.py +++ b/lib/sqlalchemy/dialects/mssql/provision.py @@ -14,6 +14,7 @@ from ...testing.provision import drop_all_schema_objects_pre_tables from ...testing.provision import drop_db from ...testing.provision import get_temp_table_name from ...testing.provision import log +from ...testing.provision import normalize_sequence from ...testing.provision import run_reap_dbs from ...testing.provision import temp_table_keyword_args @@ -116,3 +117,10 @@ def drop_all_schema_objects_pre_tables(cfg, eng): ) ) ) + + +@normalize_sequence.for_db("mssql") +def normalize_sequence(cfg, sequence): + if sequence.start is None: + sequence.start = 1 + return sequence |