From 974b1bd0fc40e11fc2886b5a9fc333feeeebf546 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Sat, 24 Sep 2022 15:50:26 +0200 Subject: 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 --- test/sql/test_insert_exec.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'test/sql/test_insert_exec.py') diff --git a/test/sql/test_insert_exec.py b/test/sql/test_insert_exec.py index 429ebf163..d9dac75b3 100644 --- a/test/sql/test_insert_exec.py +++ b/test/sql/test_insert_exec.py @@ -17,11 +17,13 @@ from sqlalchemy import testing from sqlalchemy import VARCHAR from sqlalchemy.engine import cursor as _cursor from sqlalchemy.testing import assert_raises_message +from sqlalchemy.testing import config from sqlalchemy.testing import eq_ from sqlalchemy.testing import expect_raises_message from sqlalchemy.testing import fixtures from sqlalchemy.testing import is_ from sqlalchemy.testing import mock +from sqlalchemy.testing.provision import normalize_sequence from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table @@ -268,7 +270,9 @@ class InsertExecTest(fixtures.TablesTest): Column( "id", Integer, - Sequence("t4_id_seq", optional=True), + normalize_sequence( + config, Sequence("t4_id_seq", optional=True) + ), primary_key=True, ), Column("foo", String(30), primary_key=True), @@ -296,7 +300,7 @@ class InsertExecTest(fixtures.TablesTest): Column( "id", Integer, - Sequence("t4_id_seq"), + normalize_sequence(config, Sequence("t4_id_seq")), primary_key=True, ), Column("foo", String(30)), @@ -471,7 +475,7 @@ class TableInsertTest(fixtures.TablesTest): Column( "id", Integer, - Sequence("t_id_seq"), + normalize_sequence(config, Sequence("t_id_seq")), primary_key=True, ), Column("data", String(50)), @@ -547,7 +551,11 @@ class TableInsertTest(fixtures.TablesTest): self._test( connection, t.insert().values( - id=func.next_value(Sequence("t_id_seq")), data="data", x=5 + id=func.next_value( + normalize_sequence(config, Sequence("t_id_seq")) + ), + data="data", + x=5, ), (testing.db.dialect.default_sequence_base, "data", 5), ) -- cgit v1.2.1