Commit 4f36771
authored
Generate update set on conflict for upserts (#145)
When upserting to tables with only key columns, typo would generate `do nothing`
as a conflict resolution. This has the disadvantage of making the query not
execute the `returning` part, which meant that in cases where an upsert was
executed targeting a single row, no rows would return and the generated code
would cause an error.
As a workaround, we generate `update set k = excluded.k` for an arbitrary key
column k instead. This causes the `returning` part of the query to run but
shouldn't change the value of the row as typo sees it.
- Add failing test case for upserting on an existing row
- Make the test case work by generating `update set` instead of `do nothing`1 parent 2f44343 commit 4f36771
100 files changed
Lines changed: 1292 additions & 78 deletions
File tree
- .bleep/generated-sources
- typo-tester-anorm@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded
- myschema/marital_status
- typo-tester-anorm@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded
- myschema/marital_status
- typo-tester-doobie@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/marital_status
- typo-tester-doobie@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/marital_status
- typo-tester-zio-jdbc@jvm213/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/marital_status
- typo-tester-zio-jdbc@jvm3/scripts.GenHardcodedFiles/testdb/hardcoded/myschema/marital_status
- init/data
- typo-tester-anorm
- generated-and-checked-in/adventureworks
- humanresources
- employeedepartmenthistory
- employeepayhistory
- person
- businessentityaddress
- businessentitycontact
- emailaddress
- personphone
- production
- productcosthistory
- productdocument
- productinventory
- productlistpricehistory
- productmodelillustration
- productmodelproductdescriptionculture
- productproductphoto
- workorderrouting
- public
- flaff
- issue142_2
- issue142
- only_pk_columns
- table_with_generated_columns
- title_domain
- title
- purchasing
- productvendor
- purchaseorderdetail
- sales
- countryregioncurrency
- personcreditcard
- salesorderdetail
- salesorderheadersalesreason
- salespersonquotahistory
- salesterritoryhistory
- specialofferproduct
- src/scala/adventureworks
- typo-tester-doobie
- generated-and-checked-in/adventureworks
- humanresources
- employeedepartmenthistory
- employeepayhistory
- person
- businessentityaddress
- businessentitycontact
- emailaddress
- personphone
- production
- productcosthistory
- productdocument
- productinventory
- productlistpricehistory
- productmodelillustration
- productmodelproductdescriptionculture
- productproductphoto
- workorderrouting
- public
- flaff
- issue142_2
- issue142
- only_pk_columns
- table_with_generated_columns
- title_domain
- title
- purchasing
- productvendor
- purchaseorderdetail
- sales
- countryregioncurrency
- personcreditcard
- salesorderdetail
- salesorderheadersalesreason
- salespersonquotahistory
- salesterritoryhistory
- specialofferproduct
- src/scala/adventureworks
- typo-tester-zio-jdbc
- generated-and-checked-in/adventureworks
- public
- issue142_2
- issue142
- only_pk_columns
- table_with_generated_columns
- title_domain
- title
- src/scala/adventureworks
- typo/src/scala/typo/internal/codegen
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
0 commit comments