Skip to content

Commit

Permalink
fix: update address not nil attributes (#2390)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Jan 5, 2025
1 parent 1d3c2e2 commit 244cacf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,17 @@ def update_addresses_dao_info(addrs_deposit_info)
is_depositor: address_info[:is_depositor],
}
end
Address.upsert_all(addresses_deposit_attributes, record_timestamps: true) if addresses_deposit_attributes.present?
if addresses_deposit_attributes.present?
Address.upsert_all(
addresses_deposit_attributes,
record_timestamps: true,
on_duplicate: Arel.sql(
"dao_deposit = COALESCE(EXCLUDED.dao_deposit, addresses.dao_deposit), " \
"interest = COALESCE(EXCLUDED.interest, addresses.interest), " \
"is_depositor = COALESCE(EXCLUDED.is_depositor, addresses.is_depositor)",
),
)
end
end

def update_or_create_udt_accounts!(local_block)
Expand Down

0 comments on commit 244cacf

Please sign in to comment.