groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas (Jira)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-9295) Sql.checkForNamedParams false positives
Date Wed, 30 Oct 2019 10:50:00 GMT
Andreas created GROOVY-9295:
-------------------------------

             Summary: 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


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}}

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message