small gotcha: columns named "request"

9 views
Skip to first unread message

Nathan Dintenfass

unread,
Feb 25, 2012, 2:18:30 AM2/25/12
to framew...@googlegroups.com
Just thought I'd share a small gotcha I ran into working with a database
table with a column called "request" and trying to use buildURL() while
looping through a query from that table -- since the underlying buildURL
code (along with a handful of other FW/1 methods) has "structKeyExists(
request ...." it threw the exception:

You have attempted to dereference a scalar variable of type class
java.lang.String as a structure with members.

Once I figured out what the problem was it was fairly easy to work
around by aliasing the query column,

I don't think I'll submit a ticket, as this is a very rare scenario, but
I figured I'd point this out as a lesson learned (of course, having a
query column named the same as a ColdFusion scope is just generally a
bad idea).

The work-around would likely be to change the "structKeyExists( request"
to isDefined("request.... within the framework, but again: I'm not
advocating that change.

- Nathan D


AJ Mercer

unread,
Feb 25, 2012, 8:15:12 AM2/25/12
to framew...@googlegroups.com
do you get an error if you scope your request field with the query name?
eg qry.request


Nathan Dintenfass

unread,
Feb 25, 2012, 1:18:28 PM2/25/12
to framew...@googlegroups.com
The error is thrown INSIDE the framework, so scoping my variables
wouldn't help. I managed to just get the database itself changed in
this case.

After so many years involved with CFML apps I guess this is the first
time coming across a column named the same as a scope.

On 2/25/12 5:15 AM, AJ Mercer wrote:
> do you get an error if you scope your request field with the query name?
> eg qry.request
>
>
> On 25 February 2012 15:18, Nathan Dintenfass <nat...@dintenfass.com

> <mailto:nat...@dintenfass.com>> wrote:
>
> Just thought I'd share a small gotcha I ran into working with a
> database table with a column called "request" and trying to use
> buildURL() while looping through a query from that table -- since
> the underlying buildURL code (along with a handful of other FW/1
> methods) has "structKeyExists( request ...." it threw the exception:
>
> You have attempted to dereference a scalar variable of type class
> java.lang.String as a structure with members.
>
> Once I figured out what the problem was it was fairly easy to work
> around by aliasing the query column,
>
> I don't think I'll submit a ticket, as this is a very rare scenario,
> but I figured I'd point this out as a lesson learned (of course,
> having a query column named the same as a ColdFusion scope is just
> generally a bad idea).
>
> The work-around would likely be to change the "structKeyExists(
> request" to isDefined("request.... within the framework, but again:
> I'm not advocating that change.
>
> - Nathan D
>
>
> --
> FW/1 on RIAForge: http://fw1.riaforge.org/
>

> FW/1 on github: http://github.com/__seancorfield/fw1


> <http://github.com/seancorfield/fw1>
>
> FW/1 on Google Groups:

> http://groups.google.com/__group/framework-one
> <http://groups.google.com/group/framework-one>
>
>
>
>
> --
>
> *AJ Mercer*
> <webonix:net strength="Industrial" /> <http://webonix.net> |
> <webonix:org community="Open" /> <http://webonix.org>
> http://twitter.com/webonix
> Railo Community Manager <http://www.getrailo.org/index.cfm/community/team/>

Sean Corfield

unread,
Feb 26, 2012, 2:10:26 PM2/26/12
to framew...@googlegroups.com
This is on ACF I assume? I'm surprised that code compiled outside the context of a query could possibly select a column name over a scope. I'd consider that a bug. 

Railo always treats scope names as scopes (so qry.request would be _required_ in your own code and FW/1 would "just work" because request is always the Request Scope).

Sean


--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Nathan Dintenfass

unread,
Feb 26, 2012, 2:37:13 PM2/26/12
to framew...@googlegroups.com
Yes, ACF 9.01 (OS X).

I suspect this is left over from the VERY old days (even back to
DBQUERY/DBOUTPUT) where query scope while outputting was always given
precedence in lookups.

> FW/1 on github: http://github.com/____seancorfield/fw1
> <http://github.com/__seancorfield/fw1>

> http://groups.google.com/____group/framework-one
> <http://groups.google.com/__group/framework-one>


> <http://groups.google.com/__group/framework-one
> <http://groups.google.com/group/framework-one>>
>
>
>
>
> --
>
> *AJ Mercer*
> <webonix:net strength="Industrial" /> <http://webonix.net> |
> <webonix:org community="Open" /> <http://webonix.org>
> http://twitter.com/webonix
> Railo Community Manager

> <http://www.getrailo.org/__index.cfm/community/team/

> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>

Reply all
Reply to author
Forward
0 new messages