summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_11.rst8
-rw-r--r--lib/sqlalchemy/sql/crud.py2
-rw-r--r--test/sql/test_insert.py17
3 files changed, 26 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst
index 7c2e0a8fa..1a30e2a4a 100644
--- a/doc/build/changelog/changelog_11.rst
+++ b/doc/build/changelog/changelog_11.rst
@@ -21,6 +21,14 @@
.. 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
diff --git a/lib/sqlalchemy/sql/crud.py b/lib/sqlalchemy/sql/crud.py
index 452fe5d9a..9d10fbefc 100644
--- a/lib/sqlalchemy/sql/crud.py
+++ b/lib/sqlalchemy/sql/crud.py
@@ -681,7 +681,7 @@ def _warn_pk_with_no_anticipated_value(c):
"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 "
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index 79de40e9c..2fa1860de 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -598,6 +598,23 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
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):