Skip to content

Commit

Permalink
JDBC - Add blockfactor query option alias to fetchsize
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelborn committed May 28, 2024
1 parent 0a404c1 commit 9597034
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/bx/ModuleConfig.bx
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@
// Register SQLType compatibility interceptor
interceptorService.newAndRegister(
// Class path
"#moduleRecord.invocationPath#.interceptors.CFSqlType",
"#moduleRecord.invocationPath#.interceptors.QueryCompat",
// Properties Struct
settings,
// Unique Name
"CFSqlType@compat",
"QueryCompat@compat",
// Module Record
moduleRecord
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import java:ortus.boxlang.runtime.types.immutable.ImmutableStruct;
import java:ortus.boxlang.runtime.scopes.Key;

/**
* Renames `cfsqltype` to `sqltype` in the query parameters for improved CFML compatibility.
* Improves queryExecute() and Query component compatibility with CFML syntax and options.
*
* <ul>
* <li>Alias `cfsqltype` to `sqltype` in the query parameters</li>
* <li>Adds `blockfactor` to `fetchsize` in the query options.</li>
* </ul>
*/
class{

Expand All @@ -35,14 +40,21 @@ class{
* - sql : The SQL string
* - parameters : The parameters to be used in the query
* - pendingQuery : The BoxLang query class used to build and execute queries
* - options : A struct of query options, if any, set at query time via `queryExecute()` or `<bx:query>`
*/
function onQueryBuild( struct data ){
// Add coldfusion struct
data.parameters.map( ( param ) -> {
if( param.keyExists( "cfsqltype" ) ){
if( param.keyExists( "cfsqltype" ) && !param.keyExists( "sqltype" ) ){
param.sqltype = param.cfsqltype;
}
});

// add blockfactor -> fetchsize alias
data.options.map( ( param ) -> {
if( param.keyExists( "blockfactor" ) && !param.keyExists( "fetchSize" ) ){
param.fetchSize = param.blockfactor;
}
});
}

}

0 comments on commit 9597034

Please sign in to comment.