]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Correctly interpret None passed to query.get(); warn for empty PK values
authorlizraeli <leo2002b@yahoo.com>
Mon, 28 Oct 2019 19:33:41 +0000 (15:33 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 28 Oct 2019 20:04:59 +0000 (16:04 -0400)
commita82c7d2992f7d6180f1b6a5c08207ec665950d2d
treed6ec1f37b3e10889c1562297484d220c3c7ed9f7
parentece35130a5a3cd8e910da879d8b21c938ace83de
Correctly interpret None passed to query.get(); warn for empty PK values

A warning is emitted if a primary key value is passed to :meth:`.Query.get`
that consists of None for all primary key column positions.   Previously,
passing a single None outside of a tuple would raise a ``TypeError`` and
passing a composite None (tuple of None values) would silently pass
through.   The fix now coerces the single None into a tuple where it is
handled consistently with the other None conditions.  Thanks to Lev
Izraelit for the help with this.

Fixes #4915
Closes: #4917
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4917
Pull-request-sha: b388343c7cabeecf8c779689b78e638c23f9af40

Change-Id: Ibc6c27ccf50dfd4adbf15b6dbd393115c30d44fb
(cherry picked from commit 997f4b5f2b3b4725de0960824e95fcb1150ff215)
doc/build/changelog/unreleased_13/4915.rst [new file with mode: 0644]
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/orm/query.py
test/orm/test_query.py