Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
2.3.4
-
None
-
None
Description
We are using 2.2.1 in production, and we have the following:
sql.executeInsert("INSERT INTO ${hqUser.tenant.slug}.user (email, password, registration_date) VALUES (?, ?, date_part('epoch', now()))",
[hqUser.user.email, passwordEncoder.encode(hqUser.user.password)])
But after migrating to 2.3.4 we got an exception
groovy.lang.MissingPropertyException: No such property: user for class: java.lang.String at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) at groovy.sql.Sql$executeInsert$5.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
After debugging I realised that getParams() inside Sql.java is actually returning ${hqUser.tenant.slug} value instead of params for the query.
I've changed my call to use string version of executeInsert (calling toString() on GString) and it's working. But the problem is in the getParams(), I think it should return sql params, and not the values from gstring. Not sure in which version that was changed, because it worked in 2.2.1