Applying sort on fetch-joined table's column while using paginator with an output walker. #5962

Open
opened 2026-01-22 15:23:17 +01:00 by admin · 0 comments
Owner

Originally created by @thexpand on GitHub (May 15, 2018).

Bug Report

Description

Here is the initial query:

SELECT	p0_.sku AS sku_0,
		p0_.price AS price_1,
		p0_.specialPrice AS specialPrice_2,
		p0_.weight AS weight_3,
		p0_.createdAt AS createdAt_4,
		p0_.updatedAt AS updatedAt_5,
		p0_.stockQuantity AS stockQuantity_6,
		p0_.isNeverOutOfStock AS isNeverOutOfStock_7,
		p0_.type AS type_8,
		p0_.id AS id_9

FROM Product p0_
LEFT JOIN ProductTranslation p1_ ON p0_.id = p1_.productId
ORDER BY p1_.productStatusId DESC

which gets transformed into the following one (after creating a paginator):

SELECT DISTINCT id_9 FROM (

	SELECT DISTINCT id_9, p1_.productStatusId FROM (
		SELECT	p0_.sku AS sku_0,
				p0_.price AS price_1,
				p0_.specialPrice AS specialPrice_2,
				p0_.weight AS weight_3,
				p0_.createdAt AS createdAt_4,
				p0_.updatedAt AS updatedAt_5,
				p0_.stockQuantity AS stockQuantity_6,
				p0_.isNeverOutOfStock AS isNeverOutOfStock_7,
				p0_.type AS type_8,
				p0_.id AS id_9,
				p1_.productId AS productId_11,
				p1_.productStatusId AS productStatusId_12

				FROM Product p0_
				LEFT JOIN ProductTranslation p1_ ON p0_.id = p1_.productId

				ORDER BY p1_.id ASC
	) dctrn_result_inner

	ORDER BY p1_.productStatusId DESC

) dctrn_result LIMIT 50 OFFSET 0

However, as you can see, the second column's alias in the SELECT is not resolved at all.
Instead of aliasing to productStatusId_12 the colum remained p1_.productStatusId.

Which produces the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'p1_.productStatusId' in 'field list'

Additional information

I'm not using any additional options with the paginator.
Just creating a new paginator with the query and calling getItems() through the adapter for Zend Framework.

Originally created by @thexpand on GitHub (May 15, 2018). ### Bug Report #### Description Here is the initial query: ``` SELECT p0_.sku AS sku_0, p0_.price AS price_1, p0_.specialPrice AS specialPrice_2, p0_.weight AS weight_3, p0_.createdAt AS createdAt_4, p0_.updatedAt AS updatedAt_5, p0_.stockQuantity AS stockQuantity_6, p0_.isNeverOutOfStock AS isNeverOutOfStock_7, p0_.type AS type_8, p0_.id AS id_9 FROM Product p0_ LEFT JOIN ProductTranslation p1_ ON p0_.id = p1_.productId ORDER BY p1_.productStatusId DESC ``` which gets transformed into the following one (after creating a paginator): ``` SELECT DISTINCT id_9 FROM ( SELECT DISTINCT id_9, p1_.productStatusId FROM ( SELECT p0_.sku AS sku_0, p0_.price AS price_1, p0_.specialPrice AS specialPrice_2, p0_.weight AS weight_3, p0_.createdAt AS createdAt_4, p0_.updatedAt AS updatedAt_5, p0_.stockQuantity AS stockQuantity_6, p0_.isNeverOutOfStock AS isNeverOutOfStock_7, p0_.type AS type_8, p0_.id AS id_9, p1_.productId AS productId_11, p1_.productStatusId AS productStatusId_12 FROM Product p0_ LEFT JOIN ProductTranslation p1_ ON p0_.id = p1_.productId ORDER BY p1_.id ASC ) dctrn_result_inner ORDER BY p1_.productStatusId DESC ) dctrn_result LIMIT 50 OFFSET 0 ``` However, as you can see, the second column's alias in the SELECT is not resolved at all. Instead of aliasing to `productStatusId_12` the colum remained `p1_.productStatusId`. Which produces the following error: `SQLSTATE[42S22]: Column not found: 1054 Unknown column 'p1_.productStatusId' in 'field list'` #### Additional information I'm not using any additional options with the paginator. Just creating a new paginator with the query and calling `getItems()` through the adapter for Zend Framework.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5962