Herby,

as Esteban already said, UPSERT doesn't make any sense in an ORM. It either 
knows the object as one that has been read in this session or not. If not, 
it is new and needs to be inserted.

You could, of course, try and see what happens if you let Glorp's insert 
operation always issue an UPSERT. This is probably very easy to do and at 
first sight there isn't too much I could think of that could go wrong with 
it.

But I guess including a check for existence of an object as Esteban 
suggests isn't too bad from the performance and "safety" POV. not sure I 
understand how a Dictionary Mapping could help here....

Joachim




Am Dienstag, 22. August 2017 12:13:30 UTC+2 schrieb Herbert Vojčík:
>
> Hello! 
>
> Is there some way to do insert-or-update operation (that is, roughly, to 
> be able to register an object with possibly existing primary key(s) and 
> let it be written regardless? 
>
> Thanks, Herby 
>
> P.S.: Use case - I want to have log of USER-DEVICE pairing with last 
> timestamp and 'enabled' field that would be set to false once push 
> notification fails - but set to true once user actually logs from the 
> device (again). I don't want to have many historical records, so I want 
> to have USER+DEVICE to be a composed primary key. Which means it is 
> inserted first time, but possibly updated later. 
>

Reply via email to