File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
import Config
2
2
3
- config :ash , :use_all_identities_in_manage_relationship? , false
4
-
5
3
if Mix . env ( ) == :dev do
6
4
config :git_ops ,
7
5
mix_project: AshPostgres.MixProject ,
Original file line number Diff line number Diff line change @@ -1151,8 +1151,15 @@ defmodule AshPostgres.DataLayer do
1151
1151
1152
1152
opts =
1153
1153
if options [ :upsert? ] do
1154
+ on_conflict =
1155
+ if options [ :upsert_set ] do
1156
+ [ set: options [ :upsert_set ] ]
1157
+ else
1158
+ { :replace , options [ :upsert_fields ] || [ ] }
1159
+ end
1160
+
1154
1161
opts
1155
- |> Keyword . put ( :on_conflict , { :replace , options [ :upsert_fields ] || [ ] } )
1162
+ |> Keyword . put ( :on_conflict , on_conflict )
1156
1163
|> Keyword . put (
1157
1164
:conflict_target ,
1158
1165
conflict_target (
@@ -1761,12 +1768,22 @@ defmodule AshPostgres.DataLayer do
1761
1768
|> update_defaults ( )
1762
1769
|> Keyword . merge ( explicitly_changing_attributes )
1763
1770
1771
+ on_conflict =
1772
+ if changeset . context [ :private ] [ :upsert_fields ] do
1773
+ Keyword . take (
1774
+ on_conflict ,
1775
+ changeset . context [ :private ] [ :upsert_fields ]
1776
+ )
1777
+ else
1778
+ on_conflict
1779
+ end
1780
+
1764
1781
case bulk_create ( resource , [ changeset ] , % {
1765
1782
single?: true ,
1766
1783
upsert?: true ,
1767
1784
tenant: changeset . tenant ,
1768
1785
upsert_keys: keys ,
1769
- upsert_fields: Keyword . keys ( on_conflict ) ,
1786
+ upsert_set: on_conflict ,
1770
1787
return_records?: true
1771
1788
} ) do
1772
1789
{ :ok , [ result ] } ->
You can’t perform that action at this time.
0 commit comments