Closed marcpa00 closed 10 years ago
Fair point. I can't remember offhand exactly why that method is there, but the existence of a method call is the important bit I think. Hence why the implementation doesn't matter. I wasn't terribly happy about this little sleight of hand, so I'll revisit this.
I've reviewed this and I think you're right. I wanted to follow on from the example in the previous section and make it look like it was part of a controller action. And of course dates in params
are strings. So I added the method in.
I'm going to explicitly put the example query in a standalone method. You can easily copy and past that into the Grails console and call it with any arguments you choose. I'll also add a little sidebar somewhere explaining how to run BootStrap.init
in the console.
lol, just realised that I already talk about trying out queries in the console later in the chapter.
Proves it is a pretty good idea :-)
Le 2013-10-14 à 10:45, Peter Ledbrook notifications@github.com a écrit :
lol, just realised that I already talk about trying out queries in the console later in the chapter.
— Reply to this email directly or view it on GitHub.
Next MEAP will have the modified example. Not parseDate()
any more. Should be easier to follow. Thanks for bringing it up.
At end of section 5.2.1, code snippets are using a
parseDate()
method that is not defined in the text. I know there is a paragraph stating not to worry and that its actual implementation is irrelevant, but, if others are like me, they will end up running most (if not all) code snippets in a grails console and the snippets withparseDate()
will fail. Changing them is not terribly difficult, but I fail to see the benefit of having this hypotheticparseDate()
method in there.I would suggest to use
new Date()
(and variants) as it is done in some other snippets in this chapter. I prefer to have code that I can copy/paste in my grails console to experiment as I learn rather than have code that looks like production code (if that was the intent?).Same thing for sub-section "5.3.2 Introducing Criteria queries" where the first fragment use a
parseDate(params.fromDate)
while age "dateCreated", new Date() -1
would do the job, like what is done in the second fragment in that sub-section 5.3.2.