Sha256: 82ccf0721870cc0534c6a76375e4f6f7b07c46e46ecd0944fd9ae298c81d7126

Contents?: true

Size: 1.16 KB

Versions: 79

Compression:

Stored size: 1.16 KB

Contents

require("cipherstash-pg") unless defined? CipherStashPG
class CipherStashPG::BasicTypeMapForResults < CipherStashPG::TypeMapByOid
  include(CipherStashPG::BasicTypeRegistry::Checker)
  
  class WarningTypeMap < CipherStashPG::TypeMapInRuby
    def initialize(typenames)
      @already_warned = Hash.new { |h, k| h[k] = {} }
      @typenames_by_oid = typenames
    end
    
    def typecast_result_value(result, _tuple, field)
      format = result.fformat(field)
      oid = result.ftype(field)
      unless @already_warned[format][oid] then
        warn("Warning: no type cast defined for type #{@typenames_by_oid[oid].inspect} format #{format} with oid #{oid}. Please cast this type explicitly to TEXT to be safe for future changes.")
        @already_warned[format][oid] = true
      end
      super
    end
  end
  
  def initialize(connection_or_coder_maps, registry: nil)
    @coder_maps = build_coder_maps(connection_or_coder_maps, :registry => registry)
    @coder_maps.each_format(:decoder).flat_map { |f| f.coders }.each do |coder|
      add_coder(coder)
    end
    typenames = @coder_maps.typenames_by_oid
    self.default_type_map = WarningTypeMap.new(typenames)
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
cipherstash-pg-1.0.0.beta.22-x86_64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.22-x86_64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.22-arm64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.22-aarch64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.21-x86_64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.21-aarch64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.21-arm64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.21-x86_64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.19-x86_64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.19-x86_64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.19-arm64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.19-aarch64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.18-x86_64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.18-x86_64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.18-arm64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.18-aarch64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.17-aarch64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.17-x86_64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.17-x86_64-linux ./lib/cipherstash-pg/basic_type_map_for_results.rb
cipherstash-pg-1.0.0.beta.17-arm64-darwin ./lib/cipherstash-pg/basic_type_map_for_results.rb