Skip to content

Commit bce044e

Browse files
GRAILS-9895 - improve binding String to collection
When binding a String to a collection of some non String type, the conversion was not happening. Relevant functional tests: grails/grails-functional-tests@ea1dc74
1 parent 31108a4 commit bce044e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

grails-web/src/main/groovy/org/codehaus/groovy/grails/web/binding/GrailsDataBinder.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,14 @@ else if (v!=null && (v instanceof String)) {
925925
}
926926
}
927927
else if (GrailsDomainConfigurationUtil.isBasicType(associatedType)) {
928-
if (isArray) {
929-
Object[] values = (Object[])v;
928+
Object[] values = null;
929+
if(isArray) {
930+
values = (Object[])v;
931+
} else if(v instanceof String) {
932+
values = new String[]{(String)v};
933+
}
934+
935+
if (values != null) {
930936
List list = collection instanceof List ? (List)collection : null;
931937
for (int i = 0; i < values.length; i++) {
932938
Object value = values[i];
@@ -948,6 +954,7 @@ else if (GrailsDomainConfigurationUtil.isBasicType(associatedType)) {
948954
// ignore
949955
}
950956
}
957+
mpvs.removePropertyValue(pv);
951958
}
952959
}
953960
}

0 commit comments

Comments
 (0)