]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
support "SELECT *" for ORM queries
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Jul 2022 01:24:17 +0000 (21:24 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Jul 2022 01:28:39 +0000 (21:28 -0400)
commit1b18740b99a02df5c200ce59c4f81dcf999fda2b
tree1beec468127d0747283dc9371b86eb1361ef4a77
parentd245a3deac6e5c1efbaf04caec4de8cb3ee44ad5
support "SELECT *" for ORM queries

A :func:`_sql.select` construct that is passed a sole '*' argument for
``SELECT *``, either via string, :func:`_sql.text`, or
:func:`_sql.literal_column`, will be interpreted as a Core-level SQL
statement rather than as an ORM level statement. This is so that the ``*``,
when expanded to match any number of columns, will result in all columns
returned in the result. the ORM- level interpretation of
:func:`_sql.select` needs to know the names and types of all ORM columns up
front which can't be achieved when ``'*'`` is used.

If ``'*`` is used amongst other expressions simultaneously with an ORM
statement, an error is raised as this can't be interpreted correctly by the
ORM.

Fixes: #8235
Change-Id: Ic8e84491e14acdc8570704eadeaeaf6e16b1e870
(cherry picked from commit 3916bfc9ccf2904f69498075849a82ceee225b3a)
doc/build/changelog/unreleased_14/8235.rst [new file with mode: 0644]
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/sql/elements.py
test/orm/test_loading.py