Class: OCI8::BindType::String

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_bulkoperation/monkey_patch/bindtype.rb

Constant Summary collapse

@@minimum_bind_length =

1333 <= ceil(4000 / 3). 4000 is max size of char. 3 is NLS ratio of UTF-8.

1333

Class Method Summary collapse

Class Method Details

.create(con, val, param, max_array_size) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/activerecord_bulkoperation/monkey_patch/bindtype.rb', line 25

def self.create(con, val, param, max_array_size)
  case param
  when Hash
    param[:length_semantics] = OCI8::properties[:length_semantics] unless param.has_key? :length_semantics
    unless param[:length]
      if val.is_a?(Array) && val.any?
        max = 0
        val.each do |elem|
          length = self.get_length(elem, param)
          max = length if max < length
        end
        param[:length] = max
      else
        param[:length] = self.get_length(val, param)
      end
    end
    # use the default value when :nchar is not set explicitly.
    param[:nchar] = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
  when OCI8::Metadata::Base
    case param.data_type
    when :char, :varchar2
      length_semantics = OCI8.properties[:length_semantics]
      if length_semantics == :char
        length = param.char_size
      else
        length = param.data_size * OCI8.nls_ratio
      end
      param = {
        :length => length,
        :length_semantics => length_semantics,
        :nchar => (param.charset_form == :nchar),
      }
    when :raw
      # HEX needs twice space.
      param = {:length => param.data_size * 2}
    else
      param = {:length => @@minimum_bind_length}
    end
  end
  self.new(con, val, param, max_array_size)
end

.minimum_bind_lengthObject



17
18
19
# File 'lib/activerecord_bulkoperation/monkey_patch/bindtype.rb', line 17

def self.minimum_bind_length
  @@minimum_bind_length
end

.minimum_bind_length=(val) ⇒ Object



21
22
23
# File 'lib/activerecord_bulkoperation/monkey_patch/bindtype.rb', line 21

def self.minimum_bind_length=(val)
  @@minimum_bind_length = val
end