module Sequel::Plugins::ColumnEncryption::DatasetMethods

  1. lib/sequel/plugins/column_encryption.rb

Methods

Public Instance

  1. needing_reencryption
  2. with_encrypted_value

Public Instance methods

needing_reencryption()

Filter the dataset to exclude rows where all encrypted columns are already encrypted with the current key and format.

[show source]
    # File lib/sequel/plugins/column_encryption.rb
738 def needing_reencryption
739   incorrect_column_prefixes = model.send(:column_encryption_metadata).map do |column, metadata|
740     prefix = metadata.key_searcher.call
741     (Sequel[column] < prefix) | (Sequel[column] > prefix + 'B')
742   end
743 
744   where(Sequel.|(*incorrect_column_prefixes))
745 end
with_encrypted_value(column, value)

Filter the dataset to only match rows where the column contains an encrypted version of value. Only works on searchable encrypted columns.

[show source]
    # File lib/sequel/plugins/column_encryption.rb
725 def with_encrypted_value(column, value)
726   metadata = model.send(:column_encryption_metadata)[column]
727   
728   unless metadata && metadata.data_searcher
729     raise Error, "lookup for encrypted column #{column.inspect} is not supported"
730   end
731 
732   prefixes = metadata.data_searcher.call(value)
733   where(Sequel.|(*prefixes.map{|v| Sequel.like(column, "#{escape_like(v)}%")}))
734 end