From: Inada Naoki Date: Wed, 29 Oct 2025 08:09:14 +0000 (-0400) Subject: remove use of `LABEL_STYLE_TABLENAME_PLUS_COL` outside of Query X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8fdc99e9c8d4262ad6bf2c03e572b1d3da61f76;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git remove use of `LABEL_STYLE_TABLENAME_PLUS_COL` outside of Query Changed the query style for ORM queries emitted by :meth:`.Session.get` as well as many-to-one lazy load queries to use the default labeling style, :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`, which normally does not apply labels to columns in a SELECT statement. Previously, the older style :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL` that labels columns as `_` was used for :meth:`.Session.get` to maintain compatibility with :class:`_orm.Query`. The change allows the string representation of ORM queries to be less verbose in all cases outside of legacy :class:`_orm.Query` use. Pull request courtesy Inada Naoki. Fixes: #12932 Closes: #12926 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12926 Pull-request-sha: 6738a73f635387b8326f546313cdfd12cf9ef5ab Change-Id: I044a54226a4fcade07adc1a3f5f60b4b3e451a1e --- diff --git a/doc/build/changelog/changelog_14.rst b/doc/build/changelog/changelog_14.rst index e2d2f4d6c9..7675e734f6 100644 --- a/doc/build/changelog/changelog_14.rst +++ b/doc/build/changelog/changelog_14.rst @@ -6663,9 +6663,10 @@ This document details individual issue-level changes made throughout :meth:`_sql.GenerativeSelect.apply_labels` with explicit getters and setters :meth:`_sql.GenerativeSelect.get_label_style` and :meth:`_sql.GenerativeSelect.set_label_style` to accommodate the three - supported label styles: :data:`_sql.LABEL_STYLE_DISAMBIGUATE_ONLY`, - :data:`_sql.LABEL_STYLE_TABLENAME_PLUS_COL`, and - :data:`_sql.LABEL_STYLE_NONE`. + supported label styles: + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`, + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL`, and + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_NONE`. In addition, for Core and "future style" ORM queries, ``LABEL_STYLE_DISAMBIGUATE_ONLY`` is now the default label style. This diff --git a/doc/build/changelog/unreleased_21/12932.rst b/doc/build/changelog/unreleased_21/12932.rst new file mode 100644 index 0000000000..48e42c5951 --- /dev/null +++ b/doc/build/changelog/unreleased_21/12932.rst @@ -0,0 +1,14 @@ +.. change:: + :tags: usecase, sql + :tickets: 12932 + + Changed the query style for ORM queries emitted by :meth:`.Session.get` as + well as many-to-one lazy load queries to use the default labeling style, + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`, which normally + does not apply labels to columns in a SELECT statement. Previously, the + older style :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL` + that labels columns as `_` was used for + :meth:`.Session.get` to maintain compatibility with :class:`_orm.Query`. + The change allows the string representation of ORM queries to be less + verbose in all cases outside of legacy :class:`_orm.Query` use. Pull + request courtesy Inada Naoki. diff --git a/doc/build/orm/extensions/asyncio.rst b/doc/build/orm/extensions/asyncio.rst index bd14d6f2d2..31d2248701 100644 --- a/doc/build/orm/extensions/asyncio.rst +++ b/doc/build/orm/extensions/asyncio.rst @@ -298,7 +298,7 @@ configuration: SELECT a.id, a.data, a.create_date FROM a ORDER BY a.id [...] () - SELECT b.a_id AS b_a_id, b.id AS b_id, b.data AS b_data + SELECT b.a_id, b.id, b.data FROM b WHERE b.a_id IN (?, ?, ?) [...] (1, 2, 3) diff --git a/doc/build/orm/queryguide/columns.rst b/doc/build/orm/queryguide/columns.rst index ace6a63f4c..f461d524f8 100644 --- a/doc/build/orm/queryguide/columns.rst +++ b/doc/build/orm/queryguide/columns.rst @@ -87,7 +87,7 @@ order to load the value. Below, accessing ``.cover_photo`` emits a SELECT statement to load its value:: >>> img_data = books[0].cover_photo - {execsql}SELECT book.cover_photo AS book_cover_photo + {execsql}SELECT book.cover_photo FROM book WHERE book.id = ? [...] (1,) @@ -157,7 +157,7 @@ in addition to primary key column:: {execsql}SELECT user_account.id, user_account.name, user_account.fullname FROM user_account [...] () - SELECT book.owner_id AS book_owner_id, book.id AS book_id, book.title AS book_title + SELECT book.owner_id, book.id, book.title FROM book WHERE book.owner_id IN (?, ?) [...] (1, 2) @@ -184,12 +184,12 @@ the SELECT statement emitted for each ``User.books`` collection:: {execsql}SELECT user_account.id, user_account.name, user_account.fullname FROM user_account [...] () - SELECT book.id AS book_id, book.title AS book_title + SELECT book.id, book.title FROM book WHERE ? = book.owner_id [...] (1,) {stop}Spongebob Squarepants ['100 Years of Krabby Patties', 'Sea Catch 22', 'The Sea Grapes of Wrath'] - {execsql}SELECT book.id AS book_id, book.title AS book_title + {execsql}SELECT book.id, book.title FROM book WHERE ? = book.owner_id [...] (2,) @@ -223,7 +223,7 @@ As is the case with :func:`_orm.load_only`, unloaded columns by default will load themselves when accessed using :term:`lazy loading`:: >>> img_data = books[0].cover_photo - {execsql}SELECT book.cover_photo AS book_cover_photo + {execsql}SELECT book.cover_photo FROM book WHERE book.id = ? [...] (4,) @@ -354,7 +354,7 @@ on the loaded object are first accessed is that they will :term:`lazy load` their value:: >>> img_data = book.cover_photo - {execsql}SELECT book.cover_photo AS book_cover_photo + {execsql}SELECT book.cover_photo FROM book WHERE book.id = ? [...] (2,) @@ -510,7 +510,7 @@ will load both columns at once using just one SELECT statement:: WHERE book.id = ? [...] (2,) {stop}>>> img_data, summary = book.cover_photo, book.summary - {execsql}SELECT book.summary AS book_summary, book.cover_photo AS book_cover_photo + {execsql}SELECT book.summary, book.cover_photo FROM book WHERE book.id = ? [...] (2,) diff --git a/doc/build/orm/queryguide/inheritance.rst b/doc/build/orm/queryguide/inheritance.rst index 537d51ae59..063bdbfd3b 100644 --- a/doc/build/orm/queryguide/inheritance.rst +++ b/doc/build/orm/queryguide/inheritance.rst @@ -211,8 +211,7 @@ we only indicate the additional target subclasses we wish to load:: SELECT company.id, company.name FROM company [...] () - SELECT employee.company_id AS employee_company_id, employee.id AS employee_id, - employee.name AS employee_name, employee.type AS employee_type + SELECT employee.company_id, employee.id, employee.name, employee.type FROM employee WHERE employee.company_id IN (?) [...] (1,) @@ -273,7 +272,7 @@ this collection on all ``Manager`` objects, where the sub-attributes of FROM employee JOIN manager ON employee.id = manager.id WHERE employee.id IN (?) ORDER BY employee.id [...] (1,) - SELECT paperwork.manager_id AS paperwork_manager_id, paperwork.id AS paperwork_id, paperwork.document_name AS paperwork_document_name + SELECT paperwork.manager_id, paperwork.id, paperwork.document_name FROM paperwork WHERE paperwork.manager_id IN (?) [...] (1,) @@ -327,7 +326,7 @@ examples to load ``Company.employees``, also loading the attributes for the SELECT company.id, company.name FROM company [...] () - SELECT employee.company_id AS employee_company_id, employee.id AS employee_id, employee.name AS employee_name, employee.type AS employee_type + SELECT employee.company_id, employee.id, employee.name, employee.type FROM employee WHERE employee.company_id IN (?) [...] (1,) @@ -335,7 +334,7 @@ examples to load ``Company.employees``, also loading the attributes for the FROM employee JOIN manager ON employee.id = manager.id WHERE employee.id IN (?) ORDER BY employee.id [...] (1,) - SELECT paperwork.manager_id AS paperwork_manager_id, paperwork.id AS paperwork_id, paperwork.document_name AS paperwork_document_name + SELECT paperwork.manager_id, paperwork.id, paperwork.document_name FROM paperwork WHERE paperwork.manager_id IN (?) [...] (1,) @@ -847,10 +846,8 @@ eagerly load all elements of ``Company.employees`` using the {execsql}SELECT company.id, company.name FROM company [...] () - SELECT employee.company_id AS employee_company_id, employee.id AS employee_id, - employee.name AS employee_name, employee.type AS employee_type, manager.id AS manager_id, - manager.manager_name AS manager_manager_name, engineer.id AS engineer_id, - engineer.engineer_info AS engineer_engineer_info + SELECT employee.company_id, employee.id, employee.name, employee.type, + manager.id, manager.manager_name, engineer.id, engineer.engineer_info FROM employee LEFT OUTER JOIN manager ON employee.id = manager.id LEFT OUTER JOIN engineer ON employee.id = engineer.id @@ -954,7 +951,7 @@ when it's accessed:: WHERE employee.name = ? [...] ('Mr. Krabs',) {stop}>>> mr_krabs.manager_name - {execsql}SELECT employee.manager_name AS employee_manager_name + {execsql}SELECT employee.manager_name FROM employee WHERE employee.id = ? AND employee.type IN (?) [...] (1, 'manager') diff --git a/doc/build/orm/quickstart.rst b/doc/build/orm/quickstart.rst index e8d4a26233..0b9bc2a78a 100644 --- a/doc/build/orm/quickstart.rst +++ b/doc/build/orm/quickstart.rst @@ -341,7 +341,7 @@ address associated with "sandy", and also add a new email address to {stop} >>> patrick.addresses.append(Address(email_address="patrickstar@sqlalchemy.org")) - {execsql}SELECT address.id AS address_id, address.email_address AS address_email_address, address.user_id AS address_user_id + {execsql}SELECT address.id, address.email_address, address.user_id FROM address WHERE ? = address.user_id [...] (3,){stop} @@ -380,13 +380,13 @@ object by primary key using :meth:`_orm.Session.get`, then work with the object: >>> sandy = session.get(User, 2) {execsql}BEGIN (implicit) - SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, user_account.fullname AS user_account_fullname + SELECT user_account.id, user_account.name, user_account.fullname FROM user_account WHERE user_account.id = ? [...] (2,){stop} >>> sandy.addresses.remove(sandy_address) - {execsql}SELECT address.id AS address_id, address.email_address AS address_email_address, address.user_id AS address_user_id + {execsql}SELECT address.id, address.email_address, address.user_id FROM address WHERE ? = address.user_id [...] (2,) @@ -416,11 +416,11 @@ options that we configured, in this case, onto the related ``Address`` objects: .. sourcecode:: pycon+sql >>> session.delete(patrick) - {execsql}SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, user_account.fullname AS user_account_fullname + {execsql}SELECT user_account.id, user_account.name, user_account.fullname FROM user_account WHERE user_account.id = ? [...] (3,) - SELECT address.id AS address_id, address.email_address AS address_email_address, address.user_id AS address_user_id + SELECT address.id, address.email_address, address.user_id FROM address WHERE ? = address.user_id [...] (3,) diff --git a/doc/build/tutorial/orm_data_manipulation.rst b/doc/build/tutorial/orm_data_manipulation.rst index 9329d20524..f576b31071 100644 --- a/doc/build/tutorial/orm_data_manipulation.rst +++ b/doc/build/tutorial/orm_data_manipulation.rst @@ -337,8 +337,7 @@ Let's load up ``patrick`` from the database: .. sourcecode:: pycon+sql >>> patrick = session.get(User, 3) - {execsql}SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, - user_account.fullname AS user_account_fullname + {execsql}SELECT user_account.id, user_account.name, user_account.fullname FROM user_account WHERE user_account.id = ? [...] (3,) @@ -354,8 +353,7 @@ until the flush proceeds, which as mentioned before occurs if we emit a query: .. sourcecode:: pycon+sql >>> session.execute(select(User).where(User.name == "patrick")).first() - {execsql}SELECT address.id AS address_id, address.email_address AS address_email_address, - address.user_id AS address_user_id + {execsql}SELECT address.id, address.email_address, address.user_id FROM address WHERE ? = address.user_id [...] (3,) @@ -465,8 +463,7 @@ a new transaction and refresh ``sandy`` with the current database row: >>> sandy.fullname {execsql}BEGIN (implicit) - SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, - user_account.fullname AS user_account_fullname + SELECT user_account.id, user_account.name, user_account.fullname FROM user_account WHERE user_account.id = ? [...] (2,){stop} @@ -548,7 +545,7 @@ a context manager as well, accomplishes the following things: >>> session.add(squidward) >>> squidward.name {execsql}BEGIN (implicit) - SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, user_account.fullname AS user_account_fullname + SELECT user_account.id, user_account.name, user_account.fullname FROM user_account WHERE user_account.id = ? [...] (4,){stop} diff --git a/doc/build/tutorial/orm_related_objects.rst b/doc/build/tutorial/orm_related_objects.rst index 48e049dd9e..e0dcbac871 100644 --- a/doc/build/tutorial/orm_related_objects.rst +++ b/doc/build/tutorial/orm_related_objects.rst @@ -227,8 +227,7 @@ newly generated primary key for the ``u1`` object: >>> u1.id {execsql}BEGIN (implicit) - SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, - user_account.fullname AS user_account_fullname + SELECT user_account.id, user_account.name, user_account.fullname FROM user_account WHERE user_account.id = ? [...] (6,){stop} @@ -242,8 +241,7 @@ we again see a :term:`lazy load` emitted in order to retrieve the objects: .. sourcecode:: pycon+sql >>> u1.addresses - {execsql}SELECT address.id AS address_id, address.email_address AS address_email_address, - address.user_id AS address_user_id + {execsql}SELECT address.id, address.email_address, address.user_id FROM address WHERE ? = address.user_id [...] (6,){stop} @@ -456,8 +454,7 @@ related ``Address`` objects: {execsql}SELECT user_account.id, user_account.name, user_account.fullname FROM user_account ORDER BY user_account.id [...] () - SELECT address.user_id AS address_user_id, address.id AS address_id, - address.email_address AS address_email_address + SELECT address.user_id, address.id, address.email_address FROM address WHERE address.user_id IN (?, ?, ?, ?, ?, ?) [...] (1, 2, 3, 4, 5, 6){stop} @@ -669,7 +666,7 @@ instead:: {execsql}SELECT user_account.id FROM user_account [...] () - SELECT address.user_id AS address_user_id, address.id AS address_id + SELECT address.user_id, address.id FROM address WHERE address.user_id IN (?, ?, ?, ?, ?, ?) [...] (1, 2, 3, 4, 5, 6) diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index f1d90f8d87..9f78711e57 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -51,7 +51,6 @@ from ..engine.result import SimpleResultMetaData from ..sql import select from ..sql import util as sql_util from ..sql.selectable import ForUpdateArg -from ..sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL from ..sql.selectable import SelectState from ..util import EMPTY_DICT from ..util.typing import TupleAny @@ -1671,7 +1670,7 @@ def _load_scalar_attributes(mapper, state, attribute_names, passive): result = _load_on_ident( session, - select(mapper).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL), + select(mapper), identity_key, refresh_state=state, only_load_props=attribute_names, diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index f720f90951..8777cb5bce 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -28,13 +28,11 @@ from . import loading from . import sync from .base import state_str from .. import exc as sa_exc -from .. import future from .. import sql from .. import util from ..engine import cursor as _cursor from ..sql import operators from ..sql.elements import BooleanClauseList -from ..sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL def _save_obj(base_mapper, states, uowtransaction, single=False): @@ -1559,9 +1557,7 @@ def _finalize_insert_update_commands(base_mapper, uowtransaction, states): if toload_now: state.key = base_mapper._identity_key_from_state(state) - stmt = future.select(mapper).set_label_style( - LABEL_STYLE_TABLENAME_PLUS_COL - ) + stmt = sql.select(mapper) loading._load_on_ident( uowtransaction.session, stmt, diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 100ef84fde..56b690aa4b 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -89,7 +89,6 @@ from ..sql.base import _NoArg from ..sql.base import CompileState from ..sql.schema import Table from ..sql.selectable import ForUpdateArg -from ..sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL from ..util import deprecated_params from ..util import IdentitySet from ..util.typing import TupleAny @@ -3903,17 +3902,11 @@ class Session(_SessionClassMethods, EventTarget): # TODO: this was being tested before, but this is not possible assert instance is not LoaderCallableStatus.PASSIVE_CLASS_MISMATCH - # set_label_style() not strictly necessary, however this will ensure - # that tablename_colname style is used which at the moment is - # asserted in a lot of unit tests :) - load_options = context.QueryContext.default_load_options if populate_existing: load_options += {"_populate_existing": populate_existing} - statement = sql.select(mapper).set_label_style( - LABEL_STYLE_TABLENAME_PLUS_COL - ) + statement = sql.select(mapper) if with_for_update is not None: statement._for_update_arg = ForUpdateArg._from_argument( with_for_update diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index cd0d97598f..6a71316646 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -1028,7 +1028,6 @@ class _LazyLoader( stmt = Select._create_raw_select( _raw_columns=[clauseelement], _propagate_attrs=clauseelement._propagate_attrs, - _label_style=LABEL_STYLE_TABLENAME_PLUS_COL, _compile_options=_ORMCompileState.default_compile_options, ) load_options = QueryContext.default_load_options @@ -3212,7 +3211,6 @@ class _SelectInLoader(_PostLoader, util.MemoizedSlots): entity_sql = effective_entity.__clause_element__() q = Select._create_raw_select( _raw_columns=[bundle_sql, entity_sql], - _label_style=LABEL_STYLE_TABLENAME_PLUS_COL, _compile_options=_ORMCompileState.default_compile_options, _propagate_attrs={ "compile_state_plugin": "orm", diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 6e62d30bc4..5fe7995057 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -4144,13 +4144,13 @@ class GenerativeSelect(DialectKWArgs, SelectBase, Generative): .. seealso:: - :data:`_sql.LABEL_STYLE_DISAMBIGUATE_ONLY` + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY` - :data:`_sql.LABEL_STYLE_TABLENAME_PLUS_COL` + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL` - :data:`_sql.LABEL_STYLE_NONE` + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_NONE` - :data:`_sql.LABEL_STYLE_DEFAULT` + :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DEFAULT` """ if self._label_style is not style: diff --git a/test/orm/dml/test_update_delete_where.py b/test/orm/dml/test_update_delete_where.py index 05e02a6597..3463fae907 100644 --- a/test/orm/dml/test_update_delete_where.py +++ b/test/orm/dml/test_update_delete_where.py @@ -567,15 +567,15 @@ class UpdateDeleteTest(fixtures.MappedTest): to_assert = [ # refresh john CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name, " - "users.age_int AS users_age_int FROM users " + "SELECT users.id, users.name, users.age_int " + "FROM users " "WHERE users.id = :pk_1", [{"pk_1": 1}], ), # refresh jill CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name, " - "users.age_int AS users_age_int FROM users " + "SELECT users.id, users.name, users.age_int " + "FROM users " "WHERE users.id = :pk_1", [{"pk_1": 3}], ), @@ -585,8 +585,8 @@ class UpdateDeleteTest(fixtures.MappedTest): to_assert.append( # refresh jane for partial attributes CompiledSQL( - "SELECT users.name AS users_name, " - "users.age_int AS users_age_int FROM users " + "SELECT users.name, users.age_int " + "FROM users " "WHERE users.id = :pk_1", [{"pk_1": 4}], ) @@ -711,15 +711,15 @@ class UpdateDeleteTest(fixtures.MappedTest): asserter.assert_( # refresh john CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name, " - "users.age_int AS users_age_int FROM users " + "SELECT users.id, users.name, users.age_int " + "FROM users " "WHERE users.id = :pk_1", [{"pk_1": 1}], ), # refresh jill CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name, " - "users.age_int AS users_age_int FROM users " + "SELECT users.id, users.name, users.age_int " + "FROM users " "WHERE users.id = :pk_1", [{"pk_1": 3}], ), diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index 9028fd25a4..f84807fa92 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -1706,8 +1706,7 @@ class PassiveDeletesTest(fixtures.MappedTest): s.flush() asserter.assert_( CompiledSQL( - "SELECT a.id AS a_id, a.type AS a_type " - "FROM a WHERE a.id = :pk_1", + "SELECT a.id, a.type FROM a WHERE a.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]), @@ -1748,8 +1747,7 @@ class PassiveDeletesTest(fixtures.MappedTest): s.flush() asserter.assert_( CompiledSQL( - "SELECT a.id AS a_id, a.type AS a_type " - "FROM a WHERE a.id = :pk_1", + "SELECT a.id, a.type FROM a WHERE a.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]), @@ -1786,8 +1784,7 @@ class PassiveDeletesTest(fixtures.MappedTest): s.flush() asserter.assert_( CompiledSQL( - "SELECT a.id AS a_id, a.type AS a_type " - "FROM a WHERE a.id = :pk_1", + "SELECT a.id, a.type FROM a WHERE a.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]), @@ -2875,11 +2872,9 @@ class OptimizedLoadTest(fixtures.MappedTest): testing.db, go, CompiledSQL( - "SELECT base.id AS base_id, sub.id AS sub_id, " - "base.data AS base_data, base.type AS base_type, " - "base.counter AS base_counter, " - "sub.subcounter AS sub_subcounter, " - "sub.sub AS sub_sub, sub.subcounter2 AS sub_subcounter2 " + "SELECT base.id, sub.id AS id_1, " + "base.data, base.type, base.counter, " + "sub.subcounter, sub.sub, sub.subcounter2 " "FROM base LEFT OUTER JOIN sub ON base.id = sub.id " "WHERE base.id = :pk_1", {"pk_1": sjb_id}, @@ -3222,9 +3217,9 @@ class OptimizedLoadTest(fixtures.MappedTest): bool(eager_defaults), [ CompiledSQL( - "SELECT base.counter AS base_counter, " - "sub.subcounter AS sub_subcounter, " - "sub.subcounter2 AS sub_subcounter2 " + "SELECT base.counter, " + "sub.subcounter, " + "sub.subcounter2 " "FROM base JOIN sub ON base.id = sub.id " "WHERE base.id = :pk_1", lambda ctx: {"pk_1": s1.id}, @@ -3246,9 +3241,8 @@ class OptimizedLoadTest(fixtures.MappedTest): not eager_defaults and not expect_returning, [ CompiledSQL( - "SELECT base.counter AS base_counter, " - "sub.subcounter AS sub_subcounter, sub.subcounter2 " - "AS sub_subcounter2 FROM base " + "SELECT base.counter, sub.subcounter, sub.subcounter2 " + "FROM base " "JOIN sub ON base.id = sub.id WHERE base.id = :pk_1", lambda ctx: {"pk_1": s1.id}, ) diff --git a/test/orm/inheritance/test_poly_loading.py b/test/orm/inheritance/test_poly_loading.py index cf7d314665..9bdb695e17 100644 --- a/test/orm/inheritance/test_poly_loading.py +++ b/test/orm/inheritance/test_poly_loading.py @@ -137,15 +137,14 @@ class BaseAndSubFixture: # cols a.id / asub.id are listed in the mapper's # equivalent_columns so they are guaranteed to store # the same value. - "SELECT c.a_sub_id AS c_a_sub_id, " - "c.id AS c_id " + "SELECT c.a_sub_id, c.id " "FROM c WHERE c.a_sub_id " "IN (__[POSTCOMPILE_primary_keys])", {"primary_keys": [2]}, ), ), CompiledSQL( - "SELECT b.a_id AS b_a_id, b.id AS b_id FROM b " + "SELECT b.a_id, b.id FROM b " "WHERE b.a_id IN (__[POSTCOMPILE_primary_keys])", {"primary_keys": [1, 2]}, ), @@ -340,9 +339,9 @@ class FixtureLoadTest(_Polymorphic, testing.AssertsExecutionResults): {}, ), CompiledSQL( - "SELECT people.company_id AS people_company_id, " - "people.person_id AS people_person_id, " - "people.name AS people_name, people.type AS people_type " + "SELECT people.company_id, " + "people.person_id, " + "people.name, people.type " "FROM people WHERE people.company_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY people.person_id", @@ -404,9 +403,9 @@ class FixtureLoadTest(_Polymorphic, testing.AssertsExecutionResults): {}, ), CompiledSQL( - "SELECT people.company_id AS people_company_id, " - "people.person_id AS people_person_id, " - "people.name AS people_name, people.type AS people_type " + "SELECT people.company_id, " + "people.person_id, " + "people.name, people.type " "FROM people WHERE people.company_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY people.person_id", @@ -439,9 +438,9 @@ class FixtureLoadTest(_Polymorphic, testing.AssertsExecutionResults): {"primary_keys": [1, 2, 5]}, ), CompiledSQL( - "SELECT machines.engineer_id AS machines_engineer_id, " - "machines.machine_id AS machines_machine_id, " - "machines.name AS machines_name " + "SELECT machines.engineer_id, " + "machines.machine_id, " + "machines.name " "FROM machines " "WHERE machines.engineer_id " "IN (__[POSTCOMPILE_primary_keys]) " @@ -1322,8 +1321,8 @@ class IgnoreOptionsOnSubclassAttrLoad(fixtures.DeclarativeMappedTest): if will_lazyload: expected.append( CompiledSQL( - "SELECT entity.id AS entity_id, " - "entity.type AS entity_type FROM entity " + "SELECT entity.id, " + "entity.type FROM entity " "WHERE entity.id = :pk_1", [{"pk_1": entity_id}], ) diff --git a/test/orm/inheritance/test_relationship.py b/test/orm/inheritance/test_relationship.py index 49f8c90620..82ec9ebeea 100644 --- a/test/orm/inheritance/test_relationship.py +++ b/test/orm/inheritance/test_relationship.py @@ -3198,9 +3198,9 @@ class SingleSubclassInRelationship( asserter.assert_( CompiledSQL( - "SELECT log_entry_1.id AS log_entry_1_id, " - "log_entry_1.timestamp AS log_entry_1_timestamp, " - "log_entry_1.type AS log_entry_1_type " + "SELECT log_entry_1.id, " + "log_entry_1.timestamp, " + "log_entry_1.type " "FROM log_entry AS log_entry_1 " "WHERE log_entry_1.timestamp >= :param_1 AND " "((SELECT min(log_entry_2.timestamp) AS min_1 " diff --git a/test/orm/inheritance/test_single.py b/test/orm/inheritance/test_single.py index 0f15ac4a51..a26aed1cf1 100644 --- a/test/orm/inheritance/test_single.py +++ b/test/orm/inheritance/test_single.py @@ -2610,11 +2610,10 @@ class AbstractPolymorphicTest( ], ), CompiledSQL( - "SELECT employee.company_id AS employee_company_id, " - "employee.id AS employee_id, employee.name AS employee_name, " - "employee.type AS employee_type, " - "employee.executive_background AS " - "employee_executive_background " + "SELECT employee.company_id, " + "employee.id, employee.name, " + "employee.type, " + "employee.executive_background " "FROM employee WHERE employee.company_id " "IN (__[POSTCOMPILE_primary_keys]) " "AND employee.type IN (__[POSTCOMPILE_type_1])", diff --git a/test/orm/test_ac_relationships.py b/test/orm/test_ac_relationships.py index 34f4e37ee4..c4ff8d7de3 100644 --- a/test/orm/test_ac_relationships.py +++ b/test/orm/test_ac_relationships.py @@ -272,7 +272,7 @@ class AltSelectableTest( asserter.assert_( CompiledSQL( - "SELECT b.id AS b_id FROM b JOIN d ON d.b_id = b.id " + "SELECT b.id FROM b JOIN d ON d.b_id = b.id " "JOIN c ON c.id = d.c_id WHERE :param_1 = b.id", [{"param_1": 1}], ) @@ -318,7 +318,7 @@ class AltSelectableTest( [{"param_1": 1}], ), CompiledSQL( - "SELECT a_1.id AS a_1_id, b.id AS b_id FROM a AS a_1 " + "SELECT a_1.id, b.id FROM a AS a_1 " "JOIN (b JOIN d ON d.b_id = b.id JOIN c ON c.id = d.c_id) " "ON a_1.b_id = b.id WHERE a_1.id " "IN (__[POSTCOMPILE_primary_keys])", diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py index a7c326f730..c91fc8e993 100644 --- a/test/orm/test_cascade.py +++ b/test/orm/test_cascade.py @@ -1094,8 +1094,7 @@ class M2OwNoUseGetCascadeTest( sess.flush, # looking for other bs' CompiledSQL( - "SELECT b.id AS b_id, b.email AS b_email " - "FROM b WHERE :param_1 = b.email", + "SELECT b.id, b.email " "FROM b WHERE :param_1 = b.email", lambda ctx: [{"param_1": "x"}], ), CompiledSQL( @@ -1127,8 +1126,7 @@ class M2OwNoUseGetCascadeTest( # we would like it to be able to skip this SELECT but this is not # implemented right now CompiledSQL( - "SELECT a.id AS a_id, a.email AS a_email FROM a " - "WHERE a.email = :param_1", + "SELECT a.id, a.email FROM a " "WHERE a.email = :param_1", [{"param_1": "x"}], ), CompiledSQL( diff --git a/test/orm/test_defaults.py b/test/orm/test_defaults.py index d230d4aafc..0b0ad90943 100644 --- a/test/orm/test_defaults.py +++ b/test/orm/test_defaults.py @@ -319,13 +319,11 @@ class ComputedDefaultsOnUpdateTest(fixtures.MappedTest): [{"foo": 5, "id": 1}, {"foo": 10, "id": 2}], ), CompiledSQL( - "SELECT test.bar AS test_bar FROM test " - "WHERE test.id = :pk_1", + "SELECT test.bar FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test.bar AS test_bar FROM test " - "WHERE test.id = :pk_1", + "SELECT test.bar FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], ), ], @@ -390,14 +388,12 @@ class ComputedDefaultsOnUpdateTest(fixtures.MappedTest): enable_returning=False, ), CompiledSQL( - "SELECT test.bar AS test_bar FROM test " - "WHERE test.id = :pk_1", + "SELECT test.bar FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], enable_returning=False, ), CompiledSQL( - "SELECT test.bar AS test_bar FROM test " - "WHERE test.id = :pk_1", + "SELECT test.bar FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], enable_returning=False, ), @@ -409,13 +405,11 @@ class ComputedDefaultsOnUpdateTest(fixtures.MappedTest): [{"foo": 5, "test_id": 1}, {"foo": 6, "test_id": 2}], ), CompiledSQL( - "SELECT test.bar AS test_bar FROM test " - "WHERE test.id = :pk_1", + "SELECT test.bar FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test.bar AS test_bar FROM test " - "WHERE test.id = :pk_1", + "SELECT test.bar FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], ), ) diff --git a/test/orm/test_deferred.py b/test/orm/test_deferred.py index dbfe3ef797..95c362d8fa 100644 --- a/test/orm/test_deferred.py +++ b/test/orm/test_deferred.py @@ -90,7 +90,7 @@ class DeferredTest(AssertsCompiledSQL, _fixtures.FixtureTest): {}, ), ( - "SELECT orders.description AS orders_description " + "SELECT orders.description " "FROM orders WHERE orders.id = :pk_1", {"pk_1": 3}, ), @@ -131,7 +131,7 @@ class DeferredTest(AssertsCompiledSQL, _fixtures.FixtureTest): {}, ), ( - "SELECT orders.description AS orders_description " + "SELECT orders.description " "FROM orders WHERE orders.id = :pk_1", {"pk_1": 3}, ), @@ -383,10 +383,10 @@ class DeferredTest(AssertsCompiledSQL, _fixtures.FixtureTest): {}, ), ( - "SELECT orders.user_id AS orders_user_id, " - "orders.address_id AS orders_address_id, " - "orders.description AS orders_description, " - "orders.isopen AS orders_isopen " + "SELECT orders.user_id, " + "orders.address_id, " + "orders.description, " + "orders.isopen " "FROM orders WHERE orders.id = :pk_1", {"pk_1": 3}, ), @@ -516,7 +516,7 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest): {}, ), ( - "SELECT orders.user_id AS orders_user_id " + "SELECT orders.user_id " "FROM orders WHERE orders.id = :pk_1", {"pk_1": 1}, ), @@ -755,7 +755,7 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest): {"id_1": 3}, ), ( - "SELECT users.id AS users_id, users.name AS users_name " + "SELECT users.id, users.name " "FROM users WHERE users.id IN " "(__[POSTCOMPILE_primary_keys])", [{"primary_keys": [7]}], @@ -814,11 +814,11 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest): {"id_1": 7}, ), ( - "SELECT orders.id AS orders_id, " - "orders.user_id AS orders_user_id, " - "orders.address_id AS orders_address_id, " - "orders.description AS orders_description, " - "orders.isopen AS orders_isopen " + "SELECT orders.id, " + "orders.user_id, " + "orders.address_id, " + "orders.description, " + "orders.isopen " "FROM orders WHERE :param_1 = orders.user_id " "ORDER BY orders.id", {"param_1": 7}, @@ -1456,14 +1456,14 @@ class DeferredOptionsTest(AssertsCompiledSQL, _fixtures.FixtureTest): {"id_1": [7, 8]}, ), ( - "SELECT addresses.id AS addresses_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id", {"param_1": 7}, ), ( - "SELECT addresses.id AS addresses_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id", {"param_1": 8}, ), diff --git a/test/orm/test_dynamic.py b/test/orm/test_dynamic.py index 9378f1ef50..9c69c10db2 100644 --- a/test/orm/test_dynamic.py +++ b/test/orm/test_dynamic.py @@ -1127,7 +1127,7 @@ class _UOWTests: testing.db, sess.flush, CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name " + "SELECT users.id, users.name " "FROM users WHERE users.id = :pk_1", lambda ctx: [{"pk_1": u1_id}], ), @@ -1160,8 +1160,8 @@ class _UOWTests: testing.db, sess.flush, CompiledSQL( - "SELECT addresses.id AS addresses_id, addresses.email_address " - "AS addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.email_address " + "FROM addresses " "WHERE addresses.id = :pk_1", lambda ctx: [{"pk_1": a2_id}], ), @@ -1171,7 +1171,7 @@ class _UOWTests: lambda ctx: [{"addresses_id": a2_id, "user_id": None}], ), CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name " + "SELECT users.id, users.name " "FROM users WHERE users.id = :pk_1", lambda ctx: [{"pk_1": u1_id}], ), diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py index 80178582c6..18c443a6b7 100644 --- a/test/orm/test_eager_relations.py +++ b/test/orm/test_eager_relations.py @@ -1665,10 +1665,10 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): testing.db, go, CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses WHERE :param_1 = " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " + "FROM addresses WHERE :param_1 = " "addresses.user_id", {"param_1": 8}, ), @@ -1716,10 +1716,10 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): testing.db, go, CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses WHERE :param_1 = " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " + "FROM addresses WHERE :param_1 = " "addresses.user_id", {"param_1": 8}, ), @@ -3122,11 +3122,11 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): {"id_1": 7}, ), ( - "SELECT orders.id AS orders_id, " - "orders.user_id AS orders_user_id, " - "orders.address_id AS orders_address_id, " - "orders.description AS orders_description, " - "orders.isopen AS orders_isopen FROM orders " + "SELECT orders.id, " + "orders.user_id, " + "orders.address_id, " + "orders.description, " + "orders.isopen FROM orders " "WHERE :param_1 = orders.user_id", {"param_1": 7}, ), @@ -7032,8 +7032,8 @@ class SecondaryOptionsTest(fixtures.MappedTest): testing.db, lambda: c1.child2, CompiledSQL( - "SELECT child2.id AS child2_id, base.id AS base_id, " - "base.type AS base_type " + "SELECT child2.id, base.id, " + "base.type " "FROM base JOIN child2 ON base.id = child2.id " "WHERE base.id = :pk_1", {"pk_1": 4}, @@ -7070,8 +7070,8 @@ class SecondaryOptionsTest(fixtures.MappedTest): testing.db, lambda: c1.child2, CompiledSQL( - "SELECT child2.id AS child2_id, base.id AS base_id, " - "base.type AS base_type " + "SELECT child2.id, base.id, " + "base.type " "FROM base JOIN child2 ON base.id = child2.id " "WHERE base.id = :pk_1", {"pk_1": 4}, @@ -7113,9 +7113,9 @@ class SecondaryOptionsTest(fixtures.MappedTest): testing.db, lambda: c1.child2, CompiledSQL( - "SELECT child2.id AS child2_id, base.id AS base_id, " - "base.type AS base_type, " - "related_1.id AS related_1_id FROM base JOIN child2 " + "SELECT child2.id, base.id, " + "base.type, " + "related_1.id FROM base JOIN child2 " "ON base.id = child2.id " "LEFT OUTER JOIN related AS related_1 " "ON base.id = related_1.id WHERE base.id = :pk_1", diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 642ac6edd4..536aa654f7 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -140,9 +140,8 @@ class ORMExecuteTest(RemoveORMEventsGlobally, _fixtures.FixtureTest): [{"id_1": 7}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, addresses.user_id AS " - "addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "ORDER BY addresses.id", [{"param_1": 7}], diff --git a/test/orm/test_lazy_relations.py b/test/orm/test_lazy_relations.py index 9bb8071984..ff8063cc3a 100644 --- a/test/orm/test_lazy_relations.py +++ b/test/orm/test_lazy_relations.py @@ -1499,8 +1499,8 @@ class O2MWOSideFixedTest(fixtures.MappedTest): testing.db, go, CompiledSQL( - "SELECT person.id AS person_id, person.city_id AS " - "person_city_id FROM person WHERE person.city_id = :param_1 " + "SELECT person.id, person.city_id " + "FROM person WHERE person.city_id = :param_1 " "AND :param_2 = 0", {"param_1": 2, "param_2": 1}, ), @@ -1690,8 +1690,8 @@ class TypeCoerceTest(fixtures.MappedTest, testing.AssertsExecutionResults): asserter.assert_( CompiledSQL( - "SELECT pets.id AS pets_id, pets.person_id AS " - "pets_person_id FROM pets WHERE pets.person_id = " + "SELECT pets.id, pets.person_id " + "FROM pets WHERE pets.person_id = " "CAST(:param_1 AS INTEGER)", [{"param_1": 5}], ) diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py index 9fb16a2ce1..0df14df56d 100644 --- a/test/orm/test_merge.py +++ b/test/orm/test_merge.py @@ -2048,13 +2048,11 @@ class DeferredMergeTest(fixtures.MappedTest): go, [ ( - "SELECT book.summary AS book_summary " - "FROM book WHERE book.id = :pk_1", + "SELECT book.summary FROM book WHERE book.id = :pk_1", {"pk_1": 1}, ), ( - "SELECT book.excerpt AS book_excerpt " - "FROM book WHERE book.id = :pk_1", + "SELECT book.excerpt FROM book WHERE book.id = :pk_1", {"pk_1": 1}, ), ], @@ -2094,13 +2092,11 @@ class DeferredMergeTest(fixtures.MappedTest): go, [ ( - "SELECT book.summary AS book_summary " - "FROM book WHERE book.id = :pk_1", + "SELECT book.summary FROM book WHERE book.id = :pk_1", {"pk_1": 1}, ), ( - "SELECT book.excerpt AS book_excerpt " - "FROM book WHERE book.id = :pk_1", + "SELECT book.excerpt FROM book WHERE book.id = :pk_1", {"pk_1": 1}, ), ], diff --git a/test/orm/test_relationship_criteria.py b/test/orm/test_relationship_criteria.py index 29720f7dc8..90c3243eac 100644 --- a/test/orm/test_relationship_criteria.py +++ b/test/orm/test_relationship_criteria.py @@ -955,9 +955,9 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [], ), CompiledSQL( - "SELECT addresses.user_id AS addresses_user_id, addresses.id " - "AS addresses_id, addresses.email_address " - "AS addresses_email_address FROM addresses " + "SELECT addresses.user_id, addresses.id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.user_id IN (__[POSTCOMPILE_primary_keys]) " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", @@ -991,9 +991,9 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [], ), CompiledSQL( - "SELECT addresses.user_id AS addresses_user_id, addresses.id " - "AS addresses_id, addresses.email_address " - "AS addresses_email_address FROM addresses " + "SELECT addresses.user_id, addresses.id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.user_id IN (__[POSTCOMPILE_primary_keys]) " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", @@ -1011,9 +1011,9 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [], ), CompiledSQL( - "SELECT addresses.user_id AS addresses_user_id, addresses.id " - "AS addresses_id, addresses.email_address " - "AS addresses_email_address FROM addresses " + "SELECT addresses.user_id, addresses.id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.user_id IN (__[POSTCOMPILE_primary_keys]) " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", @@ -1046,36 +1046,36 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", [{"param_1": 7, "email_address_1": "name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", [{"param_1": 8, "email_address_1": "name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", [{"param_1": 9, "email_address_1": "name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", @@ -1114,36 +1114,36 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", [{"param_1": 7, "closure_1": "name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", [{"param_1": 8, "closure_1": "name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", [{"param_1": 9, "closure_1": "name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", @@ -1164,36 +1164,36 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", [{"param_1": 7, "closure_1": "new name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", [{"param_1": 8, "closure_1": "new name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", [{"param_1": 9, "closure_1": "new name"}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :closure_1 " "ORDER BY addresses.id", @@ -1993,9 +1993,9 @@ class RelationshipCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): "SELECT users.id, users.name FROM users ORDER BY users.id" ), CompiledSQL( - "SELECT addresses.user_id AS addresses_user_id, " - "addresses.id AS addresses_id, addresses.email_address " - "AS addresses_email_address FROM addresses " + "SELECT addresses.user_id, addresses.id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.user_id IN " "(__[POSTCOMPILE_primary_keys]) " "AND addresses.email_address != :email_address_1 " @@ -2052,9 +2052,8 @@ class RelationshipCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): "SELECT users.id, users.name FROM users ORDER BY users.id" ), CompiledSQL( - "SELECT addresses.user_id AS addresses_user_id, " - "addresses.id AS addresses_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.user_id, addresses.id, " + "addresses.email_address " # note the comma-separated FROM clause "FROM addresses, (SELECT addresses_1.id AS id FROM " "addresses AS addresses_1 " @@ -2246,13 +2245,13 @@ class RelationshipCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): [{"id_1": 7}], ), CompiledSQL( - "SELECT orders.user_id AS orders_user_id, " - "orders.id AS orders_id, " - "orders.address_id AS orders_address_id, " - "orders.description AS orders_description, " - "orders.isopen AS orders_isopen, " - "items_1.id AS items_1_id, " - "items_1.description AS items_1_description " + "SELECT orders.user_id, " + "orders.id, " + "orders.address_id, " + "orders.description, " + "orders.isopen, " + "items_1.id, " + "items_1.description " "FROM orders LEFT OUTER JOIN " "(order_items AS order_items_1 " "JOIN items AS items_1 " @@ -2309,36 +2308,36 @@ class RelationshipCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): "SELECT users.id, users.name FROM users ORDER BY users.id" ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", [{"param_1": 7, "email_address_1": value}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", [{"param_1": 8, "email_address_1": value}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", [{"param_1": 9, "email_address_1": value}], ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS addresses_user_id, " - "addresses.email_address AS addresses_email_address " + "SELECT addresses.id, " + "addresses.user_id, " + "addresses.email_address " "FROM addresses WHERE :param_1 = addresses.user_id " "AND addresses.email_address != :email_address_1 " "ORDER BY addresses.id", diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py index 3bfb9b06bf..f610860d5d 100644 --- a/test/orm/test_relationships.py +++ b/test/orm/test_relationships.py @@ -4858,7 +4858,7 @@ class SecondaryNestedJoinTest( testing.db, go, CompiledSQL( - "SELECT d.id AS d_id, d.name AS d_name FROM b " + "SELECT d.id, d.name FROM b " "JOIN d ON b.d_id = d.id JOIN c ON c.d_id = d.id " "WHERE :param_1 = b.id AND :param_2 = c.a_id " "AND d.id = b.d_id", @@ -6674,7 +6674,7 @@ class SecondaryIncludesLocalColsTest(fixtures.MappedTest): params=[{"id_1": 2}], ), CompiledSQL( - "SELECT a_1.id AS a_1_id, b.id AS b_id FROM a AS a_1 JOIN " + "SELECT a_1.id, b.id FROM a AS a_1 JOIN " "(SELECT a.id AS aid, b.id AS id FROM a JOIN b ON a.b_ids " "LIKE (:id_1 || b.id || :param_1)) AS anon_1 " "ON a_1.id = anon_1.aid JOIN b ON b.id = anon_1.id " diff --git a/test/orm/test_selectin_relations.py b/test/orm/test_selectin_relations.py index c29da9f87c..9623cf0fae 100644 --- a/test/orm/test_selectin_relations.py +++ b/test/orm/test_selectin_relations.py @@ -1873,9 +1873,9 @@ class BaseRelationFromJoinedSubclassTest(_Polymorphic): {"primary_language_1": "java"}, ), CompiledSQL( - "SELECT paperwork.person_id AS paperwork_person_id, " - "paperwork.paperwork_id AS paperwork_paperwork_id, " - "paperwork.description AS paperwork_description " + "SELECT paperwork.person_id, " + "paperwork.paperwork_id, " + "paperwork.description " "FROM paperwork WHERE paperwork.person_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY paperwork.paperwork_id", @@ -1923,9 +1923,9 @@ class BaseRelationFromJoinedSubclassTest(_Polymorphic): }, ), CompiledSQL( - "SELECT paperwork.person_id AS paperwork_person_id, " - "paperwork.paperwork_id AS paperwork_paperwork_id, " - "paperwork.description AS paperwork_description " + "SELECT paperwork.person_id, " + "paperwork.paperwork_id, " + "paperwork.description " "FROM paperwork WHERE paperwork.person_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY paperwork.paperwork_id", @@ -1969,9 +1969,9 @@ class BaseRelationFromJoinedSubclassTest(_Polymorphic): "DESC LIMIT :param_1" ), CompiledSQL( - "SELECT paperwork.person_id AS paperwork_person_id, " - "paperwork.paperwork_id AS paperwork_paperwork_id, " - "paperwork.description AS paperwork_description " + "SELECT paperwork.person_id, " + "paperwork.paperwork_id, " + "paperwork.description " "FROM paperwork WHERE paperwork.person_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY paperwork.paperwork_id", @@ -2023,9 +2023,9 @@ class BaseRelationFromJoinedSubclassTest(_Polymorphic): "LIMIT :param_1" ), CompiledSQL( - "SELECT paperwork.person_id AS paperwork_person_id, " - "paperwork.paperwork_id AS paperwork_paperwork_id, " - "paperwork.description AS paperwork_description " + "SELECT paperwork.person_id, " + "paperwork.paperwork_id, " + "paperwork.description " "FROM paperwork WHERE paperwork.person_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY paperwork.paperwork_id", @@ -2071,9 +2071,9 @@ class BaseRelationFromJoinedSubclassTest(_Polymorphic): "ORDER BY engineers_1.primary_language DESC LIMIT :param_1" ), CompiledSQL( - "SELECT paperwork.person_id AS paperwork_person_id, " - "paperwork.paperwork_id AS paperwork_paperwork_id, " - "paperwork.description AS paperwork_description " + "SELECT paperwork.person_id, " + "paperwork.paperwork_id, " + "paperwork.description " "FROM paperwork WHERE paperwork.person_id " "IN (__[POSTCOMPILE_primary_keys]) " "ORDER BY paperwork.paperwork_id", @@ -2293,7 +2293,7 @@ class TupleTest(fixtures.DeclarativeMappedTest): {}, ), CompiledSQL( - "SELECT b.a_id1 AS b_a_id1, b.a_id2 AS b_a_id2, b.id AS b_id " + "SELECT b.a_id1, b.a_id2, b.id " "FROM b WHERE (b.a_id1, b.a_id2) IN " "(__[POSTCOMPILE_primary_keys]) ORDER BY b.id", [{"primary_keys": [(i, i + 2) for i in range(1, 20)]}], @@ -2325,7 +2325,7 @@ class TupleTest(fixtures.DeclarativeMappedTest): {}, ), CompiledSQL( - "SELECT a.id1 AS a_id1, a.id2 AS a_id2 FROM a " + "SELECT a.id1, a.id2 FROM a " "WHERE (a.id1, a.id2) IN (__[POSTCOMPILE_primary_keys])", [{"primary_keys": [(i, i + 2) for i in range(1, 20)]}], ), @@ -2398,19 +2398,19 @@ class ChunkingTest(fixtures.DeclarativeMappedTest): go, CompiledSQL("SELECT a.id AS a_id FROM a ORDER BY a.id", {}), CompiledSQL( - "SELECT b.a_id AS b_a_id, b.id AS b_id " + "SELECT b.a_id, b.id " "FROM b WHERE b.a_id IN " "(__[POSTCOMPILE_primary_keys]) ORDER BY b.id", {"primary_keys": list(range(1, 48))}, ), CompiledSQL( - "SELECT b.a_id AS b_a_id, b.id AS b_id " + "SELECT b.a_id, b.id " "FROM b WHERE b.a_id IN " "(__[POSTCOMPILE_primary_keys]) ORDER BY b.id", {"primary_keys": list(range(48, 95))}, ), CompiledSQL( - "SELECT b.a_id AS b_a_id, b.id AS b_id " + "SELECT b.a_id, b.id " "FROM b WHERE b.a_id IN " "(__[POSTCOMPILE_primary_keys]) ORDER BY b.id", {"primary_keys": list(range(95, 101))}, @@ -2474,19 +2474,19 @@ class ChunkingTest(fixtures.DeclarativeMappedTest): ), # chunk size is 47. so first chunk are a 1->47... CompiledSQL( - "SELECT a.id AS a_id FROM a WHERE a.id IN " + "SELECT a.id FROM a WHERE a.id IN " "(__[POSTCOMPILE_primary_keys])", {"primary_keys": list(range(1, 48))}, ), # second chunk is a 48-94 CompiledSQL( - "SELECT a.id AS a_id FROM a WHERE a.id IN " + "SELECT a.id FROM a WHERE a.id IN " "(__[POSTCOMPILE_primary_keys])", {"primary_keys": list(range(48, 95))}, ), # third and final chunk 95-100. CompiledSQL( - "SELECT a.id AS a_id FROM a WHERE a.id IN " + "SELECT a.id FROM a WHERE a.id IN " "(__[POSTCOMPILE_primary_keys])", {"primary_keys": list(range(95, 101))}, ), @@ -3011,15 +3011,14 @@ class SelfRefInheritanceAliasedTest( [{"id_1": 2}], ), CompiledSQL( - "SELECT foo_1.id AS foo_1_id, " - "foo_1.type AS foo_1_type, foo_1.foo_id AS foo_1_foo_id " + "SELECT foo_1.id, foo_1.type, foo_1.foo_id " "FROM foo AS foo_1 " "WHERE foo_1.id IN (__[POSTCOMPILE_primary_keys])", {"primary_keys": [3]}, ), CompiledSQL( - "SELECT foo.id AS foo_id_1, foo.type AS foo_type, " - "foo.foo_id AS foo_foo_id FROM foo " + "SELECT foo.id, foo.type, " + "foo.foo_id FROM foo " "WHERE foo.id IN (__[POSTCOMPILE_primary_keys])", {"primary_keys": [1]}, ), @@ -3188,7 +3187,7 @@ class SingleInhSubclassTest( {"type_1": ["employer"]}, ), CompiledSQL( - "SELECT role.user_id AS role_user_id, role.id AS role_id " + "SELECT role.user_id, role.id " "FROM role WHERE role.user_id " "IN (__[POSTCOMPILE_primary_keys])", {"primary_keys": [1]}, @@ -3312,7 +3311,7 @@ class M2OWDegradeTest( [{"id_1": [1, 3]}], ), CompiledSQL( - "SELECT b.id AS b_id, b.x AS b_x, b.y AS b_y " + "SELECT b.id, b.x, b.y " "FROM b WHERE b.id IN (__[POSTCOMPILE_primary_keys])", [{"primary_keys": [1, 2]}], ), @@ -3345,8 +3344,7 @@ class M2OWDegradeTest( # emit either for each parent object individually, or as a second # query for them. CompiledSQL( - "SELECT a_1.id AS a_1_id, b.id AS b_id, b.x AS b_x, " - "b.y AS b_y " + "SELECT a_1.id, b.id, b.x, b.y " "FROM a AS a_1 JOIN b ON b.id = a_1.b_id " "WHERE a_1.id IN (__[POSTCOMPILE_primary_keys])", [{"primary_keys": [1, 3]}], @@ -3371,7 +3369,7 @@ class M2OWDegradeTest( [{}], ), CompiledSQL( - "SELECT b.id AS b_id, b.x AS b_x, b.y AS b_y " + "SELECT b.id, b.x, b.y " "FROM b WHERE b.id IN (__[POSTCOMPILE_primary_keys])", [{"primary_keys": [1, 2]}], ), @@ -3402,8 +3400,8 @@ class M2OWDegradeTest( [{}], ), CompiledSQL( - "SELECT a_1.id AS a_1_id, b.id AS b_id, b.x AS b_x, " - "b.y AS b_y FROM a AS a_1 JOIN b ON b.id = a_1.b_id " + "SELECT a_1.id, b.id, b.x, b.y " + "FROM a AS a_1 JOIN b ON b.id = a_1.b_id " "WHERE a_1.id IN (__[POSTCOMPILE_primary_keys])", [{"primary_keys": [1, 2, 3, 4, 5]}], ), @@ -3436,8 +3434,7 @@ class M2OWDegradeTest( # emit either for each parent object individually, or as a second # query for them. CompiledSQL( - "SELECT a_1.id AS a_1_id, b.id AS b_id, b.x AS b_x, " - "b.y AS b_y " + "SELECT a_1.id, b.id, b.x, b.y " "FROM a AS a_1 JOIN b ON b.id = a_1.b_id " "WHERE a_1.id IN (__[POSTCOMPILE_primary_keys])", [{"primary_keys": [1, 2, 3, 4, 5]}], @@ -3549,15 +3546,15 @@ class SameNamePolymorphicTest(fixtures.DeclarativeMappedTest): ), AllOf( CompiledSQL( - "SELECT child_a.parent_id AS child_a_parent_id, " - "child_a.id AS child_a_id FROM child_a " + "SELECT child_a.parent_id, " + "child_a.id FROM child_a " "WHERE child_a.parent_id IN " "(__[POSTCOMPILE_primary_keys])", [{"primary_keys": [1]}], ), CompiledSQL( - "SELECT child_b.parent_id AS child_b_parent_id, " - "child_b.id AS child_b_id FROM child_b " + "SELECT child_b.parent_id, " + "child_b.id FROM child_b " "WHERE child_b.parent_id IN " "(__[POSTCOMPILE_primary_keys])", [{"primary_keys": [2]}], diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py index 4b839d8efc..b3c6f58775 100644 --- a/test/orm/test_subquery_relations.py +++ b/test/orm/test_subquery_relations.py @@ -147,9 +147,9 @@ class EagerTest(_fixtures.FixtureTest, testing.AssertsCompiledSQL): # issue 7505 # subqueryload degrades for a from_statement. this is a lazyload CompiledSQL( - "SELECT addresses.id AS addresses_id, addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE :param_1 = addresses.user_id ORDER BY addresses.id", [{"param_1": 7}], ), diff --git a/test/orm/test_unitofworkv2.py b/test/orm/test_unitofworkv2.py index 90ea0eaa03..af6f0c2ce7 100644 --- a/test/orm/test_unitofworkv2.py +++ b/test/orm/test_unitofworkv2.py @@ -381,25 +381,23 @@ class RudimentaryFlushTest(UOWTest): # the User row might be handled before or the addresses # are loaded so need to use AllOf CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.id = " ":pk_1", lambda ctx: {"pk_1": c1id}, ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.id = " ":pk_1", lambda ctx: {"pk_1": c2id}, ), CompiledSQL( - "SELECT users.id AS users_id, users.name AS users_name " + "SELECT users.id, users.name " "FROM users WHERE users.id = :pk_1", lambda ctx: {"pk_1": pid}, ), @@ -457,19 +455,17 @@ class RudimentaryFlushTest(UOWTest): # relationship is simple m2o, no SELECT should be emitted for # it. CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.id = " ":pk_1", lambda ctx: {"pk_1": c1id}, ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.id = " ":pk_1", lambda ctx: {"pk_1": c2id}, @@ -523,19 +519,17 @@ class RudimentaryFlushTest(UOWTest): AllOf( # the parent User is expired, so it gets loaded here. CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.id = " ":pk_1", lambda ctx: {"pk_1": c1id}, ), CompiledSQL( - "SELECT addresses.id AS addresses_id, " - "addresses.user_id AS " - "addresses_user_id, addresses.email_address AS " - "addresses_email_address FROM addresses " + "SELECT addresses.id, addresses.user_id, " + "addresses.email_address " + "FROM addresses " "WHERE addresses.id = " ":pk_1", lambda ctx: {"pk_1": c2id}, @@ -854,8 +848,7 @@ class RaiseLoadIgnoredTest( sess.flush, # for the flush process, lazy="raise" is ignored CompiledSQL( - "SELECT b.id AS b_id, b.a_id AS b_a_id FROM b " - "WHERE :param_1 = b.a_id", + "SELECT b.id, b.a_id FROM b WHERE :param_1 = b.a_id", [{"param_1": 1}], ), CompiledSQL( @@ -1313,23 +1306,20 @@ class SingleCycleTest(UOWTest): # the selects here are in fact unexpiring # each row - the m2o comes from the identity map. CompiledSQL( - "SELECT nodes.id AS nodes_id, nodes.parent_id AS " - "nodes_parent_id, " - "nodes.data AS nodes_data FROM nodes " + "SELECT nodes.id, nodes.parent_id, nodes.data " + "FROM nodes " "WHERE nodes.id = :pk_1", lambda ctx: {"pk_1": pid}, ), CompiledSQL( - "SELECT nodes.id AS nodes_id, nodes.parent_id AS " - "nodes_parent_id, " - "nodes.data AS nodes_data FROM nodes " + "SELECT nodes.id, nodes.parent_id, nodes.data " + "FROM nodes " "WHERE nodes.id = :pk_1", lambda ctx: {"pk_1": c1id}, ), CompiledSQL( - "SELECT nodes.id AS nodes_id, nodes.parent_id AS " - "nodes_parent_id, " - "nodes.data AS nodes_data FROM nodes " + "SELECT nodes.id, nodes.parent_id, nodes.data " + "FROM nodes " "WHERE nodes.id = :pk_1", lambda ctx: {"pk_1": c2id}, ), @@ -1510,8 +1500,8 @@ class SingleCycleM2MTest( # this is n1.parents firing off, as it should, since # passive_deletes is False for n1.parents CompiledSQL( - "SELECT nodes.id AS nodes_id, nodes.data AS nodes_data, " - "nodes.favorite_node_id AS nodes_favorite_node_id FROM " + "SELECT nodes.id, nodes.data, " + "nodes.favorite_node_id FROM " "nodes, node_to_nodes WHERE :param_1 = " "node_to_nodes.right_node_id AND nodes.id = " "node_to_nodes.left_node_id", @@ -2506,14 +2496,12 @@ class EagerDefaultsTest(fixtures.MappedTest): enable_returning=False, ), CompiledSQL( - "SELECT test.foo AS test_foo FROM test " - "WHERE test.id = :pk_1", + "SELECT test.foo FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], enable_returning=False, ), CompiledSQL( - "SELECT test.foo AS test_foo FROM test " - "WHERE test.id = :pk_1", + "SELECT test.foo FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], enable_returning=False, ), @@ -2574,13 +2562,11 @@ class EagerDefaultsTest(fixtures.MappedTest): [{"id": 1}, {"id": 2}], ), CompiledSQL( - "SELECT test.foo AS test_foo FROM test " - "WHERE test.id = :pk_1", + "SELECT test.foo FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test.foo AS test_foo FROM test " - "WHERE test.id = :pk_1", + "SELECT test.foo FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], ), ], @@ -2640,12 +2626,12 @@ class EagerDefaultsTest(fixtures.MappedTest): ], ), CompiledSQL( - "SELECT test3.foo AS test3_foo " + "SELECT test3.foo " "FROM test3 WHERE test3.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test3.foo AS test3_foo " + "SELECT test3.foo " "FROM test3 WHERE test3.id = :pk_1", [{"pk_1": 2}], ), @@ -2731,12 +2717,12 @@ class EagerDefaultsTest(fixtures.MappedTest): enable_returning=False, ), CompiledSQL( - "SELECT test2.bar AS test2_bar FROM test2 " + "SELECT test2.bar FROM test2 " "WHERE test2.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test2.bar AS test2_bar FROM test2 " + "SELECT test2.bar FROM test2 " "WHERE test2.id = :pk_1", [{"pk_1": 3}], ), @@ -2830,13 +2816,13 @@ class EagerDefaultsTest(fixtures.MappedTest): enable_returning=False, ), CompiledSQL( - "SELECT test4.bar AS test4_bar FROM test4 " + "SELECT test4.bar FROM test4 " "WHERE test4.id = :pk_1", [{"pk_1": 1}], enable_returning=False, ), CompiledSQL( - "SELECT test4.bar AS test4_bar FROM test4 " + "SELECT test4.bar FROM test4 " "WHERE test4.id = :pk_1", [{"pk_1": 3}], enable_returning=False, @@ -2934,18 +2920,15 @@ class EagerDefaultsTest(fixtures.MappedTest): enable_returning=False, ), CompiledSQL( - "SELECT test2.bar AS test2_bar FROM test2 " - "WHERE test2.id = :pk_1", + "SELECT test2.bar FROM test2 WHERE test2.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test2.bar AS test2_bar FROM test2 " - "WHERE test2.id = :pk_1", + "SELECT test2.bar FROM test2 WHERE test2.id = :pk_1", [{"pk_1": 3}], ), CompiledSQL( - "SELECT test2.bar AS test2_bar FROM test2 " - "WHERE test2.id = :pk_1", + "SELECT test2.bar FROM test2 WHERE test2.id = :pk_1", [{"pk_1": 4}], ), ) @@ -3124,7 +3107,7 @@ class EagerDefaultsTest(fixtures.MappedTest): [{"id": 1, "bar": 5}], ), CompiledSQL( - "SELECT anon_1.foo AS anon_1_foo FROM " + "SELECT anon_1.foo FROM " "(SELECT test.id AS id, test.foo AS foo, " "test2.id AS id2, test2.bar AS bar FROM test " "JOIN test2 ON test.foo = test2.foo) AS anon_1 " @@ -3268,12 +3251,12 @@ class EagerDefaultsSettingTest( expected_eager_defaults and not expect_returning, [ CompiledSQL( - "SELECT test.foo AS test_foo " + "SELECT test.foo " "FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test.foo AS test_foo " + "SELECT test.foo " "FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], ), @@ -3388,12 +3371,12 @@ class EagerDefaultsSettingTest( expected_eager_defaults and not expect_returning, [ CompiledSQL( - "SELECT test.foo AS test_foo " + "SELECT test.foo " "FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test.foo AS test_foo " + "SELECT test.foo " "FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], ), @@ -3464,12 +3447,12 @@ class EagerDefaultsSettingTest( ], ), CompiledSQL( - "SELECT test.bar AS test_bar " + "SELECT test.bar " "FROM test WHERE test.id = :pk_1", [{"pk_1": 1}], ), CompiledSQL( - "SELECT test.bar AS test_bar " + "SELECT test.bar " "FROM test WHERE test.id = :pk_1", [{"pk_1": 2}], ), diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py index 06fb1b2a5f..d239869a4e 100644 --- a/test/orm/test_versioning.py +++ b/test/orm/test_versioning.py @@ -1421,7 +1421,6 @@ class ServerVersioningTest(fixtures.MappedTest): statements.append( CompiledSQL( "SELECT version_table.version_id " - "AS version_table_version_id " "FROM version_table WHERE version_table.id = :pk_1", lambda ctx: [{"pk_1": 1}], ) @@ -1479,7 +1478,6 @@ class ServerVersioningTest(fixtures.MappedTest): ), CompiledSQL( "SELECT version_table.version_id " - "AS version_table_version_id " "FROM version_table WHERE version_table.id = :pk_1", lambda ctx: [{"pk_1": 1}], ), @@ -1630,19 +1628,16 @@ class ServerVersioningTest(fixtures.MappedTest): ), CompiledSQL( "SELECT version_table.version_id " - "AS version_table_version_id " "FROM version_table WHERE version_table.id = :pk_1", lambda ctx: [{"pk_1": 1}], ), CompiledSQL( "SELECT version_table.version_id " - "AS version_table_version_id " "FROM version_table WHERE version_table.id = :pk_1", lambda ctx: [{"pk_1": 2}], ), CompiledSQL( "SELECT version_table.version_id " - "AS version_table_version_id " "FROM version_table WHERE version_table.id = :pk_1", lambda ctx: [{"pk_1": 3}], ), diff --git a/test/profiles.txt b/test/profiles.txt index c50e01ce30..50da808a17 100644 --- a/test/profiles.txt +++ b/test/profiles.txt @@ -387,9 +387,9 @@ test.aaa_profiling.test_orm.MergeBackrefsTest.test_merge_pending_with_all_pks x8 # TEST: test.aaa_profiling.test_orm.MergeTest.test_merge_load -test.aaa_profiling.test_orm.MergeTest.test_merge_load x86_64_linux_cpython_3.13_sqlite_pysqlite_dbapiunicode_cextensions 1491 +test.aaa_profiling.test_orm.MergeTest.test_merge_load x86_64_linux_cpython_3.13_sqlite_pysqlite_dbapiunicode_cextensions 1332 test.aaa_profiling.test_orm.MergeTest.test_merge_load x86_64_linux_cpython_3.13_sqlite_pysqlite_dbapiunicode_nocextensions 1603 -test.aaa_profiling.test_orm.MergeTest.test_merge_load x86_64_linux_cpython_3.14_sqlite_pysqlite_dbapiunicode_cextensions 1492 +test.aaa_profiling.test_orm.MergeTest.test_merge_load x86_64_linux_cpython_3.14_sqlite_pysqlite_dbapiunicode_cextensions 1333 test.aaa_profiling.test_orm.MergeTest.test_merge_load x86_64_linux_cpython_3.14_sqlite_pysqlite_dbapiunicode_nocextensions 1604 # TEST: test.aaa_profiling.test_orm.MergeTest.test_merge_no_load