@@ -35,9 +35,10 @@ component
3535 ) {
3636 if ( isSimpleValue ( arguments .column ) && getEntity ().hasAttribute ( arguments .column ) ) {
3737 arguments .value = generateQueryParamStruct (
38- column = arguments .column ,
39- value = isNull ( arguments .value ) ? javacast ( " null" , " " ) : arguments .value ,
40- checkNullValues = false // where's should not be null. `WHERE foo = NULL` will return nothing.
38+ column = arguments .column ,
39+ value = isNull ( arguments .value ) ? javacast ( " null" , " " ) : arguments .value ,
40+ checkNullValues = false , // where's should not be null. `WHERE foo = NULL` will return nothing.
41+ shouldCastValues = true // we are in a where clause, so the casted values will not be persisted to the entity at this time.
4142 );
4243 }
4344 super .whereBasic ( argumentCollection = arguments );
@@ -850,7 +851,8 @@ component
850851 public struct function generateQueryParamStruct (
851852 required string column ,
852853 any value ,
853- boolean checkNullValues = true
854+ boolean checkNullValues = true ,
855+ boolean shouldCastValues = false
854856 ) {
855857 // If that value is already a struct, pass it back unchanged.
856858 if ( ! isNull ( arguments .value ) && getUtils ().isValidQueryParamStruct ( arguments .value ) ) {
@@ -859,15 +861,17 @@ component
859861
860862 if ( arguments .checkNullValues ) {
861863 return {
862- " value" : ( isNull ( arguments .value ) || getEntity ().isNullValue ( arguments .column , arguments .value ) ) ? " " : getEntity ().convertToCastedValue (
863- arguments .column ,
864- arguments .value
864+ " value" : ( isNull ( arguments .value ) || getEntity ().isNullValue ( arguments .column , arguments .value ) ) ? " " : (
865+ arguments .shouldCastValues ? getEntity ().convertToCastedValue ( arguments .column , arguments .value ) : arguments .value
865866 ),
866867 " cfsqltype" : getEntity ().attributeHasSqlType ( arguments .column ) ? getEntity ().retrieveSqlTypeForAttribute (
867868 arguments .column
868869 ) : (
869870 isNull ( arguments .value ) ? " CF_SQL_VARCHAR" : getUtils ().inferSqlType (
870- getEntity ().convertToCastedValue ( arguments .column , arguments .value ),
871+ arguments .shouldCastValues ? getEntity ().convertToCastedValue (
872+ arguments .column ,
873+ arguments .value
874+ ) : arguments .value ,
871875 variables .grammar
872876 )
873877 ),
@@ -886,15 +890,17 @@ component
886890 };
887891 } else {
888892 return {
889- " value" : isNull ( arguments .value ) ? " " : getEntity ().convertToCastedValue (
890- arguments .column ,
891- arguments .value
893+ " value" : isNull ( arguments .value ) ? " " : (
894+ arguments .shouldCastValues ? getEntity ().convertToCastedValue ( arguments .column , arguments .value ) : arguments .value
892895 ),
893896 " cfsqltype" : getEntity ().attributeHasSqlType ( arguments .column ) ? getEntity ().retrieveSqlTypeForAttribute (
894897 arguments .column
895898 ) : (
896899 isNull ( arguments .value ) ? " CF_SQL_VARCHAR" : getUtils ().inferSqlType (
897- getEntity ().convertToCastedValue ( arguments .column , arguments .value ),
900+ arguments .shouldCastValues ? getEntity ().convertToCastedValue (
901+ arguments .column ,
902+ arguments .value
903+ ) : arguments .value ,
898904 variables .grammar
899905 )
900906 ),
0 commit comments