activerecord_bulkoperation 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17592890c6cddecfc0574cfbc0b2646ddc753cc9
|
4
|
+
data.tar.gz: 6796ddbfd955454f12bc5404e44210f497967263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aa53b84368fe12513710f1ab441fb75c47d5457960a827e7f7dac6082162502c798bca0f70d2bdf8e2d2b7b9f856b08ce661c52edcd0dd13306fab4f0ef7eb2
|
7
|
+
data.tar.gz: d1b4f8b3f2249ada5035e6dc7e2f8f84837619789a67aa42a3f4d8efcfa0fb4f746bdc3725d444594ea3a92e9f12fa0d44b9089fcdefd9493ff449ad83a85c9a
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../../monkey_patch/bindtype'
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module Bulkoperation
|
3
5
|
module BatchUpdate
|
@@ -172,7 +174,7 @@ module ActiveRecord
|
|
172
174
|
|
173
175
|
def bind_column(cursor, index, type, column)
|
174
176
|
if type == :string
|
175
|
-
cursor.bind_param_array(":#{index}", column, String
|
177
|
+
cursor.bind_param_array(":#{index}", column, String)
|
176
178
|
|
177
179
|
elsif type == :integer
|
178
180
|
cursor.bind_param_array(":#{index}", column, Fixnum)
|
@@ -189,19 +191,6 @@ module ActiveRecord
|
|
189
191
|
end
|
190
192
|
end
|
191
193
|
|
192
|
-
def get_max_string_length(column)
|
193
|
-
return nil if column.nil?
|
194
|
-
|
195
|
-
max_length = 0
|
196
|
-
|
197
|
-
column.each do |value|
|
198
|
-
next if value.nil?
|
199
|
-
max_length = value.length if value.length > max_length
|
200
|
-
end
|
201
|
-
|
202
|
-
return max_length > 0 ? max_length : nil
|
203
|
-
end
|
204
|
-
|
205
194
|
def get_date_type(value)
|
206
195
|
return Date if value.nil?
|
207
196
|
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'oci8'
|
2
|
+
|
3
|
+
#--
|
4
|
+
# bindtype.rb -- OCI8::BindType
|
5
|
+
#
|
6
|
+
# Copyright (C) 2009-2011 KUBO Takehiro <kubo@jiubao.org>
|
7
|
+
#++
|
8
|
+
|
9
|
+
#
|
10
|
+
class OCI8
|
11
|
+
module BindType
|
12
|
+
|
13
|
+
class String
|
14
|
+
# 1333 <= ceil(4000 / 3). 4000 is max size of char. 3 is NLS ratio of UTF-8.
|
15
|
+
@@minimum_bind_length = 1333
|
16
|
+
|
17
|
+
def self.minimum_bind_length
|
18
|
+
@@minimum_bind_length
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.minimum_bind_length=(val)
|
22
|
+
@@minimum_bind_length = val
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.create(con, val, param, max_array_size)
|
26
|
+
case param
|
27
|
+
when Hash
|
28
|
+
param[:length_semantics] = OCI8::properties[:length_semantics] unless param.has_key? :length_semantics
|
29
|
+
unless param[:length]
|
30
|
+
if val.is_a?(Array) && val.any?
|
31
|
+
max = 0
|
32
|
+
val.each do |elem|
|
33
|
+
length = self.get_length(elem, param)
|
34
|
+
max = length if max < length
|
35
|
+
end
|
36
|
+
param[:length] = max
|
37
|
+
else
|
38
|
+
param[:length] = self.get_length(val, param)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# use the default value when :nchar is not set explicitly.
|
42
|
+
param[:nchar] = OCI8.properties[:bind_string_as_nchar] unless param.has_key?(:nchar)
|
43
|
+
when OCI8::Metadata::Base
|
44
|
+
case param.data_type
|
45
|
+
when :char, :varchar2
|
46
|
+
length_semantics = OCI8.properties[:length_semantics]
|
47
|
+
if length_semantics == :char
|
48
|
+
length = param.char_size
|
49
|
+
else
|
50
|
+
length = param.data_size * OCI8.nls_ratio
|
51
|
+
end
|
52
|
+
param = {
|
53
|
+
:length => length,
|
54
|
+
:length_semantics => length_semantics,
|
55
|
+
:nchar => (param.charset_form == :nchar),
|
56
|
+
}
|
57
|
+
when :raw
|
58
|
+
# HEX needs twice space.
|
59
|
+
param = {:length => param.data_size * 2}
|
60
|
+
else
|
61
|
+
param = {:length => @@minimum_bind_length}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
self.new(con, val, param, max_array_size)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def self.get_length(val, param)
|
70
|
+
if val.respond_to? :to_str
|
71
|
+
val = val.to_str
|
72
|
+
if param[:length_semantics] == :char
|
73
|
+
# character semantics
|
74
|
+
return val.size
|
75
|
+
else
|
76
|
+
# byte semantics
|
77
|
+
if OCI8.encoding != val.encoding
|
78
|
+
# If the string encoding is different with NLS_LANG character set,
|
79
|
+
# convert it to get the length.
|
80
|
+
val = val.encode(OCI8.encoding)
|
81
|
+
end
|
82
|
+
return val.bytesize
|
83
|
+
end
|
84
|
+
else
|
85
|
+
return @@minimum_bind_length
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_bulkoperation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OSP
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/activerecord_bulkoperation/connection_adapters/oracle_enhanced/oci_connection.rb
|
65
65
|
- lib/activerecord_bulkoperation/group_operations.rb
|
66
66
|
- lib/activerecord_bulkoperation/group_operations_select.rb
|
67
|
+
- lib/activerecord_bulkoperation/monkey_patch/bindtype.rb
|
67
68
|
- lib/activerecord_bulkoperation/util/connection_object.rb
|
68
69
|
- lib/activerecord_bulkoperation/util/entity_hash.rb
|
69
70
|
- lib/activerecord_bulkoperation/util/flush_dirty_objects.rb
|