module Sequel::Plugins::PgXminOptimisticLocking::ClassMethods

Private Instance Methods

append_xmin_column_if_usable(ds) click to toggle source

If the xmin column is not already selected, and selecting it does not raise an error, append it to the selections.

# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb, line 57
def append_xmin_column_if_usable(ds)
  select = ds.opts[:select]

  unless select && select.include?(:xmin)
    xmin_ds = ds.select_append(:xmin)
    begin
      columns = xmin_ds.columns!
    rescue Sequel::DatabaseConnectionError, Sequel::DatabaseDisconnectError
      raise
    rescue Sequel::DatabaseError
      # ignore, could be view, subquery, table returning function, etc.
    else
      ds = xmin_ds if columns.include?(:xmin)
    end
  end

  ds
end
convert_input_dataset(ds) click to toggle source

Ensure the dataset selects the xmin column if doing so

Calls superclass method
# File lib/sequel/plugins/pg_xmin_optimistic_locking.rb, line 51
def convert_input_dataset(ds)
  append_xmin_column_if_usable(super)
end