Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 2.0-M2
-
Fix Version/s: 2.0-RC1
-
Component/s: Persistence
-
Labels:None
Description
The code Foo.executeQuery("some query").each{} throws an exception
groovy.lang.MissingMethodException: No signature of method: ConsoleScript1$_run_closure1.doCall()
-
Hide
- grails8002.zip
- 08/Sep/11 2:38 PM
- 117 kB
- Jeff Brown
-
- grails8002/.classpath 0.7 kB
- grails8002/.gitignore 0.0 kB
- grails8002/.project 0.5 kB
- grails8002/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- grails8002/application.properties 0.1 kB
- grails8002/grails-app/.../BootStrap.groovy 0.1 kB
- grails8002/grails-app/.../BuildConfig.groovy 2 kB
- grails8002/grails-app/conf/Config.groovy 4 kB
- grails8002/grails-app/.../DataSource.groovy 1 kB
- grails8002/grails-app/.../UrlMappings.groovy 0.2 kB
- grails8002/grails-app/.../resources.groovy 0.0 kB
- grails8002/.../FooController.groovy 3 kB
- grails8002/grails-app/domain/Foo.groovy 0.0 kB
- grails8002/.../messages.properties 3 kB
- grails8002/.../messages_cs_CZ.properties 3 kB
- grails8002/.../messages_da.properties 3 kB
- grails8002/.../messages_de.properties 4 kB
- grails8002/.../messages_es.properties 3 kB
- grails8002/.../messages_fr.properties 2 kB
- grails8002/.../messages_it.properties 2 kB
- grails8002/.../messages_ja.properties 4 kB
- grails8002/.../messages_nl.properties 3 kB
- grails8002/.../messages_pt_BR.properties 3 kB
- grails8002/.../messages_pt_PT.properties 3 kB
- grails8002/.../messages_ru.properties 4 kB
- grails8002/.../messages_sv.properties 3 kB
- grails8002/.../messages_th.properties 5 kB
- grails8002/.../messages_zh_CN.properties 2 kB
- grails8002/grails-app/views/error.gsp 0.3 kB
- grails8002/grails-app/.../foo/_form.gsp 0.2 kB
-
Hide
- groovy5009.zip
- 25/Sep/11 8:02 PM
- 112 kB
- Jeff Brown
-
- groovy5009/.classpath 0.7 kB
- groovy5009/.gitignore 0.0 kB
- groovy5009/.project 0.5 kB
- groovy5009/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- groovy5009/application.properties 0.1 kB
- groovy5009/grails-app/.../BootStrap.groovy 0.2 kB
- groovy5009/grails-app/.../BuildConfig.groovy 2 kB
- groovy5009/grails-app/conf/Config.groovy 4 kB
- groovy5009/grails-app/.../DataSource.groovy 1 kB
- groovy5009/grails-app/.../UrlMappings.groovy 0.2 kB
- groovy5009/grails-app/.../resources.groovy 0.0 kB
- groovy5009/.../DemoController.groovy 0.3 kB
- groovy5009/grails-app/.../Person.groovy 0.1 kB
- groovy5009/.../messages.properties 3 kB
- groovy5009/.../messages_cs_CZ.properties 3 kB
- groovy5009/.../messages_da.properties 3 kB
- groovy5009/.../messages_de.properties 4 kB
- groovy5009/.../messages_es.properties 3 kB
- groovy5009/.../messages_fr.properties 2 kB
- groovy5009/.../messages_it.properties 2 kB
- groovy5009/.../messages_ja.properties 4 kB
- groovy5009/.../messages_nl.properties 3 kB
- groovy5009/.../messages_pt_BR.properties 3 kB
- groovy5009/.../messages_pt_PT.properties 3 kB
- groovy5009/.../messages_ru.properties 4 kB
- groovy5009/.../messages_sv.properties 3 kB
- groovy5009/.../messages_th.properties 5 kB
- groovy5009/.../messages_zh_CN.properties 2 kB
- groovy5009/grails-app/views/error.gsp 0.3 kB
- groovy5009/grails-app/views/index.gsp 3 kB
Issue Links
- is duplicated by
-
GRAILS-8008
.each closure not work
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
I am attaching a project which invokes the each method on value returned from the executeQuery method and it appears to work as it should. See the list action in the FooController.
I suspect you may have a typo or the body of the closure that you are passing to the each method is doing something funky.
If you can provide any more information, that might be helpful.
Thanks for the help!
If I take your example and add the code below to the list action, it fails. This worked in M1. If I only select on name, it works.
new Foo('name':'Abby','title':'Lady').save()
new Foo('name':'Bill','title':'Sir').save()
new Foo('name':'Carol','title':'Dame').save()
Foo.executeQuery('select name,title from Foo').each { foo ->
println "Name: $
"
}
Sorry I didn't get an example to you sooner, and I'll try to be more responsive as work allows me.
I don't think this has anything to do with executeQuery. I think it has to do with something going wrong with dispatching to the closure. The following code generates the same problem:
package com.demo class DemoController { def index() { def f = [['a', 'b'] as Object[]] f.each {} } }
Is it a Groovy bug? If so have we raised a corresponding Groovy JIRA?
Probably not a Groovy bug.
If I run the closure test code Jeff posted in the Grails console, I get the same error. If I run it in a Groovy 1.8.2 console, there is no error.
This may be related to http://jira.codehaus.org/browse/GROOVY-5009.
In case it's not obvious, the easy workaround is to use a for loop:
for (foo in Foo.executeQuery("some query")) { ... }
I believe that this also breaks criteria.list(), which means every place you use criteria.list().each() is broken. Or at least I believe those were the locations where this bug was biting us. I don't think rewriting all of our code to use a different construct constitutes an easy or viable workaround. Is this supposed to be fixed now that the dependency on groovy upgraded to 1.8.3?
Charles,
I expect this to be resolved once we upgrade to 1.8.3 (currently we are still using 1.8.2). The problem is serious and should be resolved before we release Grails 2. The query methods are just one way that the problem might manifest. We have flagged the issue as a Blocker.
fixed with the 1.8.3 snapshot in Groovy in use now. When RC1 is released we will be on 1.8.3 final
Should this now work with the latest snapshot build? I downloaded the latest (1420) and get the same error as before.
The attached application works for me, are you seeing something different?
Graeme,
See the attached groovy5009.zip. Click the links on the main index page. Do those generate errors for you?
Yeah I can reproduce. I have re-opened the relevant Groovy issue
This is definitely fixed now with latest Groovy 1.8.3 snapshot. Added test to ensure no future regression:
https://github.com/grails/grails-core/commit/b9c9472449e072fe158b854a28b04a4adda02783
I'm able to run my application with the latest build snapshot.
Thanks!
Can you post an executable example?