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
87 def _insert_dataset
88   super.returning(WILDCARD, :xmin)
89 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
93 def _save_update_all_columns_hash
94   v = super
95   v.delete(:xmin)
96   v
97 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
100 def _update_without_checking(columns)
101   ds = _update_dataset
102   rows = ds.clone(ds.send(:default_server_opts, :sql=>ds.returning(:xmin).update_sql(columns))).all
103   values[:xmin] = rows.first[:xmin] unless rows.empty?
104   rows.length
105 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
82 def lock_column_instance_filter
83   super if @values[:xmin]
84 end