tommasop#2001
tommasop#2001
Explore posts from servers
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
hope the test makes sense 🙂
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
I added a test with a Manager resource which belongs to Organization the test passes for creation but fails for upsert
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
Here the error stays the same
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
I will set up a test with different resources because otherwise I'll break all other tests or let me know if there is a better way
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
I'm setting up the test and it seems the problem arises when you have attributes with allow_nil? false and without a default
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
will do my best 🙂
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
I can try to write a minimal reproduction test in ash_postgres
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
sku_code is writable, and no default_accept?, id is writeable
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
it's not upserting but creating new records
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
create :create do
description ""

argument :data_in_id, :uuid do
allow_nil? false
end

argument :category_id, :uuid do
allow_nil? false
end

change manage_relationship(:data_in_id, :data_in, type: :append_and_remove)
change manage_relationship(:category_id, :category, type: :append_and_remove)
end
create :create do
description ""

argument :data_in_id, :uuid do
allow_nil? false
end

argument :category_id, :uuid do
allow_nil? false
end

change manage_relationship(:data_in_id, :data_in, type: :append_and_remove)
change manage_relationship(:category_id, :category, type: :append_and_remove)
end
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
ok thanks
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
yes
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
the behavior is consistent if I use id or another identity (:unique_sku_code)
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
p = MmsBiztalk.bulk_create!(input.resources_attributes, input.resource, :create, upsert?: true, upsert_fields: [:sku_code, :quantity], return_records?: true)
%Ash.BulkResult{
status: :success,
errors: [],
records: [
#MmsBiztalk.Product<
category: #Ash.NotLoaded<:relationship>,
data_in: #Ash.NotLoaded<:relationship>,
__meta__: #Ecto.Schema.Metadata<:loaded, "products">,
id: "1905788c-1f86-4cef-a92c-2480ede1a59f",
sku_code: "MAGP0.6.2",
brand: "lotus",
description_en: "cool",
description_full_it: nil,
description_full_en: nil,
description_full_es: nil,
description_full_de: nil,
gross_unit_weight: 1.0,
gross_unit_weight_measurement: nil,
price: 1.0,
macrofamily_code: "A",
family_code: "A",
logistic_class: "A",
created_at: nil,
quantity: 14.0,
status: :not_synced,
inserted_at: ~U[2023-05-25 15:13:14.831601Z],
updated_at: ~U[2023-05-25 15:13:14.831601Z],
deleted_at: nil,
data_in_id: nil,
category_id: nil,
aggregates: %{},
calculations: %{},
__order__: nil,
...
>
],
notifications: [],
error_count: 0
}
p = MmsBiztalk.bulk_create!(input.resources_attributes, input.resource, :create, upsert?: true, upsert_fields: [:sku_code, :quantity], return_records?: true)
%Ash.BulkResult{
status: :success,
errors: [],
records: [
#MmsBiztalk.Product<
category: #Ash.NotLoaded<:relationship>,
data_in: #Ash.NotLoaded<:relationship>,
__meta__: #Ecto.Schema.Metadata<:loaded, "products">,
id: "1905788c-1f86-4cef-a92c-2480ede1a59f",
sku_code: "MAGP0.6.2",
brand: "lotus",
description_en: "cool",
description_full_it: nil,
description_full_en: nil,
description_full_es: nil,
description_full_de: nil,
gross_unit_weight: 1.0,
gross_unit_weight_measurement: nil,
price: 1.0,
macrofamily_code: "A",
family_code: "A",
logistic_class: "A",
created_at: nil,
quantity: 14.0,
status: :not_synced,
inserted_at: ~U[2023-05-25 15:13:14.831601Z],
updated_at: ~U[2023-05-25 15:13:14.831601Z],
deleted_at: nil,
data_in_id: nil,
category_id: nil,
aggregates: %{},
calculations: %{},
__order__: nil,
...
>
],
notifications: [],
error_count: 0
}
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
with all the needed fields it works but it updates all the fields:
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
good idea
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
pry(1)> input.resources_attributes
[
%{
category_id: "054bb31e-932d-4509-b96c-18af44abf5ad",
data_in_id: "8b58c644-c9a4-4ff7-8314-ea8262a826fb",
id: "73c7a25b-1bd3-45f4-bb5d-0dae1b293022",
quantity: 14.0,
sku_code: "MAGP0.6.2"
}
]
pry(1)> input.resources_attributes
[
%{
category_id: "054bb31e-932d-4509-b96c-18af44abf5ad",
data_in_id: "8b58c644-c9a4-4ff7-8314-ea8262a826fb",
id: "73c7a25b-1bd3-45f4-bb5d-0dae1b293022",
quantity: 14.0,
sku_code: "MAGP0.6.2"
}
]
163 replies
AEAsh Elixir
Created by tommasop#2001 on 5/24/2023 in #support
BulkCreate upsert not working
this is the collection
163 replies