Passing invalid column names to selectBy doesn't break

Bug #681870 reported by Julian Edwards
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Storm
New
Undecided
Unassigned

Bug Description

For the SQLObject compatibility layer - if I pass a bogus column name as one of the args to selectBy it just returns an empty result set. I'd really expect it to throw an exception so we can catch typos.

Revision history for this message
James Henstridge (jamesh) wrote :

The keyword arguments to selectBy() are converted to the where clause with:

        for key, value in self._by.items():
            args.append(getattr(self._cls, key) == value)

So you should get an AttributeError if you make a typo, unless the incorrect attribute name actually exists on the class. Perhaps that is what you observed?

Revision history for this message
Julian Edwards (julian-edwards) wrote : Re: [Bug 681870] Re: Passing invalid column names to selectBy doesn't break

On Tuesday 04 January 2011 10:02:34 you wrote:
> The keyword arguments to selectBy() are converted to the where clause
> with:
>
>
> for key, value in self._by.items():
> args.append(getattr(self._cls, key) == value)
>
> So you should get an AttributeError if you make a typo, unless the
> incorrect attribute name actually exists on the class. Perhaps that is
> what you observed?

I don't remember exactly what the args were now, sorry :/

It's still a bug though, isn't it? The 'getattr' should surely be something
that looks up column names instead.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.