Skip to content
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

fix: EXPOSED-493 Update with join query throws if WHERE clause present #2207

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

bog-walk
Copy link
Member

Description

Summary of the change:
Fixes bug when generating UPDATE-FROM-JOIN statement that uses a subquery (with its own WHERE clause) in the JOIN part.

Detailed description:

  • Why:
    Previous refactor of UpdateStatement.arguments(), to properly order registered arguments in an update-from-join statement, took place in PR fix: EXPOSED-301 Update with join throws if additionalConstraint provided #2007 . The fix did not factor in the possibility that the join target could be a subquery. If this query itself holds any clause with arguments, the latter will not be registered when preparing the statement, leading to the same No value specified for parameter x errors as previously.

  • How:

    • Any detected subquery arguments are registered just before the rest of the join part additional arguments.
    • Tests for single and multiple joins, and joins with update-where, have been edited to include joins with a subquery.

Type of Change

Please mark the relevant options with an "X":

  • Bug fix

Affected databases:

  • All

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)

Related Issues

EXPOSED-493

@bog-walk bog-walk requested a review from e5l August 20, 2024 02:17
joinWithConstraint.update({ tableA.foo eq "foo" }) {
it[tableB.bar] = "baz"
}
assertEquals(0, joinWithConstraint.selectAll().count())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to split this test into multiple. If something breaks it will take time to investigate

Previous refactoring of UpdateStatement.arguments() to properly order registered
arguments in an update-from-join statement did not factor in the possibility that
the join target would be a subquery or QueryAlias. If this query itself holds a WHERE
clause with arguments, the latter will not be registered when preparing the statement,
leading to the same 'parameter not filled' errors as previously.

This PR ensures any query arguments are registered just before the rest of the join
part additional arguments, at whatever point that may be for each database.

Tests for single and multiple joins, and joins with update-where, have been edited
to include joins with a subquery.
- Break up new tests into separate unit tests
- Fix typos in update(where) unsupported exceptions
- Rebase from main
@bog-walk bog-walk force-pushed the bog-walk/fix-join-subquery-update branch from c0b7051 to e17ce9c Compare August 20, 2024 14:54
@bog-walk bog-walk merged commit 6b8ec4e into main Aug 20, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/fix-join-subquery-update branch August 20, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants