From f4bcedd29689224f7447dfa009ca177343739501 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Thu, 21 May 2026 11:58:22 +0200 Subject: [PATCH 1/2] Remove redundant check --- models/BaseEntity.cfc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/models/BaseEntity.cfc b/models/BaseEntity.cfc index c5f8736..99c30c6 100644 --- a/models/BaseEntity.cfc +++ b/models/BaseEntity.cfc @@ -616,12 +616,13 @@ component accessors="true" { 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 ] ); + + var value = isNull( arguments.attributes[ key ] ) + ? javacast( "null", "" ) + : castValueForGetter( key, arguments.attributes[ key ] ); + + variables._data[ retrieveColumnForAlias( key ) ] = value; + variables[ retrieveAliasForColumn( key ) ] = value; } } From 5ae2c926fef3b565c943a38d5fd0c2c9608e2901 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Thu, 21 May 2026 12:41:01 +0200 Subject: [PATCH 2/2] castValueForGetter returns the value if no cast exists; else the cast is responsible for handling the value, even null ones --- models/BaseEntity.cfc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/models/BaseEntity.cfc b/models/BaseEntity.cfc index 99c30c6..83fb1ec 100644 --- a/models/BaseEntity.cfc +++ b/models/BaseEntity.cfc @@ -617,9 +617,7 @@ component accessors="true" { continue; } - var value = isNull( arguments.attributes[ key ] ) - ? javacast( "null", "" ) - : castValueForGetter( key, arguments.attributes[ key ] ); + var value = castValueForGetter( key, arguments.attributes[ key ] ); variables._data[ retrieveColumnForAlias( key ) ] = value; variables[ retrieveAliasForColumn( key ) ] = value; @@ -3456,10 +3454,6 @@ component accessors="true" { return arguments.value; } - if ( !isVirtualAttribute( arguments.key ) && isNullValue( arguments.key, arguments.value ) ) { - return arguments.value; - } - var castMapping = variables._casts[ arguments.key ]; if ( !variables._casterCache.keyExists( arguments.key ) ) { variables._casterCache[ arguments.key ] = variables._wirebox.getInstance( dsl = castMapping );