Skip to content

Fix for parameter position Error that occurs when binding the same Collection multiple times in R2DBC DatabaseClient #34873

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

Conversation

Tussle0410
Copy link
Contributor

While developing with R2DBC DatabaseClient, an error occurred with the message 'Parameter at position 3 is not set' during the process of binding a Collection multiple times.

[Example SQL]

SELECT * 
FROM PERSON
WHERE name IN (:ids)
GROUP BY address

UNION

SELECT * 
FROM PERSON
WHERE name NOT IN (:ids)

[Execute Code]

    List<String> ids = List.of("1", "2", "3");

    return databaseClient.sql(query)
        .bind("ids", ids)
        .map((row, rowMetadata) -> row.get("name", String.class))
        .all();

[Exception]

java.lang.IllegalStateException: Parameter at position 3 is not set

When debugging the related code, we confirmed that while it was retrieving the marking and index information, it was replacing the Collection values with information that had only been marked once.

We modified the code that replaces Collections according to marking and index information to ensure it doesn't execute only once, and we've written related test code.

[Modified]
When binding a Collection multiple times, n BindMarkers are created for the collection, so we modified the code to repeat the marking process if there is remaining mark information for the collection, ensuring the binding process executes n times.

Tussle0410 added 2 commits May 9, 2025 10:41
Signed-off-by: ChanHyeongLee <cksgud410@gmail.com>
Signed-off-by: ChanHyeongLee <cksgud410@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 9, 2025
@sbrannen sbrannen self-assigned this May 9, 2025
@sbrannen sbrannen added the in: data Issues in data modules (jdbc, orm, oxm, tx) label May 9, 2025
@sbrannen
Copy link
Member

sbrannen commented May 9, 2025

Hi @Tussle0410,

Thanks for raising the issue and simultaneously submitting a proposed fix.

However, this issue was already reported a few weeks ago in #34768, and I just pushed a fix in dd6eede.

In light of that, I am closing this as a ...

@sbrannen sbrannen closed this May 9, 2025
@sbrannen sbrannen added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: duplicate A duplicate of another issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants