UPSERT repaired. It is whole done in one query in the database, not
as a combination of two queries. The original way led to following:
we want to upsert val = 1 to val = 1

original solution
query: upsert1, upsert2 ... in db exists val = 1? no -> insert later
query: upsert2, insert1 ... in db exists val = 1? no -> insert later
query: insert1, insert2 ... in db insert val = 1
query: insert2          ... in db insert val = 1
query:

right (current) solution
query: upsert1, upsert2 ... in db exists val = 1? no -> insert now!
query: upsert2          ... in db exists val = 1? yes -> update now!
query: