]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Skip PK returned as None for RETURNING, server side default
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 21 Jan 2022 15:19:02 +0000 (10:19 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 22 Jan 2022 04:33:46 +0000 (23:33 -0500)
commitc98c0ec73cd22f43fabc6294a4de6c6b476708a2
tree0f744d48ae9174ca4b6e4307ee95e616ab2fbd89
parent328041d21d9f96db12caac79bbf7251a0dbd01e1
Skip PK returned as None for RETURNING, server side default

Fixed regression where the ORM exception that is to be raised when an
INSERT silently fails to actually insert a row (such as from a trigger)
would not be reached, due to a runtime exception raised ahead of time due
to the missing primary key value, thus raising an uninformative exception
rather than the correct one. For 1.4 and above, a new ``FlushError`` is
added for this case that's raised earlier than the previous "null identity"
exception was for 1.3, as a situation where the number of rows actually
INSERTed does not match what was expected is a more critical situation in
1.4 as it prevents batching of multiple objects from working correctly.
This is separate from the case where a newly fetched primary key is
fetched as NULL, which continues to raise the existing "null identity"
exception.

Fixes: #7594
Change-Id: Ie8e181e3472f09f389cca757c5e58e61b15c7d79
(cherry picked from commit 8a1931601d3b105ad585ef39840c8251ebdb44a2)
doc/build/changelog/unreleased_14/7594.rst [new file with mode: 0644]
lib/sqlalchemy/orm/persistence.py
test/orm/test_unitofwork.py