Should custom casts in Quick be called for NULL database values?

Following this old thread : [Quick 7] Undocumented Breaking Change from 6 to 7 - #4 by rodrigoEscrol

I will paste again here the messages:

Hi. I do have related issues.
I have this : property name="show" column="FotosGrandes" type="boolean" casts="S-NCast";
In the DB its stored as “Y or N” but I want to be a pure boolean on CFML side.
It works ONLY when it’s not null. If its NULL it will be an empty string, and no cast is called. Also, default won’t get respected so default="true" won’t do anything. Only works the default if I add persistent="false"

Any ideas how can I get a pure boolean of a DB null (The cast its made that if I get null, It’s equal to false)??

OTHER MESSAGE Following the request of my CustomCast :

No problem. But the cast is not called in that case:

component implements="quick.models.Casts.CastsAttribute" {

	/**
	 * Devuelve true si el valor en la base de datos es 'S', de lo contrario false.
	 */
	public any function get(
		required entity,
		required string key,
		any value
	){
		if ( isNull( arguments.value ) || trim( arguments.value ) == "" ) {
			return false;
		}
		var val = uCase( trim( arguments.value ) );
		return val == "S";
	}

	/**
	 * Guarda 'S' en la base de datos si el valor es true, y 'N' si es false.
	 */
	public any function set(
		required entity,
		required string key,
		any value
	){
		if ( isNull( arguments.value ) ) {
			return "N";
		}
		if ( isBoolean( arguments.value ) ) {
			return arguments.value ? "S" : "N";
		}
		var val = uCase( trim( arguments.value ) );
		return ( val == "S" ) ? "S" : "N";
	}

}

I do a research on my own:
BaseEntity.cfc :

public any function populateAttributes( struct attributes = {} ) {
		for ( var key in arguments.attributes ) {
			if ( !hasAttribute( key ) ) {
				continue;
			}
			variables._data[ retrieveColumnForAlias( key ) ] = (
				!arguments.attributes.keyExists( key ) || isNull( arguments.attributes[ key ] )
			) ? javacast( "null", "" ) : castValueForGetter( key, arguments.attributes[ key ] );
			variables[ retrieveAliasForColumn( key ) ] = (
				!arguments.attributes.keyExists( key ) || isNull( arguments.attributes[ key ] )
			) ? javacast( "null", "" ) : castValueForGetter( key, arguments.attributes[ key ] );
		}
	}

If it is null it never gets called the cast, which in my opinion is the cast who should be able to decide what null means, no empty string in all cases, which then I have to null check every variable with the cast, but the cast can make this work.

Also in castValueForGetter you will check again for null

Helpfull comment from @DaveL:

I can see the argument for passing null values to casters. Feel free to open up an issue or a PR on the Quick GitHub.

As for default not being respected, that’s more an issue between CFML properties and how null is represented in the CFML Retrieving values from the database brings back null values as empty strings in CFML. That value then overrides the default value that was there when the component was instantiated. I suppose we could detect if a null value was returned (according to Quick’s current semantics) and skip setting properties in that case. Free free to open a ticket or PR for that as well.

Should custom casts in Quick be called for NULL database values? · Issue #275 · coldbox-modules/quick

Open. Also, I do open other 3 tickets 3 weeks ago.

Thanks