Conversation
…ySQL When HEAD (count pagination) uses multiple JOINs, the subquery for each JOIN table only selected its own ON key (on.getKey()). If another JOIN's ON clause references a column of this table (e.g. Warehose_info.id@ = /Location_info/warehouse_id), that column was missing from the subquery, causing an Unknown column error on MySQL. Now, for MySQL-family databases, also collect the targetKey of any ON clause (from any JOIN in the list) whose target table/alias matches the current JOIN table. PostgreSQL keeps its SELECT * fallback. issue APIJSON#824 fixes APIJSON#824
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix for issue #824 (multi-JOIN count pagination). When
HEAD/count pagination is used with multiple JOINs, the subquery for each JOIN table only selected its own ON key (on.getKey()). If another JOIN's ON clause references a column of this table, that column was missing from the subquery, causing anUnknown columnerror.Example (from the issue):
Location_info's subquery only selectscode, but the second ON clause referencesLocation_info.warehouse_id.Change
In
AbstractSQLConfig.parseJoin(MySQL-family databases only), when building the subquery column list for a JOIN table, also collect thetargetKeyof any ON clause (from any JOIN in the list) whose target table/alias matches the current JOIN table. Uses aLinkedHashSetto keep insertion order and deduplicate.PostgreSQL (and other non-MySQL databases) keep their existing
SELECT *fallback, which already covers this case.Tests
Added
AbstractSQLConfigJoinCountTestwith 2 cases:SELECT *(regression guard).Location_infosubquery must include bothcode(its own ON key) andwarehouse_id(referenced by the second JOIN's ON).Full suite: 38 tests, 0 failures.
fixes #824