[
https://issues.apache.org/jira/browse/GROOVY-9295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King updated GROOVY-9295:
------------------------------
Description:
The public function {{checkForNamedParams}} (used in getPreparedStatement)
detects named parameters with a regex via
{{ExtractIndexAndSql.hasNamedParameters}}.
This regex matches not only named params (:xxx) but also sql casts
('xxx'::text) which in turn results in sql errrs when called with
{code:groovy}
sql.eachRow(query, args, closure)
{code}
when
# query includes a cast but no named parameters and
# args contains Map with named parameters
Test case:
{code:groovy}
sql.eachRow("select 1,2,3::text", ["a": "b"], { row -> println row as String})
{code}
error when sql points to postgres: no hstore extension installed
was:
The public function
{{checkForNamedParams }}
(used in getPreparedStatement) detects named parameters with a regex via
{{ExtractIndexAndSql.hasNamedParameters}}
{{This regex matches not only named params (:xxx) but also sql casts
('xxx'::text) which in turn results in sql errrs when called with}}
{{sql.eachRow(query, args, closure)}}
{{when }}
{{a. query includes a cast but no named parameters and }}
{{b. args contains Map with named parameters}}
{{Test case:}}
{{sql.eachRow("select 1,2,3::text", ["a": "b"], {}}{{{ row -> println row as
String})}}
{{error when sql points to postgres: no hstore extension installed}}
> Sql.checkForNamedParams false positives
> ---------------------------------------
>
> Key: GROOVY-9295
> URL: https://issues.apache.org/jira/browse/GROOVY-9295
> Project: Groovy
> Issue Type: Bug
> Components: SQL processing
> Affects Versions: 2.4.15
> Environment: Grails 3.2.4
> Reporter: Andreas
> Assignee: Paul King
> Priority: Major
>
> The public function {{checkForNamedParams}} (used in getPreparedStatement)
> detects named parameters with a regex via
> {{ExtractIndexAndSql.hasNamedParameters}}.
> This regex matches not only named params (:xxx) but also sql casts
> ('xxx'::text) which in turn results in sql errrs when called with
> {code:groovy}
> sql.eachRow(query, args, closure)
> {code}
> when
> # query includes a cast but no named parameters and
> # args contains Map with named parameters
> Test case:
> {code:groovy}
> sql.eachRow("select 1,2,3::text", ["a": "b"], { row -> println row as String})
> {code}
> error when sql points to postgres: no hstore extension installed
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)