Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
1.0-JSR-1
-
None
-
None
-
None
Description
int index = 1
println "test.$index".getClass()
Result is not java.lang.String as I would expect, but some kind of inner script class. In many cases it will not make any difference, as it will be automatically converted to string as needed, but at least in one place it DOES make a difference - when I try to use sql.dataSet(...).add(map). With string column 'NAME' I cannot do
def map = [:]
map.NAME = 'test.$index"
sql.add(map)
because sql dataset will try to set NAME to Object (like Script$1) instead of String field.
While sql dataset could be possibly corrected for this special case, I have no doubts that other similar cases will appear on any api trying to find out argument types dynamically. If it is not possible to change for any reason, then in documentation it should be written with very big letters, that you should use "test.$index".toString() in case of any dynamic api.
Attachments
Issue Links
- relates to
-
GROOVY-883 when passing an list of gstrings to Java, it will never be treated as a String[]
- Closed