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
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
param = {:length => param.data_size * 2}
else
param = {:length => @@minimum_bind_length}
end
end
self.new(con, val, param, max_array_size)
end
|