The User object 'name' field

1 view
Skip to first unread message

Clarke Bishop

unread,
Mar 9, 2010, 1:16:22 PM3/9/10
to spla...@googlegroups.com

I just posted an issue for this:

http://github.com/russjohnson/SplashCMS/issues/issue/46

 

There is a conflict with the 'name' field in the user object.

If you dump the user object, you'll see the name field, but it contains the value of the 'username'. I think there must be a conflict in Wheels where it gets confused. If you rename the 'name' field to 'fullname' the problem goes away.

Another place you can see this in action is on the Users/Edit screen in the admin. It doesn't pull in the 'name' information, but instead pulls the 'username'.

What do you guys think about change ‘name’ to ‘fullname’ everywhere in Splash?

 

Office: 770-642-1353
eMail: cbi...@resultantsys.com

 

raulriera

unread,
Mar 9, 2010, 1:24:04 PM3/9/10
to Splash CMS
Yes,

This may be a conflict with something unscoped on Wheels... I am
pretty sure it should be conflicting with arguments.name in models or
something... can you log this into cfwheels issue page as well?

> eMail: cbis...@resultantsys.com

Chris Peters

unread,
Mar 9, 2010, 1:40:10 PM3/9/10
to spla...@googlegroups.com
When there are naming collisions, Wheels appends the children column names with the included table's name. This isn't a bug.

So in your mind, look at username as userName. It's the "name" field of the "user" table.

To override this behavior, you can always use the select argument to select the column names that you want.

Clarke Bishop

unread,
Mar 9, 2010, 2:38:38 PM3/9/10
to spla...@googlegroups.com

In this case, there are two fields in the user table:

username

name

 

When Wheels retrieves the data, both fields contain the same data which is pulled from the username field.

 

I did try author(select=’name’) and that worked! So that give me a workaround for now.

 

In the Admin, the User-Edit function isn’t working right either due to the same problem. So, I think this is a Splash bug, and not a Wheels bug. Right?

 

   Clarke

Russ Johnson

unread,
Mar 11, 2010, 12:39:22 PM3/11/10
to spla...@googlegroups.com
I have been noticing this myself and even spent some time trying to figure out why but just started to ignore it after awhile... I think now that I understand the problem so I will look at a code fix for it shortly..

- Russ

Doug Giles

unread,
Mar 11, 2010, 10:00:50 PM3/11/10
to Splash CMS
I had this identical problem in a Wheels app recently with a user
object that had 'name' and 'username' properties. I worked around the
problem by splitting my name column into firstName and lastName.

If I remember correctly, the code that was responsible is in the
$initModelObject method in wheels/model/crud.cfm. When it converts a
query row into an object, it can populate the value of one property
with the value of another. Here's the code (I hope it doesn't wrap
too poorly):

if (ListFindNoCase(arguments.properties.columnList, arguments.name
& loc.iItem))
this[loc.iItem] = arguments.properties[arguments.name &
loc.iItem][arguments.row];
else if (ListFindNoCase(arguments.properties.columnList,
loc.iItem))
this[loc.iItem] = arguments.properties[loc.iItem]
[arguments.row];

The first 'if' statement concatenates the name of the model and the
property name, so it will assign the value of 'username' to the 'name'
property.

This seems like a problem, because an object returned by findByKey()
won't necessarily contain the same values in a one-row query result
from findAllByXXX().

-Doug

On Mar 11, 12:39 pm, Russ Johnson <russ.cfco...@gmail.com> wrote:
> I have been noticing this myself and even spent some time trying to figure out why but just started to ignore it after awhile... I think now that I understand the problem so I will look at a code fix for it shortly..
>
> - Russ
>
> On Mar 9, 2010, at 2:38 PM, Clarke Bishop wrote:
>
> > In this case, there are two fields in the user table:
> > username
> > name
>
> > When Wheels retrieves the data, both fields contain the same data which is pulled from the username field.
>
> > I did try author(select=’name’) and that worked! So that give me a workaround for now.
>
> > In the Admin, the User-Edit function isn’t working right either due to the same problem. So, I think this is a Splash bug, and not a Wheels bug. Right?
>
> >    Clarke
>
> > From: spla...@googlegroups.com [mailto:spla...@googlegroups.com] On Behalf Of Chris Peters
> > Sent: Tuesday, March 09, 2010 1:40 PM
> > To: spla...@googlegroups.com
> > Subject: Re: [splashcms] Re: The User object 'name' field
>
> > When there are naming collisions, Wheels appends the children column names with the included table's name. This isn't a bug.
>
> > So in your mind, look at username as userName. It's the "name" field of the "user" table.
>
> > To override this behavior, you can always use the select argument to select the column names that you want.
>

raulriera

unread,
Mar 12, 2010, 12:07:17 AM3/12/10
to Splash CMS
Doug,

This may be a flaw in Wheels or a bug that we need to submit. With
your firstName and lastName setup you can get around a little more by
adding the following line of code into your init() function of your
User model

<cfset property(name="fullName", sql="CONCAT(firstName, ' ',
lastName)")>

That line will enable you the fullName property in your finder methods
(findAll,findOne,etc)

Doug Giles

unread,
Mar 12, 2010, 12:18:40 AM3/12/10
to Splash CMS
Hey Raul,

I'll do that ... thanks!

Russ Johnson

unread,
Mar 12, 2010, 1:10:57 AM3/12/10
to spla...@googlegroups.com
You know, the more I look at this, the more I think it is a bug in Wheels... if you dump session.currentUser the value of the name attribute is the same as the username attribute... this is odd behavior considering its all coming from a single table. There shouldnt be any naming collisions in this instance.
Reply all
Reply to author
Forward
0 new messages