module Sequel::Plugins::PgXminOptimisticLocking::InstanceMethods

Private Instance Methods

_insert_dataset() click to toggle source

Include xmin value when inserting initial row

Calls superclass method
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb, line 86
def _insert_dataset
  super.returning(WILDCARD, :xmin)
end
_save_update_all_columns_hash() click to toggle source

Remove the xmin from the columns to update. PostgreSQL automatically updates the xmin value, and it cannot be assigned.

Calls superclass method
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb, line 92
def _save_update_all_columns_hash
  v = super
  v.delete(:xmin)
  v
end
_update_without_checking(columns) click to toggle source

Add an RETURNING clause to fetch the updated xmin when updating the row.

# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb, line 99
def _update_without_checking(columns)
  ds = _update_dataset
  rows = ds.clone(ds.send(:default_server_opts, :sql=>ds.returning(:xmin).update_sql(columns))).all
  values[:xmin] = rows.first[:xmin] unless rows.empty?
  rows.length
end
lock_column_instance_filter() click to toggle source

Only set the lock column instance filter if there is an xmin value.

Calls superclass method
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb, line 81
def lock_column_instance_filter
  super if @values[:xmin]
end