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
58 def append_xmin_column_if_usable(ds)
59   select = ds.opts[:select]
60 
61   unless select && select.include?(:xmin)
62     xmin_ds = ds.select_append(:xmin)
63     begin
64       columns = xmin_ds.columns!
65     rescue Sequel::DatabaseConnectionError, Sequel::DatabaseDisconnectError
66       raise
67     rescue Sequel::DatabaseError
68       # ignore, could be view, subquery, table returning function, etc.
69     else
70       ds = xmin_ds if columns.include?(:xmin)
71     end
72   end
73 
74   ds
75 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
52 def convert_input_dataset(ds)
53   append_xmin_column_if_usable(super)
54 end