jtuchel wrote:
Herby,

as Esteban already said, UPSERT doesn't make any sense in an ORM. It

I don't know... I just create new object (with same "primary key") and register it (yes, I know I get an error - maybe I should be able to set the policy to "overwrite" and it would makes sense; or not?).

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....

Similarly to what was posted above: I can simply at:put: and I don't care if I created the new key-value pair or overwritten the old value (in cases where simply putting new object under a key is feasible, which is in this case).

Joachim

Herby

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.

--
You received this message because you are subscribed to the Google
Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to glorp-group+unsubscr...@googlegroups.com
<mailto:glorp-group+unsubscr...@googlegroups.com>.
To post to this group, send email to glorp-gr...@googlegroups.com
<mailto:glorp-gr...@googlegroups.com>.
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.


Reply via email to