Skip to content

Commit

Permalink
fix(SqlCommenter): Fix bug in new BindingsCommenter
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Apr 19, 2024
1 parent 941daf3 commit ce3fd63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion models/SQLCommenter/ColdBoxSQLCommenter.cfc
@@ -1,4 +1,4 @@
component extends="SQLCommenter" singleton {
component extends="SQLCommenter" singleton accessors="true" {

/**
* All the qb module settings so we can inspect the sqlCommenter settings.
Expand Down Expand Up @@ -54,6 +54,7 @@ component extends="SQLCommenter" singleton {
),
true
);
return acc;
}, {} );

return appendCommentsToSQL( arguments.sql, comments );
Expand Down
9 changes: 5 additions & 4 deletions models/SQLCommenter/Commenters/BindingsCommenter.cfc
@@ -1,5 +1,6 @@
component singleton accessors="true" {

property name="queryUtil" inject="QueryUtils@qb";
property name="properties";

/**
Expand All @@ -15,17 +16,17 @@ component singleton accessors="true" {
}

private string function serializeBindings( required array bindings, string delimiter = ";" ) {
return bindings
.map( function( binding ) {
return serializeJSON(
bindings.map( ( binding ) => {
return limitString(
str = castAsSqlType(
str = variables.queryUtil.castAsSqlType(
value = binding.null ? javacast( "null", "" ) : binding.value,
sqltype = binding.cfsqltype
),
limit = 100
);
} )
.toList( delimiter );
);
}

private string function limitString( required string str, required numeric limit, string end = "..." ) {
Expand Down

0 comments on commit ce3fd63

Please sign in to comment.