forklift_etl 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- forklift_etl (1.1.7)
4
+ forklift_etl (1.1.8)
5
5
  activesupport (~> 4.0, >= 4.0.0)
6
6
  elasticsearch (~> 1.0, >= 1.0.0)
7
7
  lumberjack (~> 1.0, >= 1.0.0)
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (4.1.4)
14
+ activesupport (4.1.5)
15
15
  i18n (~> 0.6, >= 0.6.9)
16
16
  json (~> 1.7, >= 1.7.7)
17
17
  minitest (~> 5.1)
@@ -52,16 +52,16 @@ GEM
52
52
  rspec-core (~> 3.0.0)
53
53
  rspec-expectations (~> 3.0.0)
54
54
  rspec-mocks (~> 3.0.0)
55
- rspec-core (3.0.2)
55
+ rspec-core (3.0.4)
56
56
  rspec-support (~> 3.0.0)
57
- rspec-expectations (3.0.2)
57
+ rspec-expectations (3.0.4)
58
58
  diff-lcs (>= 1.2.0, < 2.0)
59
59
  rspec-support (~> 3.0.0)
60
- rspec-mocks (3.0.2)
60
+ rspec-mocks (3.0.4)
61
61
  rspec-support (~> 3.0.0)
62
- rspec-support (3.0.2)
62
+ rspec-support (3.0.4)
63
63
  thread_safe (0.3.4)
64
- tzinfo (1.2.1)
64
+ tzinfo (1.2.2)
65
65
  thread_safe (~> 0.1)
66
66
 
67
67
  PLATFORMS
@@ -69,9 +69,17 @@ module Forklift
69
69
 
70
70
  def self.can_incremental_pipe?(source, from_table, destination, to_table, matcher=source.default_matcher)
71
71
  return false unless source.tables.include?(from_table)
72
- return false unless source.columns(from_table, source.current_database).include?(matcher)
73
72
  return false unless destination.tables.include?(to_table)
74
- return false unless destination.columns(to_table, destination.current_database).include?(matcher)
73
+ source_cols = source.columns(from_table, source.current_database)
74
+ destination_cols = destination.columns(to_table, destination.current_database)
75
+ return false unless source_cols.include?(matcher)
76
+ return false unless destination_cols.include?(matcher)
77
+ source_cols.each do |source_col|
78
+ return false unless destination_cols.include?(source_col)
79
+ end
80
+ destination_cols.each do |destination_col|
81
+ return false unless source_cols.include?(destination_col)
82
+ end
75
83
  true
76
84
  end
77
85
 
@@ -68,10 +68,20 @@ module Forklift
68
68
  if data.length > 0
69
69
  columns = columns(table, database)
70
70
  data.each do |d|
71
- d = clean_to_columns(d, columns) unless crash_on_extral_col == true
71
+
72
+ if crash_on_extral_col == false
73
+ d.each do |k,v|
74
+ unless columns.include?(k.to_s)
75
+ q("ALTER TABLE `#{database}`.`#{table}` ADD `#{k}` #{sql_type(v)} NULL DEFAULT NULL;")
76
+ columns = columns(table, database)
77
+ end
78
+ end
79
+ end
80
+
72
81
  if(to_update == true && !d[primary_key.to_sym].nil?)
73
82
  q("DELETE FROM `#{database}`.`#{table}` WHERE `#{primary_key}` = #{d[primary_key.to_sym]}")
74
83
  end
84
+
75
85
  insert_q = "INSERT INTO `#{database}`.`#{table}` (#{safe_columns(d.keys)}) VALUES (#{safe_values(d.values)});"
76
86
  q(insert_q)
77
87
  end
@@ -247,14 +257,6 @@ module Forklift
247
257
  return a.join(', ')
248
258
  end
249
259
 
250
- def clean_to_columns(row, columns)
251
- r = {}
252
- row.each do |k,v|
253
- r[k] = row[k] if columns.include?(k.to_s)
254
- end
255
- r
256
- end
257
-
258
260
  def safe_values(values)
259
261
  a = []
260
262
  values.each do |v|
@@ -1,3 +1,3 @@
1
1
  module Forklift
2
- VERSION = "1.1.7"
2
+ VERSION = "1.1.8"
3
3
  end
@@ -135,6 +135,26 @@ describe 'mysql' do
135
135
  expect(cols).to eql ['id', 'thing', 'number', 'updated_at']
136
136
  end
137
137
 
138
+ it "can add columns to exiting tables when new keys are provided" do
139
+ table = "users"
140
+ raw = SpecClient.mysql('forklift_test_source_a')
141
+
142
+ count = raw.query("SHOW COLUMNS FROM #{table}").count
143
+ expect(count).to eql 6
144
+
145
+ data = [
146
+ {email: 'other@example.com', something_else: :abc123, first_name: 'other', last_name: 'n', created_at: Time.new.to_s(:db), updated_at: Time.new.to_s(:db)}
147
+ ]
148
+ plan = SpecPlan.new
149
+ plan.do! {
150
+ destination = plan.connections[:mysql][:forklift_test_source_a]
151
+ destination.write(data, table)
152
+ }
153
+
154
+ count = raw.query("SHOW COLUMNS FROM #{table}").count
155
+ expect(count).to eql 7
156
+ end
157
+
138
158
  it "can will seek further for null-ish values" do
139
159
  data = [
140
160
  {id: 1, thing: 'stuff a', number: nil, updated_at: Time.new},
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forklift_etl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Evan Tahler
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
12
+ date: 2014-08-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -23,6 +25,7 @@ dependencies:
23
25
  type: :runtime
24
26
  prerelease: false
25
27
  version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
26
29
  requirements:
27
30
  - - ~>
28
31
  - !ruby/object:Gem::Version
@@ -33,6 +36,7 @@ dependencies:
33
36
  - !ruby/object:Gem::Dependency
34
37
  name: mysql2
35
38
  requirement: !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ~>
38
42
  - !ruby/object:Gem::Version
@@ -43,6 +47,7 @@ dependencies:
43
47
  type: :runtime
44
48
  prerelease: false
45
49
  version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
46
51
  requirements:
47
52
  - - ~>
48
53
  - !ruby/object:Gem::Version
@@ -53,6 +58,7 @@ dependencies:
53
58
  - !ruby/object:Gem::Dependency
54
59
  name: elasticsearch
55
60
  requirement: !ruby/object:Gem::Requirement
61
+ none: false
56
62
  requirements:
57
63
  - - ~>
58
64
  - !ruby/object:Gem::Version
@@ -63,6 +69,7 @@ dependencies:
63
69
  type: :runtime
64
70
  prerelease: false
65
71
  version_requirements: !ruby/object:Gem::Requirement
72
+ none: false
66
73
  requirements:
67
74
  - - ~>
68
75
  - !ruby/object:Gem::Version
@@ -73,6 +80,7 @@ dependencies:
73
80
  - !ruby/object:Gem::Dependency
74
81
  name: pony
75
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
76
84
  requirements:
77
85
  - - ~>
78
86
  - !ruby/object:Gem::Version
@@ -83,6 +91,7 @@ dependencies:
83
91
  type: :runtime
84
92
  prerelease: false
85
93
  version_requirements: !ruby/object:Gem::Requirement
94
+ none: false
86
95
  requirements:
87
96
  - - ~>
88
97
  - !ruby/object:Gem::Version
@@ -93,6 +102,7 @@ dependencies:
93
102
  - !ruby/object:Gem::Dependency
94
103
  name: lumberjack
95
104
  requirement: !ruby/object:Gem::Requirement
105
+ none: false
96
106
  requirements:
97
107
  - - ~>
98
108
  - !ruby/object:Gem::Version
@@ -103,6 +113,7 @@ dependencies:
103
113
  type: :runtime
104
114
  prerelease: false
105
115
  version_requirements: !ruby/object:Gem::Requirement
116
+ none: false
106
117
  requirements:
107
118
  - - ~>
108
119
  - !ruby/object:Gem::Version
@@ -191,26 +202,27 @@ files:
191
202
  homepage: https://github.com/taskrabbit/forklift
192
203
  licenses:
193
204
  - MIT
194
- metadata: {}
195
205
  post_install_message:
196
206
  rdoc_options: []
197
207
  require_paths:
198
208
  - lib
199
209
  required_ruby_version: !ruby/object:Gem::Requirement
210
+ none: false
200
211
  requirements:
201
212
  - - ! '>='
202
213
  - !ruby/object:Gem::Version
203
214
  version: '0'
204
215
  required_rubygems_version: !ruby/object:Gem::Requirement
216
+ none: false
205
217
  requirements:
206
218
  - - ! '>='
207
219
  - !ruby/object:Gem::Version
208
220
  version: '0'
209
221
  requirements: []
210
222
  rubyforge_project: forklift_etl
211
- rubygems_version: 2.2.2
223
+ rubygems_version: 1.8.23
212
224
  signing_key:
213
- specification_version: 4
225
+ specification_version: 3
214
226
  summary: ! 'Forklift: Moving big databases around. A ruby ETL tool.'
215
227
  test_files:
216
228
  - spec/config/connections/csv/forklift_test_destination.yml
@@ -242,4 +254,3 @@ test_files:
242
254
  - spec/unit/misc/error_spec.rb
243
255
  - spec/unit/misc/pid_spec.rb
244
256
  - spec/unit/misc/step_spec.rb
245
- has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjM4NGIzZDIwMjQzNjg2MTI1ODU4NmUzZmIyZmI5YzVjODZkZjMwZA==
5
- data.tar.gz: !binary |-
6
- YjU0MGQyNmU3ZGM3MzI4MjJkYzg4NDU4NGJiMjNiMWU0ZDU5NzVhYQ==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- ZWU3MWM1OWM1MjAyMmVmNzRlYmVhZGJhMGY5N2Y3NTY5MTVlYzNlN2RhNzEy
10
- NGIxMmEyYjRjNGM1NjcxYmVjZjIyM2FkM2FhY2ZjZjc1YmNmMDYzNDQ4MmEy
11
- NDBiYTlmZWZiNDVlNjFjY2Y4OTMwYzRhMmFmZDgwOTlhOTUyMjM=
12
- data.tar.gz: !binary |-
13
- OGQ0ZjZiODA3OGMzZGMxMmY2ZDA5ZTQyZDNmYTQwMTQ2MWM4ODc3NGU4YjY1
14
- MjYxMzQxOWQ0OWY0NjUzMzRkNTFmNjdiNDliNjVhMzI3ZDQ2YTg2YzVlOWQw
15
- NGJmYzI1ZTE3Y2FlNzhiZGQ2YTA5MjQ2NWM1MjIwNzIyNGM1NjE=