]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
don't use LABEL_STYLE_TABLENAME_PLUS_COL in _SelectInLoader
authorInada Naoki <songofacandy@gmail.com>
Thu, 23 Oct 2025 06:30:41 +0000 (15:30 +0900)
committerInada Naoki <songofacandy@gmail.com>
Thu, 23 Oct 2025 07:05:40 +0000 (16:05 +0900)
12 files changed:
doc/build/orm/extensions/asyncio.rst
doc/build/orm/queryguide/columns.rst
doc/build/orm/queryguide/inheritance.rst
doc/build/tutorial/orm_related_objects.rst
lib/sqlalchemy/orm/strategies.py
test/orm/inheritance/test_poly_loading.py
test/orm/inheritance/test_single.py
test/orm/test_ac_relationships.py
test/orm/test_deferred.py
test/orm/test_relationship_criteria.py
test/orm/test_relationships.py
test/orm/test_selectin_relations.py

index bd14d6f2d2cfcd572c73b44d21709cb81eebce4c..31d22487010721dbe7a49d1aa4e0e510a7f662e7 100644 (file)
@@ -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)
index d8b086efea3eb121beadad6c1bcd641ef240c73c..f461d524f8a6b7079454cfec30e01acf4e0240b5 100644 (file)
@@ -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)
index 7f948ded97ca23012835430456cc15fafe547e7d..063bdbfd3b0a471ccd68ce718bbb790d8c84ee55 100644 (file)
@@ -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
index 454875ab5fe1667f83050db856fe3e89b6866183..e0dcbac871c752da603bf9869a34471cf42aff64 100644 (file)
@@ -454,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}
@@ -667,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)
index 6eb91af25c720280df77466b2d44cb565e2ead1d..6a71316646916b5ed55cd083007a47dea834ce51 100644 (file)
@@ -3211,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",
index f912710916a5169ed09e5c6be4e77abfbab5f523..9bdb695e17d0e1c464d8e8f6d26d3d415e92b457 100644 (file)
@@ -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]) "
index 0f15ac4a511c0300e9544f01ae06bc182a0b124c..a26aed1cf1eb731adb82e2a46119c3a49081216d 100644 (file)
@@ -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])",
index aa7a393ffb4cee5fed3c545d8851a291ccbabfe3..c4ff8d7de3734dd36b3161da8f2df3c99f48e981 100644 (file)
@@ -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])",
index 8c29831e4e848ceb8b54acd33fb78167622470d3..95c362d8fac55159f7bde7093f629e461dd87913 100644 (file)
@@ -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]}],
index 3fe4d72e257225b9f176d6400190d57b09b665d7..90c3243eac8d08376a564b15e2b00ca56e756bd7 100644 (file)
@@ -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",
@@ -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 "
index 8b14dae5385d006a2ab9e3628a1ffe96dbfa5197..f610860d5d630d317f26af22bdd432c5c33fa3b2 100644 (file)
@@ -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 "
index c29da9f87c07f7ad995c32c6b23d1d0e77a2c9ea..9623cf0fae4229b05d1bfec821a2bd354f921de7 100644 (file)
@@ -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]}],