I have got the weirdest problem, ever. I am trying...
# lucee
g
I have got the weirdest problem, ever. I am trying to run some SQL via
Copy code
<cfset "ds.results" = new query(
	name = "q",
	datasource = customer.getDataSource(),
	sql = theSQLtoRun).execute().getResult()  />
It throws an error:
The named parameter [00] has not been provided
The only place in the SQL that has "00" in it is in the WHERE clause
Copy code
select xxxxx
WHERE zzzzzzz
AND x.survey_date BETWEEN '2023-06-01 01:00' AND '2023-06-10 23:59'
If I change the start date in the WHERE clause to
'2023-06-01 01:06'
Then the error message changes to:
The named parameter [06] has not been provided
Whatever is in the "minutes" section of the start date, ends up in the error message. Also: I have tried for the past 3 full days to work out how to reproduce it - so that I could put something repeatable into a GIST / tryCF... But I can't get it to fail, outside of where it is in the application code. I dump the contents of
theSQLtoRun
, directly before running the SQL that fails - and it looks completely normal. I copy/paste the SQL in the dump() directly into the DB - and of course, it runs without failing. I am open to any ideas at all.
z
cfqueryparam
: is a placeholder for params
a
But should not be when it's within quotes. I suspect the query runner in Query.cfc is not calling
preserveSingleQuotes
on the passed-in string. But, @gavinbaumanis, why the hell are you using
new Query etc
to run SQL??! It's 2023 mate.
g
Hi Zac, But I am not using any cfqueryparams. is JUST text.
a
Hang on... you're in Aussie. Is it 2023 there too? Or still in the 70s?
z
also you din't mention your lucee version either, so you owe me a beer, new rules :)
šŸ˜€ 1
šŸ‘ 1
g
@Adam Cameron If I am missing something obvious - please let me know - cause I am not seeing it.
5.4.1.8
z
:06 is being parsed as a inline param marker
where lastUpdate :lastUpdated
(or the timestamp) in your case. use params like it's 2023
g
I "get" what it is doing - but if I put the SQL into a CFM file - that is a copy/paste of the SQL - it doesn't "see" it as a parameter placeholder.
a
Yeah @zackster’s advice is misdirection. Your query as it stands ought to work.
:
should not be considered the beginning of a param placeholder if the
:
is within a string, which is it here.
@gavinbaumanis
Query.cfc
was only ever a CF hack to be able to do DB calls from CFScript. Am pretty sure Lucee only includes it for sideways compat, but also seem to recall it was never recommended.
queryExecute
was added to native CFML in CF11 in 2014. That's what you ought to be using.
šŸ‘šŸ¼ 1
g
I'll swap it over and report back - Thanks.
z
what's the stacktrace?
would need test cases for mixed unbound and bound param combos
g
Copy code
lucee.runtime.exp.CustomTypeException: The named parameter [02] has not been provided at lucee.runtime.tag.Throw._doStartTag(Throw.java:212) at lucee.runtime.tag.Throw.doStartTag(Throw.java:201) at throw_cfm$cf.udfCall(/throw.cfm:11) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213) at lucee.runtime.functions.system.CFFunction.call(CFFunction.java:109) at org.lucee.cfml.query_cfc$cf.udfCall(/org/lucee/cfml/Query.cfc:188) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223) at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:786) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775) at org.lucee.cfml.query_cfc$cf.udfCall(/org/lucee/cfml/Query.cfc:103) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223) at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:786) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775) at org.lucee.cfml.query_cfc$cf.udfCall(/org/lucee/cfml/Query.cfc:34) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:664) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:586) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1933) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1775) at scripts.csvextract.au.csvextractau_v4_cfm$cf.call(/dbsetup/scripts/csvExtract/au/csvExtractAU_v4.cfm:2672) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1025) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:948) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:219) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2493) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2478) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2449) at lucee.runtime.engine.Request.exe(Request.java:45) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1216) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1162) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:47) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:67) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at runwar.undertow.SSLClientCertHeaderHandler.handleRequest(SSLClientCertHeaderHandler.java:144) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:275) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:255) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449) at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282) at java.base/java.lang.Thread.run(Unknown Source)
Swapping to queryExecute worked. Thanks @Adam Cameron
šŸ‘ 1
d
@zackster I wonder if it would make sense to migrate Query.cfc over to just use queryExecture() under the hood.
z
yeah, would be good for 6
šŸ’Æ 2
c
Or deprecate query.cfc. Didn't Adobe deprecate the cfc-based query, http and other implementations a few versions back (like CF 2018 or so)?
z
deprecate means they are still there, just not recommended
c
Understood. But Adobe had abandoned development/fixing of those CFCs many years ago (there were a number of bugs reported but never fixed), and finally formally deprecated them. If Lucee hasn't deprecated them (but leaving them in place for backward compatibility), they should be deprecated so that users are not encouraged to use them.
šŸ’Æ 1
z
they aren't actually listed anywhere on the docs i believe? that said people still use them and I'm open for a patch
a
That is just encouraging their use. There is no need to: don't make work for yerself, and don't encourage poor practice. Plus they are in the docs: https://docs.lucee.org/guides/cookbooks/Query-Handling.html#query-component
We're even discussing this in a thread wherein someone was using it, after all.
g
Just about every query in our application is created via
new query
And the ones that aren't - are still in tags.,
z
they all use the cfquery tag underneath, a PR is more than welcome