Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.8.2, 1.8.6, 2.0-beta-3
-
Component/s: SQL processing
-
Labels:None
-
Number of attachments :
Description
Postgres supports a casting syntax like "SELECT '2011-01-01'::date". I recently wrote a query like: "SELECT * FROM table WHERE my_date BETWEEN ?-'1 week'::interval AND ?" and was surprised to receive strange errors about java.sql.Date not supporting the "interval" property. It would appear that the regex parsing that identifies named parameters is a bit broken in this instance.
In groovy.sql.Sql changing:
to:
should fix this problem. It matches:
but not:
It does not cover the case when something that looks like a named parameter is contained in a string e.g:
This case is probably hard to cover in a regex as it must check that it is not a named parameter surrounded by strings e.g.:
So while this is not a perfect solution it adds functionality without removing any (as far as I can tell).