.update_or_insert() does in fact do an initial query to retrieve the first record that matches, so presumably it could just return the id of that record rather than returning None. The problem, though, is that you would then have no way of knowing whether it had done an update or an insert. A better option might be for it to return the entire record in case of an update -- then you can distinguish between an insert (which returns and id) and an update (which returns a record). However, that might create backward compatibility problems in cases where a test for any return value is used to distinguish insert from update. To get around that, perhaps we could add an argument to explicitly request the record:
db.mytable.update_or_insert(_return_record=True, name='Bob', city='Chicago') _return_record would default to False to preserve backward compatibility. Anthony On Tuesday, May 21, 2013 11:26:27 AM UTC-4, Robin Manoli wrote: > > I mean before doing the update, how does web2py know if there is a record > to update? I mean to get the id from there. > > Den tisdagen den 21:e maj 2013 kl. 17:04:40 UTC+2 skrev Niphlod: >> >> >> >> Il giorno martedì 21 maggio 2013 16:42:46 UTC+2, Robin Manoli ha scritto: >>> >>> is it really another query? isn't there already a query to see if there >>> is a post to update? >> >> >> come up with a SQL syntax that returns the PK of updated records and >> we'll try it. I'm pretty sure there isn't any but I'm open to possible >> implementations. >> >> >> > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

