gavinbaumanis
06/29/2023, 12:57 AMSELECT
random_string AS customersMetricName
A customer has entered a lot of metric names that contain full colins ":".
• Group:attribute1
• Group:attribute2
• ...
So the dynamically produced SQL string looks like;
SELECT
random_string AS Group:attribute1
FROM ....
As a consequence using cfquery fails because it goes looking for a query parameter called "attribute1"
The named parameter [attribute1] has not been provided
The Error Occurred in
/org/lucee/cfml/Query.cfc: line 188
called from /org/lucee/cfml/Query.cfc: line 103
called from /org/lucee/cfml/Query.cfc: line 34
called from xxxxxx
I tried "back - ticking", "`" and double-quoting and single quoting the column name - but get the same error in the application.
SELECT
random_string AS `Group:attribute1`
FROM ....
When using the SQL directly on the database (MariaDB) - it works without error.
(irrespective of the quotes / back-ticks usage)
Short of "Don't allows users to have values with ':'s in values that are used as column names"...
Any thoughts on how I might get this to work?
Thanks!gavinbaumanis
06/29/2023, 1:46 AMzackster
06/29/2023, 5:39 AMgavinbaumanis
06/29/2023, 5:40 AMgavinbaumanis
06/29/2023, 5:43 AMzackster
06/29/2023, 6:58 AMzackster
06/29/2023, 7:17 AMRodney
06/29/2023, 11:58 AMRodney
06/29/2023, 12:00 PMgavinbaumanis
06/29/2023, 11:21 PMgavinbaumanis
06/29/2023, 11:31 PMgert
07/08/2023, 7:25 AMgert
07/08/2023, 7:26 AMgert
07/08/2023, 7:26 AMgert
07/08/2023, 7:28 AM<cfscript>
listener={
before= function (caller,args) {
dump(label:"before",var:arguments);
args.sql&=" where Tables_in_test<>'test'"
return arguments;
},
after= function (caller,args,result,meta) {
dump(label:"after",var:arguments);
var colName="table_name_lower_case";
queryAddColumn(arguments.result,colName);
loop query=result {
result["table_name_lower_case"]=lCase(result["Tables_in_test"]);
}
return arguments;
}
}
</cfscript>
<!--- custom listener --->
<cfquery name="qry" datasource="mysql" listener="#listener#">
show tables
</cfquery>
<cfdump var="#qry#">