Skip to content

Commit

Permalink
chore(tests): Update tests for new autoDeriveNumericType default
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Feb 6, 2023
1 parent 250626f commit 0341edb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
12 changes: 1 addition & 11 deletions tests/specs/Query/Abstract/BuilderGetSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ component extends="testbox.system.BaseSpec" {
expect( binding.cfsqltype ).toBe( "cf_sql_varchar" );
var binding = bindings[ 2 ];
expect( binding.value ).toBe( 10 );
if ( isACF2016() ) {
expect( binding.cfsqltype ).toBe( "cf_sql_varchar" );
} else {
expect( binding.cfsqltype ).toBe( "cf_sql_numeric" );
}
expect( binding.cfsqltype ).toBe( "CF_SQL_INTEGER" );
} );

it( "retreives a map of bindings", function() {
Expand All @@ -56,10 +52,4 @@ component extends="testbox.system.BaseSpec" {
} );
}

private boolean function isACF2016() {
return server.keyExists( "coldfusion" ) &&
!server.keyExists( "lucee" ) &&
left( server.coldfusion.productversion, 4 ) == "2016";
}

}
10 changes: 5 additions & 5 deletions tests/specs/Query/Abstract/QueryUtilsSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ component displayname="QueryUtilsSpec" extends="testbox.system.BaseSpec" {

describe( "numbers", function() {
it( "integers", function() {
expect( utils.inferSqlType( 100 ) ).toBe( "CF_SQL_NUMERIC" );
variables.utils.setAutoDeriveNumericType( true );
expect( utils.inferSqlType( 100 ) ).toBe( "CF_SQL_INTEGER" );
variables.utils.setAutoDeriveNumericType( false );
expect( utils.inferSqlType( 100 ) ).toBe( "CF_SQL_NUMERIC" );
variables.utils.setAutoDeriveNumericType( true );
} );

it( "decimals", function() {
expect( utils.inferSqlType( 4.50 ) ).toBe( "CF_SQL_NUMERIC" );
variables.utils.setAutoDeriveNumericType( true );
expect( utils.inferSqlType( 4.50 ) ).toBe( "CF_SQL_DECIMAL" );
variables.utils.setAutoDeriveNumericType( false );
expect( utils.inferSqlType( 4.50 ) ).toBe( "CF_SQL_NUMERIC" );
variables.utils.setAutoDeriveNumericType( true );
} );
} );

Expand Down Expand Up @@ -58,7 +58,7 @@ component displayname="QueryUtilsSpec" extends="testbox.system.BaseSpec" {

describe( "it infers the sql type from the members of an array", function() {
it( "if all the members of the array are the same", function() {
expect( utils.inferSqlType( [ 1, 2 ] ) ).toBe( "CF_SQL_NUMERIC" );
expect( utils.inferSqlType( [ 1, 2 ] ) ).toBe( "CF_SQL_INTEGER" );
} );

it( "but defaults to CF_SQL_VARCHAR if they are different", function() {
Expand Down

0 comments on commit 0341edb

Please sign in to comment.