Skip to content

Upsert conflict with id + uuid #1635

Answered by simolus3
frankvollebregt asked this question in Q&A
Discussion options

You must be logged in to vote

I haven't tried it, but something like this could work:

db.into(table).insert(companion, onConflict: DoUpdate((Table? old) {
  final oldId = (old as TableInfo).columnsByName['${tableName}_uuid'];
  return RawValuesInsertable({
   ...companion.toColumns(false),
    '${tableName}_uuid': oldId,
  });
}));

Essentially, the idea is to use the uuid column from the old table, but all other values from the companion.

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
4 replies
@frankvollebregt
Comment options

@frankvollebregt
Comment options

@simolus3
Comment options

@frankvollebregt
Comment options

Answer selected by frankvollebregt
Comment options

You must be logged in to vote
8 replies
@frankvollebregt
Comment options

@frankvollebregt
Comment options

@frankvollebregt
Comment options

@simolus3
Comment options

@frankvollebregt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants