Method: Webhookdb::Replicator::Base#_coalesce_excluded_on_update
- Defined in:
- lib/webhookdb/replicator/base.rb
#_coalesce_excluded_on_update(update, column_names) ⇒ Object
Have a column set itself only on insert or if nil.
Given the payload to DO UPDATE, mutate it so that the column names included in ‘column_names’ use what is already in the table, and fall back to what’s being inserted. This new payload should be passed to the ‘update` kwarg of `insert_conflict`:
ds.insert_conflict(update: self._coalesce_excluded_on_update(payload, :created_at)).insert(payload)
874 875 876 877 878 879 |
# File 'lib/webhookdb/replicator/base.rb', line 874 def _coalesce_excluded_on_update(update, column_names) # Now replace just the specific columns we're overriding. column_names.each do |c| update[c] = Sequel.function(:coalesce, self.qualified_table_sequel_identifier[c], Sequel[:excluded][c]) end end |