tapsoob 0.3.22-java → 0.3.27-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0902657538025d8da02f1bcfe8d15b8e14746bb56083cc021044f25aa4e81f24'
4
- data.tar.gz: 41a7f3a480214954e2d06869f094e38b73ac79ba59e38b17b6c06d9a37a991cd
3
+ metadata.gz: 2c121ad1d7de6889a3cc1e79d39ab7844099a88a3da79654c1bfba1ddaba87f6
4
+ data.tar.gz: fac74e80043e1e2418f11541db774650f483a866e52fdfbe7282d4eb3f63a47a
5
5
  SHA512:
6
- metadata.gz: 42f9ca1dd0dd01eb5f257b30e8872db9bf6de0606453a74558d0be1094abfeae036f0394d32c73fb6a99ed19e383e4dbddae0ab63a90d33d04c015096564664e
7
- data.tar.gz: 2f42ab39fbb77d28620c4b174429fc8d1861e5a11a708c34ddece07a809f1a5d4e436dbf1e9bed8e3ce925421a7439c1098f5f60d135b10ed813144dddcf512d
6
+ metadata.gz: 4091d6a83bd692f59661236077028ee8c082b9fbe46d8adc7bb38afe736a6f26b3fcb404e4eeb9e2f0597cad75438cfbdeea5dabe9ad70f34f1582f202b7f54e
7
+ data.tar.gz: 3faea33ccd48dc605cd0f70e8f8fd9c68ed9a0d77ae057af193051a004124a91a9d2b65f3265878368e0aa9d035631ce6af4eb4142b2bd6bcc0070b4a9060152
@@ -219,6 +219,9 @@ module Tapsoob
219
219
  end
220
220
 
221
221
  def import_rows(rows)
222
+ columns = rows[:header]
223
+ data = rows[:data]
224
+
222
225
  # Decode blobs
223
226
  if rows.has_key?(:types) && rows[:types].include?("blob")
224
227
  blob_indices = rows[:types].each_index.select { |idx| rows[:types][idx] == "blob" }
@@ -229,10 +232,27 @@ module Tapsoob
229
232
  end
230
233
  end
231
234
 
235
+ # Parse date/datetime/time columns
236
+ if rows.has_key?(:types)
237
+ %w(date datetime time).each do |type|
238
+ if rows[:types].include?(type)
239
+ type_indices = rows[:types].each_index.select { |idx| rows[:types][idx] == type }
240
+ rows[:data].each_index do |idx|
241
+ type_indices.each do |ti|
242
+ rows[:data][idx][ti] = Sequel.send("string_to_#{type}".to_sym, rows[:data][idx][ti])
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
248
+
232
249
  # Remove id column
233
- columns = ((@options[:"discard-identity"] && rows[:headers].include?("id")) ? rows[:headers] - ["id"] : rows[:headers])
250
+ if @options[:"discard-identity"]
251
+ columns = rows[:header] - ["id"]
252
+ data = data.map { |d| d[1..-1] }
253
+ end
234
254
 
235
- table.import(columns, rows[:data], :commit_every => 100)
255
+ table.import(columns, data, :commit_every => 100)
236
256
  state[:offset] += rows[:data].size
237
257
  rescue Exception => ex
238
258
  case ex.message
@@ -250,19 +270,19 @@ module Tapsoob
250
270
  state[:offset] = table.count
251
271
  end
252
272
 
253
- def self.factory(db, state)
273
+ def self.factory(db, state, opts)
254
274
  if defined?(Sequel::MySQL) && Sequel::MySQL.respond_to?(:convert_invalid_date_time=)
255
275
  Sequel::MySQL.convert_invalid_date_time = :nil
256
276
  end
257
277
 
258
278
  if state.has_key?(:klass)
259
- return eval(state[:klass]).new(db, state)
279
+ return eval(state[:klass]).new(db, state, opts)
260
280
  end
261
281
 
262
282
  if Tapsoob::Utils.single_integer_primary_key(db, state[:table_name].to_sym)
263
- DataStreamKeyed.new(db, state)
283
+ DataStreamKeyed.new(db, state, opts)
264
284
  else
265
- DataStream.new(db, state)
285
+ DataStream.new(db, state, opts)
266
286
  end
267
287
  end
268
288
  end
@@ -270,8 +290,8 @@ module Tapsoob
270
290
  class DataStreamKeyed < DataStream
271
291
  attr_accessor :buffer
272
292
 
273
- def initialize(db, state)
274
- super(db, state)
293
+ def initialize(db, state, opts = {})
294
+ super(db, state, opts)
275
295
  @state = { :primary_key => order_by(state[:table_name]).first, :filter => 0 }.merge(@state)
276
296
  @state[:chunksize] ||= DEFAULT_CHUNKSIZE
277
297
  @buffer = []
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tapsoob
3
- VERSION = "0.3.22".freeze
3
+ VERSION = "0.3.27".freeze
4
4
  end
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.22
4
+ version: 0.3.27
5
5
  platform: java
6
6
  authors:
7
7
  - Félix Bellanger