Andrew Thornton zeripath
  • Joined on 2019-01-16
zeripath commented on pull request xorm/xorm#2234 2023-03-26 12:25:44 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

I don't understand why the tests are failing on the CI but work here...

zeripath commented on pull request xorm/xorm#2234 2023-03-15 19:49:52 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

Ok I've disabled the conds/exprs part for upsert - I think insert on conflict do nothing will work fine for those.

Basic testing of the Upsert suggested that MySQL required a lot more work to…

zeripath pushed to on-conflict at zeripath/xorm 2023-03-15 17:30:50 +00:00
67b5c85f85 disable conds/exprs in upsert
zeripath pushed to on-conflict at zeripath/xorm 2023-03-15 13:56:46 +00:00
d7eb965a92 handle weird update n by mysql
zeripath pushed to on-conflict at zeripath/xorm 2023-03-15 12:55:54 +00:00
344985f6bd adjust name
zeripath commented on pull request xorm/xorm#2234 2023-03-15 12:28:28 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

Testcases for map[string]interface{} have been added.

The exprs stuff is still untested and it would be good to see an example of what that should do.

zeripath pushed to on-conflict at zeripath/xorm 2023-03-15 12:26:57 +00:00
2715e0de59 add tests for map
zeripath pushed to on-conflict at zeripath/xorm 2023-03-15 11:47:53 +00:00
625167ded5 More cleanly handle primary keys as unique constraints
zeripath commented on pull request xorm/xorm#2234 2023-03-14 22:54:33 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

So the next thing to do is to simplify the postgres and merge code to correctly handle this PK updates.

Then add some tests for the map[string]interface{}, []map[string]interface{} and…

zeripath pushed to on-conflict at zeripath/xorm 2023-03-14 22:53:03 +00:00
4bf706dd0c allow upsert on primary key
zeripath commented on pull request xorm/xorm#2234 2023-03-14 21:36:54 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

OK so the next thing I've realised is that we can Upsert on with a table without an Unique index - so long as it has a PK autoincrement.

zeripath pushed to on-conflict at zeripath/xorm 2023-03-14 21:03:57 +00:00
4bf7c4d738 fix tidb
zeripath pushed to on-conflict at zeripath/xorm 2023-03-14 16:49:05 +00:00
b4467b717a Try getting the LastInsertID before the rows affected
zeripath pushed to on-conflict at zeripath/xorm 2023-03-13 20:24:20 +00:00
5a188e58d1 oops
zeripath pushed to on-conflict at zeripath/xorm 2023-03-13 18:42:44 +00:00
e88ca1d017 only permit upsert if there is only one unique constraint
zeripath commented on pull request xorm/xorm#2234 2023-03-13 18:36:18 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

Actually thinking on I don't think you can reasonably do an upsert using these techniques if there is more than one unique constraint. So I think we should ban them.

zeripath commented on pull request xorm/xorm#2234 2023-03-13 15:47:08 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

OK, so if there is more than one unique constraint you really need to say which one you're upserting against. For example, it's possible for two different unique constraints to fail in two…

zeripath pushed to on-conflict at zeripath/xorm 2023-03-13 12:59:33 +00:00
5b92ebc141 fix postgres
zeripath commented on pull request xorm/xorm#2234 2023-03-13 11:10:40 +00:00
WIP: Add InsertOnConflictDoNothing and Upsert functionality

OK I think I have basic working implementation.

There are a couple of things needed:

  • Testcases which use the map[string]interface{}, []map[string]interface{} and []bean routes.
  • It…
zeripath pushed to on-conflict at zeripath/xorm 2023-03-13 11:03:12 +00:00
1e50bd8705 more test changes