Allow to pass an array as value to cfqueryparam

Description

cfqueryparam can accept the attribute list=true with separator="," which will take a csv list and use it as needed (e.g. wrap each value with 'single-quotes' etc.)

It'd be very useful to be able instead to pass an array, so that the following snippets are equivalent:

currently:

params={ values="1, 2, 3", list="true", separator=",", sqltype="integer" }

proposed:

params={ values=[1, 2, 3], sqltype="integer" }

Activity

Show:

Zac Spitzer 28 February 2022 at 10:47
Edited

Julian Halliwell 31 October 2017 at 21:43

Thanks Igal. Nice to have both options.

Igal Sapir 31 October 2017 at 18:23
Edited

Issue is fixed for cfqueryparam in 5.2.6.13

<cfset arrayOfNumbers = [ 1, 2, 3, 4, 5 ]> <cfquery name="qTestArray"> SELECT * FROM null_test WHERE nullable_int IN ( <cfqueryparam value="#arrayOfNumbers#" sqltype="integer" > ) </cfquery> <cfdump var="#qTestArray#">

Igal Sapir 31 October 2017 at 18:10

I found the issue. I will fix it.

Igal Sapir 31 October 2017 at 17:39

Hmm... It works in the script format of cfquery:

arrayOfNumbers = [ 1 , 2 , 3 , 4 , 5, 6, 7 ]; query name="q4" params={ myNumbers: {value:arrayOfNumbers, sqltype:"integer"} } { echo(" SELECT * FROM null_test WHERE nullable_int IN ( :myNumbers ) "); } dump(q4);

Not sure why it fails in the tag format. Please open a separate ticket for that if you can't get it to work. Thanks.

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Priority

Created 15 June 2017 at 20:31
Updated 28 February 2022 at 10:48
Resolved 25 August 2017 at 21:17

Flag notifications