module Sequel::Plugins::PgXminOptimisticLocking::InstanceMethods
Private Instance Methods
Source
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb 96 def _insert_dataset 97 super.returning(WILDCARD, :xmin) 98 end
Include xmin value when inserting initial row
Calls superclass method
Source
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb 102 def _save_update_all_columns_hash 103 v = super 104 v.delete(:xmin) 105 v 106 end
Remove the xmin from the columns to update. PostgreSQL automatically updates the xmin value, and it cannot be assigned.
Calls superclass method
Source
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb 109 def _update_without_checking(columns) 110 ds = _update_dataset 111 rows = ds.clone(ds.send(:default_server_opts, :sql=>ds.returning(:xmin).update_sql(columns).freeze)).all 112 values[:xmin] = rows.first[:xmin] unless rows.empty? 113 rows.length 114 end
Add an RETURNING clause to fetch the updated xmin when updating the row.
Source
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb 91 def lock_column_instance_filter 92 super if @values[:xmin] 93 end
Only set the lock column instance filter if there is an xmin value.
Calls superclass method