Skip to content

Add failing test with multiple joins and InlineQuery #1362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

koenpunt
Copy link
Contributor

@koenpunt koenpunt commented Oct 13, 2022

I'm not sure yet how I should approach this problem, but it seems that somehow where clauses of the inline query are partly reused in the outer query, resulting in invalid SQL.

To clarify, the test result is:

org.opentest4j.AssertionFailedError: 
expected: "SELECT merchants_customers.* FROM merchants_customers JOIN (SELECT customer_details.user_id AS user_id FROM customer_details JOIN merchants_customers ON merchants_customers.user_id = customer_details.user_id) inner ON inner.user_id = merchants_customers.user_id"
 but was: "SELECT merchants_customers.* FROM merchants_customers JOIN (SELECT customer_details.user_id AS user_id FROM customer_details JOIN merchants_customers ON merchants_customers.user_id = customer_details.user_id) inner ON merchants_customers.merchant_id = :merchantId = merchants_customers.user_id"
  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 13, 2022
@koenpunt
Copy link
Contributor Author

I've been able to make the test a bit smaller with less conditions and clauses. But after spending quite some time I haven't been able to find what should be changed to let this behave correctly.

Somewhere between ComparisonVisitor.enterNested and ComparisonVisitor.leaveNested the previous comparison is visited again, and causes the incorrect SQL.

Unfortunately I don't know enough about the visitor/delegation setup to find the actual cause.

@schauder schauder added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 17, 2022
schauder pushed a commit that referenced this pull request Oct 25, 2022
Adds a test demonstrating that the join condition of inline queries messes up those of outer joins.

Original pull request #1362
schauder added a commit that referenced this pull request Oct 25, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes #1362
schauder added a commit that referenced this pull request Oct 25, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes #1362
@schauder
Copy link
Contributor

I created a fresh PR which includes your (simplified) tests plus a fix: #1368

@schauder schauder closed this Oct 25, 2022
@koenpunt koenpunt deleted the InlineQuery-issues branch October 25, 2022 15:11
schauder pushed a commit that referenced this pull request Nov 15, 2022
Adds a test demonstrating that the join condition of inline queries messes up those of outer joins.

Original pull request #1362
schauder added a commit that referenced this pull request Nov 15, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes #1362
schauder added a commit that referenced this pull request Nov 15, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes #1362
schauder added a commit that referenced this pull request Nov 15, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes #1362
@schauder schauder added this to the 3.0 GA (2022.0.0) milestone Nov 15, 2022
mp911de pushed a commit that referenced this pull request Nov 16, 2022
Adds a test demonstrating that the join condition of inline queries messes up those of outer joins.

Closes: #1362
Original pull request: #1368
mp911de pushed a commit that referenced this pull request Nov 16, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes: #1362
Original pull request: #1368
mp911de added a commit that referenced this pull request Nov 16, 2022
Extend tests to use aliased columns.

See #1362
Original pull request: #1368
mp911de pushed a commit that referenced this pull request Nov 16, 2022
Adds a test demonstrating that the join condition of inline queries messes up those of outer joins.

Closes: #1362
Original pull request: #1368
mp911de pushed a commit that referenced this pull request Nov 16, 2022
Before this fix, whenever a column of an inline query was rendered the `InlineQuery` and all its children were visited, resulting in spurious output.
This is no prevented by injecting a NoopVisitor.

Closes: #1362
Original pull request: #1368
mp911de added a commit that referenced this pull request Nov 16, 2022
Extend tests to use aliased columns.

See #1362
Original pull request: #1368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants