]> 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:27:12 +0000 (21:27 -0400)
commit3916bfc9ccf2904f69498075849a82ceee225b3a
treeab835bf174a4047de0d2b62f6a3ac2731c321434
parent805a1323b973a30af99ce506dd5c5c4ab96cff0f
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
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