Dan MacNeil
12/30/2023, 4:04 PM<cfquery name="url_as_object" datasource="admin_console">
SELECT url FROM content WHERE ROWNUM <= 1
</cfquery>
<cfset my_str="a string">
<cfloop query="url_as_object">
<cfoutput>
<pre>
expected data for url: #getMetadata(my_str)#
actual meta data for url: #getMetadata(url)#
</pre>
</cfoutput>
</cfloop>
OUTPUT:
expected data for url: class java.lang.String
actual meta data for url: class lucee.runtime.type.scope.URLImpl
OS: ubuntu 22.04n
Java Version: OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
Tomcat Version: 9.0.58-1ubuntu0.1
Lucee Version: 5.4.4.38Adam Cameron
URL is a scope, so also using it as an unqualified column reference in a query loop is less than ideal code to start with. And am not at all surprised that when you reference url that Lucee goes "that'll be the URL scope, right? Because... like... that's most likely what people will expect".
So I think you should not raise a ticket in Jira, you should make yer code clearer.
Maybe the documentation for how names are resolved to values could stand some improvement too, to take in the context where a name is the same as another name Lucee already uses.Adam Cameron
alexpixl8
12/30/2023, 5:35 PMAdam Cameron
url_as_object.url would solve the problem.
@alexpixl8 are you sure that it should resolve to the unqualified query column first? That would mean it would completely shadow the URL scope, which is less than idea. I think in the case of scope names (and just scope names, not "variables in scopes), it should resolve the scope first and foremost. Like it is.
But whichever case it "should be", I think the userland code should not try to shadow the scope. It's unclear code, and - as demonstrated - the behaviour is not necessarily "predictable". Best to avoid code like this.alexpixl8
12/30/2023, 6:01 PMAdam Cameron
bdw429s
12/30/2023, 6:51 PMalexpixl8
12/30/2023, 6:53 PMAdam Cameron
bdw429s
12/30/2023, 7:19 PMquetwo
12/30/2023, 10:46 PMbdw429s
12/31/2023, 4:15 AMquetwo
01/01/2024, 10:21 PM