]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
``Identity`` implies ``nullable=False``.
authorFederico Caselli <cfederico87@gmail.com>
Thu, 7 Jan 2021 20:22:52 +0000 (21:22 +0100)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 16 Jan 2021 23:39:11 +0000 (18:39 -0500)
commit3ebc3710a72c9bb724e7074ef0409ae69cfc39fe
tree77f81978aa29869e516615998cb35ef1ce6dd115
parent6137d223be8e596fb2d7c78623ab22162db8ea6e
``Identity`` implies ``nullable=False``.

Altered the behavior of the :class:`_schema.Identity` construct such that
when applied to a :class:`_schema.Column`, it will automatically imply that
the value of :paramref:`_sql.Column.nullable` should default to ``False``,
in a similar manner as when the :paramref:`_sql.Column.primary_key`
parameter is set to ``True``.   This matches the default behavior of all
supporting databases where ``IDENTITY`` implies ``NOT NULL``.  The
PostgreSQL backend is the only one that supports adding ``NULL`` to an
``IDENTITY`` column, which is here supported by passing a ``True`` value
for the :paramref:`_sql.Column.nullable` parameter at the same time.

Fixes: #5775
Change-Id: I0516d506ff327cff35cda605e8897a27440e0373
doc/build/changelog/unreleased_14/5775.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/schema.py
test/dialect/postgresql/test_compiler.py
test/sql/test_identity_column.py
test/sql/test_metadata.py