module Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods

  1. lib/sequel/plugins/prepared_statements_with_pk.rb

Methods

Public Instance

  1. with_pk

Public Instance methods

with_pk (pk)

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

[show source]
# File lib/sequel/plugins/prepared_statements_with_pk.rb, line 41
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