From a134956c4e4564844c33302ddf27a70102fe00a8 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Tue, 14 Jun 2022 10:09:04 -0600 Subject: Allow NUMERIC()/DECIMAL() IDENTITY columns Fixed issue where :class:`.Table` objects that made use of IDENTITY columns with a :class:`.Numeric` datatype would produce errors when attempting to reconcile the "autoincrement" column, preventing construction of the :class:`.Column` from using the :paramref:`.Column.autoincrement` parameter as well as emitting errors when attempting to invoke an :class:`.Insert` construct. Fixes: #8111 Change-Id: Iaacc4eebfbafb42fa18f9a1a4f43cb2b6b91d28a --- test/dialect/mssql/test_query.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/dialect') diff --git a/test/dialect/mssql/test_query.py b/test/dialect/mssql/test_query.py index 3576a9fc2..29bf4c812 100644 --- a/test/dialect/mssql/test_query.py +++ b/test/dialect/mssql/test_query.py @@ -1,4 +1,6 @@ # -*- encoding: utf-8 +import decimal + from sqlalchemy import and_ from sqlalchemy import Column from sqlalchemy import DDL @@ -9,6 +11,7 @@ from sqlalchemy import func from sqlalchemy import Identity from sqlalchemy import Integer from sqlalchemy import literal +from sqlalchemy import Numeric from sqlalchemy import or_ from sqlalchemy import PrimaryKeyConstraint from sqlalchemy import select @@ -39,6 +42,13 @@ class IdentityInsertTest(fixtures.TablesTest, AssertsCompiledSQL): Column("description", String(50)), PrimaryKeyConstraint("id", name="PK_cattable"), ) + Table( + "numeric_identity", + metadata, + Column("id", Numeric(18, 0), autoincrement=True), + Column("description", String(50)), + PrimaryKeyConstraint("id", name="PK_numeric_identity"), + ) def test_compiled(self): cattable = self.tables.cattable @@ -61,6 +71,13 @@ class IdentityInsertTest(fixtures.TablesTest, AssertsCompiledSQL): lastcat = conn.execute(cattable.select().order_by(desc(cattable.c.id))) eq_((10, "PHP"), lastcat.first()) + numeric_identity = self.tables.numeric_identity + # for some reason, T-SQL does not like .values(), but this works + result = conn.execute( + numeric_identity.insert(), dict(description="T-SQL") + ) + eq_(result.inserted_primary_key, (decimal.Decimal("1"),)) + def test_executemany(self, connection): conn = connection cattable = self.tables.cattable -- cgit v1.2.1