I am checking if primary key has a conflict and then replace all values with new ones.
And i have array of maps that i want to insert through insert_all
Repo function.
But i want to use on_conflict option to replace_all fields if conflict occurs on room_id(primary_key) like this:
Repo.insert_all(schema_name, list_of_maps, on_conflict: :replace_all, conflict_target: [:room_id], returning: true)
Here are my list of maps
[
%{
"date_from" => #DateTime<2016-11-03 13:23:00Z>,
"date_to" => #DateTime<2016-11-03 13:23:00Z>,
"room_id" => 8,
"unit_id" => 11
},
%{
"date_from" => #DateTime<2016-11-03 13:23:00Z>,
"date_to" => #DateTime<2016-11-03 13:23:00Z>,
"room_id" => 9,
"unit_id" => 11
}
]
But it returns internal server error in test cases without any helpful stacktrace.
Any suggesstions?
Thanks