tapsoob 0.3.16-java → 0.3.17-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tapsoob/data_stream.rb +10 -0
- data/lib/tapsoob/utils.rb +12 -6
- data/lib/tapsoob/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc5fc59bb301fada27f8d881680940916d55a17d98645a3761c5aa42cd1a4b44
|
4
|
+
data.tar.gz: 8aa7c7cdaa584109f932908f488b54b78dcd6de147386f1c60e4c09615be64ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 375467934ae7a5f53d9312aae0d675bd5095ec04af63672b875972ea4c0fcea29bc23d5e19d802664fbcdb0ed7393884bdb701d269ffb5f030b1d729ea4176fa
|
7
|
+
data.tar.gz: 6f628a7ff1a132d39b4377eb3dac4c1078a2bf1171cb436d2b72add56524d4c29d6ef32638095d6962084b9339effefd67ede9af34a4676e37cb51f5da3d8987
|
data/lib/tapsoob/data_stream.rb
CHANGED
@@ -218,6 +218,16 @@ module Tapsoob
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def import_rows(rows)
|
221
|
+
# Decode blobs
|
222
|
+
if rows.has_key?(:types) && rows[:types].include?("blob")
|
223
|
+
blob_indices = rows[:types].each_index.select { |idx| rows[:types][idx] == "blob" }
|
224
|
+
rows[:data].each_index do |idx|
|
225
|
+
blob_indices.each do |bi|
|
226
|
+
rows[:data][idx][bi] = Sequel::SQL::Blob.new(Tapsoob::Utils.base64decode(rows[:data][idx][bi])) unless rows[:data][idx][bi].nil?
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
221
231
|
table.import(rows[:header], rows[:data], :commit_every => 100)
|
222
232
|
state[:offset] += rows[:data].size
|
223
233
|
rescue Exception => ex
|
data/lib/tapsoob/utils.rb
CHANGED
@@ -51,7 +51,7 @@ module Tapsoob
|
|
51
51
|
|
52
52
|
header = data[0].keys
|
53
53
|
only_data = data.collect do |row|
|
54
|
-
row =
|
54
|
+
row = encode_blobs(row, string_columns)
|
55
55
|
row.each do |column, data|
|
56
56
|
if data.to_s.length > (max_lengths[column] || data.to_s.length)
|
57
57
|
raise Tapsoob::InvalidData.new(<<-ERROR)
|
@@ -70,27 +70,33 @@ Data : #{data}
|
|
70
70
|
end
|
71
71
|
header.collect { |h| row[h] }
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
|
+
res = { table_name: table, header: header, data: only_data }
|
75
|
+
|
76
|
+
# Add types if schema isn't empty
|
77
|
+
res[:types] = schema.map { |c| c.last[:type] } unless schema.empty?
|
78
|
+
|
79
|
+
res
|
74
80
|
end
|
75
81
|
|
76
82
|
# mysql text and blobs fields are handled the same way internally
|
77
83
|
# this is not true for other databases so we must check if the field is
|
78
84
|
# actually text and manually convert it back to a string
|
79
85
|
def incorrect_blobs(db, table)
|
80
|
-
return [] if (db.url =~ /mysql:\/\//).nil?
|
86
|
+
return [] if (db.url =~ /(mysql|mysql2):\/\//).nil?
|
81
87
|
|
82
88
|
columns = []
|
83
89
|
db.schema(table).each do |data|
|
84
90
|
column, cdata = data
|
85
|
-
columns << column if cdata[:
|
91
|
+
columns << column if cdata[:type] == :blob
|
86
92
|
end
|
87
93
|
columns
|
88
94
|
end
|
89
95
|
|
90
|
-
def
|
96
|
+
def encode_blobs(row, columns)
|
91
97
|
return row if columns.size == 0
|
92
98
|
columns.each do |c|
|
93
|
-
row[c] = row[c]
|
99
|
+
row[c] = base64encode(row[c]) unless row[c].nil?
|
94
100
|
end
|
95
101
|
row
|
96
102
|
end
|
data/lib/tapsoob/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapsoob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.17
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Félix Bellanger
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|