tapsoob 0.3.21-java → 0.3.22-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: 58cd9a0f8c1ad8356c661c091d51d53e515aee22b746622f08173e31eaef7edf
4
- data.tar.gz: 6802b841f8c59cb73687c1f22a0e696ae26f23732871f44063bbf712290a1ea2
3
+ metadata.gz: '0902657538025d8da02f1bcfe8d15b8e14746bb56083cc021044f25aa4e81f24'
4
+ data.tar.gz: 41a7f3a480214954e2d06869f094e38b73ac79ba59e38b17b6c06d9a37a991cd
5
5
  SHA512:
6
- metadata.gz: f2d55a4ce17d26490e587e118bdcbe43f9430b7c9cbd0c9672c17dd358d37d9c203564a8c04cd6638a326f50966e6dc5a657a7dbecd1c40a08ca94ced1c21876
7
- data.tar.gz: 2ec0bb229614e453d5832f60b14cfd7e98e5a3cbec264499d0b50cfb77bd1790ba4505a599c3fd21af87ae1bb4da4c5f215e3ff34cb23c9b583cc5473aba1402
6
+ metadata.gz: 42f9ca1dd0dd01eb5f257b30e8872db9bf6de0606453a74558d0be1094abfeae036f0394d32c73fb6a99ed19e383e4dbddae0ab63a90d33d04c015096564664e
7
+ data.tar.gz: 2f42ab39fbb77d28620c4b174429fc8d1861e5a11a708c34ddece07a809f1a5d4e436dbf1e9bed8e3ce925421a7439c1098f5f60d135b10ed813144dddcf512d
@@ -39,6 +39,7 @@ module Tapsoob
39
39
  option :tables, desc: "Shortcut to filter on a list of tables", type: :array, aliases: "-t"
40
40
  option :"exclude-tables", desc: "Shortcut to exclude a list of tables", type: :array, aliases: "-e"
41
41
  option :purge, desc: "Purge data in tables prior to performing the import", default: false, type: :boolean, aliases: "-p"
42
+ option :"discard-identity", desc: "Remove identity when pushing data (may result in creating duplicates)", default: false, type: :boolean
42
43
  option :debug, desc: "Enable debug messages", default: false, type: :boolean, aliases: "-d"
43
44
  def push(dump_path, database_url)
44
45
  opts = parse_opts(options)
@@ -71,8 +72,9 @@ module Tapsoob
71
72
  debug: options[:debug]
72
73
  }
73
74
 
74
- # Purge (push only)
75
+ # Push only options
75
76
  opts[:purge] = options[:purge] if options.key?(:purge)
77
+ opts[:"discard-identity"] = options[:"discard-identity"] if options.key?(:"discard-identity")
76
78
 
77
79
  # Resume
78
80
  if options[:resume]
@@ -6,9 +6,9 @@ module Tapsoob
6
6
  class DataStream
7
7
  DEFAULT_CHUNKSIZE = 1000
8
8
 
9
- attr_reader :db, :state
9
+ attr_reader :db, :state, :options
10
10
 
11
- def initialize(db, state)
11
+ def initialize(db, state, opts = {})
12
12
  @db = db
13
13
  @state = {
14
14
  :offset => 0,
@@ -17,6 +17,7 @@ module Tapsoob
17
17
  :total_chunksize => 0
18
18
  }.merge(state)
19
19
  @state[:chunksize] ||= DEFAULT_CHUNKSIZE
20
+ @options = opts
20
21
  @complete = false
21
22
  end
22
23
 
@@ -227,8 +228,11 @@ module Tapsoob
227
228
  end
228
229
  end
229
230
  end
231
+
232
+ # Remove id column
233
+ columns = ((@options[:"discard-identity"] && rows[:headers].include?("id")) ? rows[:headers] - ["id"] : rows[:headers])
230
234
 
231
- table.import(rows[:header], rows[:data], :commit_every => 100)
235
+ table.import(columns, rows[:data], :commit_every => 100)
232
236
  state[:offset] += rows[:data].size
233
237
  rescue Exception => ex
234
238
  case ex.message
@@ -394,9 +394,9 @@ module Tapsoob
394
394
  tables.each do |table_name, count|
395
395
  next unless File.exists?(File.join(dump_path, "data", "#{table_name}.json"))
396
396
  db[table_name.to_sym].truncate if @opts[:purge]
397
- stream = Tapsoob::DataStream.factory(db,
397
+ stream = Tapsoob::DataStream.factory(db, {
398
398
  :table_name => table_name,
399
- :chunksize => default_chunksize)
399
+ :chunksize => default_chunksize }, { :"discard-identity" => @opts[:"discard-identity"] || false })
400
400
  progress = ProgressBar.new(table_name.to_s, count)
401
401
  push_data_from_file(stream, progress)
402
402
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Tapsoob
3
- VERSION = "0.3.21".freeze
3
+ VERSION = "0.3.22".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.21
4
+ version: 0.3.22
5
5
  platform: java
6
6
  authors:
7
7
  - Félix Bellanger