How pass send empty char strings to the database?

Is there any way to send an empty string to a DB table column? We are doing an ACF11 → Lucee 5.4 conversion and I have just come up against this issue.
Lucee is throwing an error because the table column doesn’t support NULLs. In ACF, it would happily INSERT an empty string.

Rather than having to enable something, at the server level, only, maybe we could also have a way of setting it at a Query level.

We could use an attribute in both:

cfqueryparam 
cfprocparam

Like:

allowEmptyStrings = true [false by default]

Or you could have a setting in the Server Admin that allows NULL behaviour to be altered for Queries, independently.

Query: allow empty strings:  true/false

We already made a breaking change in Lucee 6 to match ACF behaviour

LDEV-4410 stop queryparam casting empty strings to nulls

what datatype is the queryparam?

varchar never had this auto casting to null?

other types like numeric did

but no longer in 6

@Charlesr please don’t cross post on both Jira ticket and the mailing list, and don’t mix unrelated topics

All discussion, triage etc should happen on here first

just drop the urls for the tickets or posts into a new thread. I am going to split this topic out and delete your comments on the ticket

1 Like

It is:

cfprocparam

CHAR

Any empty string is sent as a NULL to the DB, which causes an error, because we have this column set to ALLOW NULL = false

UPDATE:

I have set it to VARCHAR and everything works as expected. Thanks for the explanation.
I am not sure whether the way the CHAR type is handled, is correct or not?

yeah, char is a strange old beast

null is a very generic topic! cfparam only shares a name with with cfquery/proc param.

ok, I have confirmed locally (with mysql), please file a bug

1 Like

Is that a comment:

// if(str!=null && str.length()==0) str=null;

In

case Types.CHAR:
String str = Caster.toString(value);
// if(str!=null && str.length()==0) str=null;
stat.setObject(parameterIndex, str, type);
//// stat.setString(parameterIndex,str);

Telling us what will happen to a CHAR? I can’t tell? Or is it actual code that was commented out and just left there? If it is just a description, then I guess we have the reason, why it is being passed as NULL?

Anyway, I will file a bug for this…

file the bug, i already have a fix and test case coverage

fix in 6.0.0.517 and 5.4.2.13

if you don’t already, please consider supporting us!

1 Like

Hi Zac

I tried to become a monthly contributor, and I want to pay by PayPal, but the payment button just keeps animating with no action.

I cannot get to the next page.

I am using the latest version of Safari on my iPhone 8+ iOS16.5.1

As soon as this is fixed I will sign up again. :slightly_smiling_face: