Module: Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods

Defined in:
lib/sequel/plugins/prepared_statements_with_pk.rb

Instance Method Summary collapse

Instance Method Details

#with_pk(pk) ⇒ Object

Use a prepared statement to find a row with the matching primary key inside this dataset.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sequel/plugins/prepared_statements_with_pk.rb', line 43

def with_pk(pk)
  begin
    ds, bv = unbind
  rescue UnbindDuplicate
    super
  else
    begin
      bv = bv.merge!(model.primary_key_hash(pk)){|k, v1, v2| ((v1 == v2) ? v1 : raise(UnbindDuplicate))}
    rescue UnbindDuplicate
      super
    else
      model.send(:prepared_lookup_dataset, ds).call(bv)
    end
  end
end