spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
740 stars 342 forks source link

Should NOT_IN judgment be added to QueryMapper's convertValue function implementation? #1744

Closed yande2011 closed 4 months ago

yande2011 commented 4 months ago

The current implementation is like this @Nullable private Object convertValue(Comparator comparator, @Nullable Object value, TypeInformation<?> typeHint) {

    if (Comparator.IN.equals(comparator) && value instanceof Collection<?> collection && !collection.isEmpty()) {

        Collection<Object> mapped = new ArrayList<>(collection.size());

        for (Object o : collection) {
            mapped.add(convertValue(o, typeHint));
        }

        return mapped;
    }

    return convertValue(value, typeHint);
}

My scenario is like this. I implemented the conversion from Collection to String myself. If NOT_IN is not determined before, the subsequent conversion function first determines whether conversion is possible, resulting in the wrong type of conversion.

mp911de commented 4 months ago

It should be added. Do you want to submit a pull request?

yande2011 commented 4 months ago

It should be added. Do you want to submit a pull request?

ok, i'll submit.