that would require another query (no thanks!). No database on an update 
gives you back the ids of the records you updated, just the number of rows.

Suppose you did db.update_or_insert(condition, values)

If you are in the need just db(condition).select(table.id) after that.

On Tuesday, October 23, 2012 3:15:44 AM UTC+2, Adi wrote:
>
> Stumbled upon the same thing.
>
> Understood that possibly results could  have more ids when key is 
> different from primary key, e.g (name=='john'), but would it be possible to 
> return an additional parameter with update id(s), if they are known? 
>
> return newid, updateids
>
>
> On Friday, December 30, 2011 12:31:37 PM UTC-5, olivier wrote:
>>
>> The "insert" method returns the id of the inserted row. 
>> The "update_or_insert" method returns the id of the inserted row, but 
>> returns None in case of an update... 
>>
>> Why is it so? 
>>
>> I have a case in which I want to update_or_insert and then further 
>> update the corresponding row (to track the status of a long running 
>> process). 
>> I would rather have the method to always output the id of the updated/ 
>> inserted row... 
>> Or is there any use-case you would like to discriminate between the 
>> fact you inserted or update a row? 
>>
>> What do you think? 
>>
>>   -Olivier 
>>
>>
>> From dal.py (I added the proposed modification) 
>> =========== 
>>
>> def update_or_insert(self, key=DEFAULT, **values): 
>>   if key==DEFAULT: 
>>     record = self(**values) 
>>   else: 
>>     record = self(key) 
>>    if record: 
>>     record.update_record(**values) 
>>     newid = None  #------> why not record['id'] ???? 
>>    else: 
>>      newid = self.insert(**values) 
>>    return newid
>
>

-- 



Reply via email to