Skip to content

spring-r2dbc can't correctly fill multiple named parameters with list #34768

Open
@Dieken

Description

@Dieken

https://github.com/spring-projects/spring-framework/blob/v7.0.0-M3/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/NamedParameterUtils.java#L528

if (parameter.getValue() instanceof Collection collection) {
				Iterator<Object> iterator = collection.iterator();
				Iterator<BindMarker> markers = bindMarkers.iterator();
				while (iterator.hasNext()) {
					Object valueToBind = iterator.next();
					if (valueToBind instanceof Object[] objects) {
						for (Object object : objects) {
							bind(target, markers, object);
						}
					}
					else {
						bind(target, markers, valueToBind);
					}
				}
			}

For example, for SELECT ... WHERE fund_codeA in (:fundCodes) OR fund_codeB in (:fundCodes), fundCodes references a List, then the code above only fill the first occurrence of :fundCodes.

parameter = ["00001"]
markers = [?, ?]    // two occurrence

// iterate on parameter won't fill second "?"
// SELECT .... WHERE fund_codeA in (?)   OR fund_codeB in (?)

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: waiting-for-feedbackWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triaged or decided on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions