Title:
<cfqueryparam cfsqltype="cf_sql_integer" list="true" value=""> is coercing to 0
| View in TrackerStatus/Resolution/Reason: Closed/Withdrawn/AsDesigned
Reporter/Name(from Bugbase): Alexandre Potvin Latreille / Alexandre Potvin Latreille (Alexandre Potvin Latreille)
Created: 06/08/2016
Components: Database
Versions: 11.0
Failure Type: Incorrect w/Workaround
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Normal / All users will encounter
Locale/System: English / Win 2008 Server
Vote Count: 0
Problem Description:
<cfqueryparam type="cf_sql_integer" list="true" value=""> is getting coerced to the value 0.
Steps to Reproduce:
Assuming your SQL server engine supports this construct (here we use SQL Server 2008):
<cfquery name="q" datasource="someDsn">
SELECT CASE
WHEN 0 IN (<cfqueryparam cfsqltype="cf_sql_integer" list="true" value="">)
THEN 1
ELSE 0
END AS result
</cfquery>
<cfoutput>#q.result#</cfoutput>
Actual Result: The output will be 1.
Expected Result:
The list should be left blank which will result in the SQL predicate 'IN ()'. The SQL engine may throw an exception if it doesn't support empty sets like most implementations.
It would be up to the developer to correctly handle cases where a list may be empty, but CF shouldn't silently coerce an empty list to 0 as this may lead to unpredictable behaviors.
Any Workarounds: Handle empty lists explicitly in a way that is suitable for the use case.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4162304
Reason: PRHaveInfo
External Customer Info:
External Company:
External Customer Name: Alexandre Potvin Latreille
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: