Re: [sqlalchemy] Weird error with update

2009-11-25 Thread Ilia Kharin
>
> one advantage of this syntax is that Python will raise an exception that
> last_access does not exist.
>
yes, and it will be seen at first running

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.




Re: [sqlalchemy] Weird error with update

2009-11-23 Thread Mike Conley
> Why not use update({ESMagicNumber.last_access: datetime.datetime.now()}) ?
>
>
> one advantage of this syntax is that Python will raise an exception that
last_access does not exist.

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.




Re: [sqlalchemy] Weird error with update

2009-11-22 Thread akscram litus
>
>  I am able to create the same bad SQL, but only if the key in the update
> dictionary is not a column in the table being updated. Are you sure
> 'last_access' is a valid column in ESMagicNumber?
>

Why not use update(ESMagicNumber.last_access: datetime.datetime.now()) ?

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=.




Re: [sqlalchemy] Weird error with update

2009-11-21 Thread Mariano Mara
Excerpts from Mike Conley's message of Sat Nov 21 03:36:07 -0300 2009:
> On Fri, Nov 20, 2009 at 5:14 PM, Mariano Mara wrote:
> 
> > ... or, at least, is weird for me :)
> > Hi everyone. I'm running a pylons controller
> > with the following instruction:
> >
> >meta.Session.query(ESMagicNumber).filter(
> >ESMagicNumber.uuid==request.params['uuid_']).\
> >update({'last_access':datetime.datetime.now()})
> >
> > but I'm getting the following error:
> >
> > (ProgrammingError) syntax error at or near "WHERE"
> > LINE 1: UPDATE es_magicnumber SET WHERE es_magicnumber.uuid = E'705...
> > ^ 'UPDATE es_magicnumber SET WHERE es_magicnumber.uuid = %(uuid_1)s'
> > {'uuid_1': u'705fa1e6-977f-416a-9847-fe8715cc920a'}
> >
> > I am able to create the same bad SQL, but only if the key in the update
> dictionary is not a column in the table being updated. Are you sure
> 'last_access' is a valid column in ESMagicNumber?
> 
> This is because the SET clause is generated from the update dictionary, and
> if there are no valid columns, there is nothing to generate and the SET
> clause becomes nothing.
> 

I checked that first but turns out I was checking the wrong file :(
Somebody should not work past midnight.

Thank you very much for your answer and sorry for the waste of time.

Mariano

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=.




Re: [sqlalchemy] Weird error with update

2009-11-20 Thread Mike Conley
On Fri, Nov 20, 2009 at 5:14 PM, Mariano Mara wrote:

> ... or, at least, is weird for me :)
> Hi everyone. I'm running a pylons controller
> with the following instruction:
>
>meta.Session.query(ESMagicNumber).filter(
>ESMagicNumber.uuid==request.params['uuid_']).\
>update({'last_access':datetime.datetime.now()})
>
> but I'm getting the following error:
>
> (ProgrammingError) syntax error at or near "WHERE"
> LINE 1: UPDATE es_magicnumber SET WHERE es_magicnumber.uuid = E'705...
> ^ 'UPDATE es_magicnumber SET WHERE es_magicnumber.uuid = %(uuid_1)s'
> {'uuid_1': u'705fa1e6-977f-416a-9847-fe8715cc920a'}
>
> I am able to create the same bad SQL, but only if the key in the update
dictionary is not a column in the table being updated. Are you sure
'last_access' is a valid column in ESMagicNumber?

This is because the SET clause is generated from the update dictionary, and
if there are no valid columns, there is nothing to generate and the SET
clause becomes nothing.

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=.




[sqlalchemy] Weird error with update

2009-11-20 Thread Mariano Mara
... or, at least, is weird for me :)
Hi everyone. I'm running a pylons controller
with the following instruction:

meta.Session.query(ESMagicNumber).filter(
ESMagicNumber.uuid==request.params['uuid_']).\
update({'last_access':datetime.datetime.now()})

but I'm getting the following error:

(ProgrammingError) syntax error at or near "WHERE"
LINE 1: UPDATE es_magicnumber SET WHERE es_magicnumber.uuid = E'705...
^ 'UPDATE es_magicnumber SET WHERE es_magicnumber.uuid = %(uuid_1)s'
{'uuid_1': u'705fa1e6-977f-416a-9847-fe8715cc920a'}

can anyone tell me why the "SET" instruction is being totally ignored?
Did I misunderstand how "update" works?

TIA,
Mariano

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=.