can't cast empty string to a number value with cf_sql_decimal and null=true

Description

cfqueryparam null=true does not ignore the value attribute for cfsqltype="cf_sql_decimal".

The code below will result in the following error:

lucee.runtime.exp.CasterException: can't cast empty string to a number value at lucee.runtime.op.Caster.toDoubleValue(Caster.java:448) at lucee.runtime.op.Caster.toDoubleValue(Caster.java:396) at lucee.runtime.op.Caster.toDecimal(Caster.java:827) at lucee.runtime.tag.QueryParam.check(QueryParam.java:236) at lucee.runtime.tag.QueryParam.doStartTag(QueryParam.java:214)

<cfquery datasource="yourMSSQLServerDSN"> DECLARE @pleaseFix TABLE ( dessy decimal(15,2) ) INSERT INTO @pleaseFix ( dessy ) VALUES ( <cfqueryparam cfsqltype="cf_sql_decimal" null="true" value="" maxlength="15" scale="2"> ) </cfquery>

 

This code works in ACF, and it actually works for other sql types in Lucee, but it does not work for cf_sql_decimal. This code should insert a NULL and ignore the fact that the value is not a number. A workaround for this is to use cf_sql_numeric vs. cf_sql_decimal, but I am not sure what implications that may have.

 

Here is an old Railo ticket that is similar to this issue:

https://issues.redhat.com/browse/RAILO-494?page=com.atlassian.jirafisheyeplugin%3Afisheye-issuepanel

Environment

None

Activity

Show:

Pothys - MitrahSoft 27 October 2020 at 10:55
Edited

I've checked this ticket and confirmed the issue happened on lucee latest version 5.3.8.90-SNAPSHOT also. While using null value with cfsqltype = cf_sql_decimal with null=true throws an exception "can't cast empty string to a number value". But in ACF works fine with a null value.

Pull Request: https://github.com/lucee/Lucee/pull/1094

Details

Assignee

Reporter

Priority

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

Affects versions

Created 23 October 2020 at 15:06
Updated 4 December 2020 at 13:03

Flag notifications