PrimaryKeyConstraint is present on Table however
on table() and others it's a ColumnSet. The warning
here only needs len() and PrimaryKeyConstraint supports that
directly in the same way as ColumnSet.
Change-Id: I19c11a39110bfef48cdea49a471e7ab80b537538
Fixes: #3842
.. changelog::
:version: 1.1.4
+ .. change:: 3842
+ :tags: bug, sql
+ :tickets: 3842
+
+ Fixed bug where newly added warning for primary key on insert w/o
+ autoincrement setting (see :ref:`change_3216`) would fail to emit
+ correctly when invoked upon a lower-case :func:`.table` construct.
+
.. change:: default_schema
:tags: bug, engine
"Primary key columns typically may not store NULL."
%
(c.table.fullname, c.name, c.table.fullname))
- if len(c.table.primary_key.columns) > 1:
+ if len(c.table.primary_key) > 1:
msg += (
" Note that as of SQLAlchemy 1.1, 'autoincrement=True' must be "
"indicated explicitly for composite (e.g. multicolumn) primary "
dialect=d
)
+ def test_anticipate_no_pk_lower_case_table(self):
+ t = table(
+ 't',
+ Column(
+ 'id', Integer, primary_key=True, autoincrement=False),
+ Column('notpk', String(10), nullable=True)
+ )
+ with expect_warnings(
+ "Column 't.id' is marked as a member.*"
+ "may not store NULL.$"
+ ):
+ self.assert_compile(
+ t.insert(),
+ "INSERT INTO t () VALUES ()",
+ params={}
+ )
+
class InsertImplicitReturningTest(
_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):