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