--- /dev/null
+.. change::
+ :tags: bug, schema, mssql
+ :tickets: 8111
+
+ 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.
+
def _autoincrement_column(self):
def _validate_autoinc(col, autoinc_true):
if col.type._type_affinity is None or not issubclass(
- col.type._type_affinity, type_api.INTEGERTYPE._type_affinity
+ col.type._type_affinity,
+ (
+ type_api.INTEGERTYPE._type_affinity,
+ type_api.NUMERICTYPE._type_affinity,
+ ),
):
if autoinc_true:
raise exc.ArgumentError(
BOOLEANTYPE = Boolean()
STRINGTYPE = String()
INTEGERTYPE = Integer()
+NUMERICTYPE = Numeric()
MATCHTYPE = MatchType()
TABLEVALUE = TableValueType()
DATETIME_TIMEZONE = DateTime(timezone=True)
type_api.STRINGTYPE = STRINGTYPE
type_api.INTEGERTYPE = INTEGERTYPE
type_api.NULLTYPE = NULLTYPE
+type_api.NUMERICTYPE = NUMERICTYPE
type_api.MATCHTYPE = MATCHTYPE
type_api.INDEXABLE = Indexable
type_api.TABLEVALUE = TABLEVALUE
# -*- encoding: utf-8
+import decimal
+
from sqlalchemy import and_
from sqlalchemy import Column
from sqlalchemy import DDL
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
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
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