postgres_upsert 2.0.0 → 5.1.0
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 +5 -5
- data/.gitignore +3 -0
- data/.rubocop.yml +57 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +175 -85
- data/README.md +117 -41
- data/Rakefile +4 -16
- data/app/assets/config/manifest.js +0 -0
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/setup +56 -0
- data/config.ru +4 -0
- data/config/application.rb +21 -0
- data/config/boot.rb +3 -0
- data/config/database.yml +24 -0
- data/config/database.yml.travis +23 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +41 -0
- data/config/environments/production.rb +79 -0
- data/config/environments/test.rb +42 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +56 -0
- data/config/secrets.yml +22 -0
- data/db/migrate/20150214192135_create_test_tables.rb +24 -0
- data/db/migrate/20150710162236_create_composite_models_table.rb +9 -0
- data/db/schema.rb +48 -0
- data/db/seeds.rb +7 -0
- data/lib/postgres_upsert.rb +38 -6
- data/lib/postgres_upsert/model_to_model_adapter.rb +37 -0
- data/lib/postgres_upsert/read_adapters/active_record_adapter.rb +37 -0
- data/lib/postgres_upsert/read_adapters/file_adapter.rb +42 -0
- data/lib/postgres_upsert/read_adapters/io_adapter.rb +42 -0
- data/lib/postgres_upsert/result.rb +23 -0
- data/lib/postgres_upsert/table_writer.rb +48 -0
- data/lib/postgres_upsert/write_adapters/active_record_adapter.rb +36 -0
- data/lib/postgres_upsert/write_adapters/table_adapter.rb +56 -0
- data/lib/postgres_upsert/writer.rb +130 -92
- data/postgres_upsert.gemspec +7 -4
- data/spec/composite_key_spec.rb +50 -0
- data/spec/fixtures/comma_with_header_duplicate.csv +3 -0
- data/spec/fixtures/composite_key_model.rb +4 -0
- data/spec/fixtures/composite_key_with_header.csv +3 -0
- data/spec/fixtures/composite_nonkey_with_header.csv +3 -0
- data/spec/fixtures/test_model_copy.rb +4 -0
- data/spec/from_table_spec.rb +40 -0
- data/spec/pg_upsert_csv_spec.rb +93 -35
- data/spec/rails_helper.rb +1 -0
- data/spec/spec_helper.rb +9 -37
- metadata +106 -37
- data/VERSION +0 -1
- data/lib/postgres_upsert/active_record.rb +0 -13
- data/spec/fixtures/2_col_binary_data.dat +0 -0
- data/spec/pg_upsert_binary_spec.rb +0 -35
- data/spec/spec.opts +0 -1
data/spec/pg_upsert_csv_spec.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "pg_upsert from file with CSV format" do
|
4
|
-
before(:each) do
|
5
|
-
ActiveRecord::Base.connection.execute %{
|
6
|
-
TRUNCATE TABLE test_models;
|
7
|
-
TRUNCATE TABLE three_columns;
|
8
|
-
SELECT setval('test_models_id_seq', 1, false);
|
9
|
-
}
|
10
|
-
end
|
11
4
|
|
12
5
|
before do
|
13
|
-
DateTime.stub_chain(:now, :utc).and_return (DateTime.parse("2012-01-01").utc)
|
6
|
+
DateTime.stub_chain(:now, :utc).and_return (DateTime.parse("2012-01-01").utc.round(4))
|
7
|
+
@time_now = Time.now.round(4)
|
8
|
+
allow(Time).to receive(:now).and_return(@time_now)
|
14
9
|
end
|
15
10
|
|
16
11
|
def timestamp
|
@@ -18,14 +13,14 @@ describe "pg_upsert from file with CSV format" do
|
|
18
13
|
end
|
19
14
|
|
20
15
|
it "should import from file if path is passed without field_map" do
|
21
|
-
|
16
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/comma_with_header.csv')
|
22
17
|
expect(
|
23
18
|
TestModel.first.attributes
|
24
19
|
).to include('data' => 'test data 1', 'created_at' => timestamp, 'updated_at' => timestamp)
|
25
20
|
end
|
26
21
|
|
27
22
|
it "correctly handles delimiters in content" do
|
28
|
-
|
23
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/comma_with_header_and_comma_values.csv')
|
29
24
|
expect(
|
30
25
|
TestModel.first.attributes
|
31
26
|
).to include('data' => 'test, the data 1', 'created_at' => timestamp, 'updated_at' => timestamp)
|
@@ -33,39 +28,39 @@ describe "pg_upsert from file with CSV format" do
|
|
33
28
|
|
34
29
|
it "throws error if csv is malformed" do
|
35
30
|
expect{
|
36
|
-
|
31
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/comma_with_header_and_unquoted_comma.csv')
|
37
32
|
}.to raise_error
|
38
33
|
end
|
39
34
|
|
40
|
-
it "throws error if
|
35
|
+
it "throws error if source data contains duplicate pk" do
|
41
36
|
expect{
|
42
|
-
|
43
|
-
}.to raise_error
|
37
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/comma_with_header_duplicate.csv')
|
38
|
+
}.to raise_error(/duplicate key/)
|
44
39
|
end
|
45
40
|
|
46
41
|
it "should import from IO without field_map" do
|
47
|
-
|
42
|
+
PostgresUpsert.write TestModel, File.open(File.expand_path('spec/fixtures/comma_with_header.csv'), 'r')
|
48
43
|
expect(
|
49
44
|
TestModel.first.attributes
|
50
45
|
).to include('data' => 'test data 1', 'created_at' => timestamp, 'updated_at' => timestamp)
|
51
46
|
end
|
52
47
|
|
53
48
|
it "should import with custom delimiter from path" do
|
54
|
-
|
49
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/semicolon_with_header.csv'), :delimiter => ';'
|
55
50
|
expect(
|
56
51
|
TestModel.first.attributes
|
57
52
|
).to include('data' => 'test data 1', 'created_at' => timestamp, 'updated_at' => timestamp)
|
58
53
|
end
|
59
54
|
|
60
55
|
it "should import with custom delimiter from IO" do
|
61
|
-
|
56
|
+
PostgresUpsert.write TestModel, File.open(File.expand_path('spec/fixtures/semicolon_with_header.csv'), 'r'), :delimiter => ';'
|
62
57
|
expect(
|
63
58
|
TestModel.first.attributes
|
64
59
|
).to include('data' => 'test data 1', 'created_at' => timestamp, 'updated_at' => timestamp)
|
65
60
|
end
|
66
61
|
|
67
62
|
it "should not expect a header when :header is false" do
|
68
|
-
|
63
|
+
PostgresUpsert.write(TestModel, File.open(File.expand_path('spec/fixtures/comma_without_header.csv'), 'r'), :header => false, :columns => [:id,:data])
|
69
64
|
|
70
65
|
expect(
|
71
66
|
TestModel.first.attributes
|
@@ -73,7 +68,7 @@ describe "pg_upsert from file with CSV format" do
|
|
73
68
|
end
|
74
69
|
|
75
70
|
it "should be able to map the header in the file to diferent column names" do
|
76
|
-
|
71
|
+
PostgresUpsert.write(TestModel, File.open(File.expand_path('spec/fixtures/tab_with_different_header.csv'), 'r'), :delimiter => "\t", :map => {'cod' => 'id', 'info' => 'data'})
|
77
72
|
|
78
73
|
expect(
|
79
74
|
TestModel.first.attributes
|
@@ -81,7 +76,7 @@ describe "pg_upsert from file with CSV format" do
|
|
81
76
|
end
|
82
77
|
|
83
78
|
it "should be able to map the header in the file to diferent column names with custom delimiter" do
|
84
|
-
|
79
|
+
PostgresUpsert.write(TestModel, File.open(File.expand_path('spec/fixtures/semicolon_with_different_header.csv'), 'r'), :delimiter => ';', :map => {'cod' => 'id', 'info' => 'data'})
|
85
80
|
|
86
81
|
expect(
|
87
82
|
TestModel.first.attributes
|
@@ -89,7 +84,7 @@ describe "pg_upsert from file with CSV format" do
|
|
89
84
|
end
|
90
85
|
|
91
86
|
it "should ignore empty lines" do
|
92
|
-
|
87
|
+
PostgresUpsert.write(TestModel, File.open(File.expand_path('spec/fixtures/tab_with_extra_line.csv'), 'r'), :delimiter => "\t")
|
93
88
|
|
94
89
|
expect(
|
95
90
|
TestModel.first.attributes
|
@@ -97,7 +92,7 @@ describe "pg_upsert from file with CSV format" do
|
|
97
92
|
end
|
98
93
|
|
99
94
|
it "should not create timestamps when the model does not include them" do
|
100
|
-
|
95
|
+
PostgresUpsert.write ReservedWordModel, File.expand_path('spec/fixtures/reserved_words.csv'), :delimiter => "\t"
|
101
96
|
|
102
97
|
expect(
|
103
98
|
ReservedWordModel.first.attributes
|
@@ -113,12 +108,12 @@ describe "pg_upsert from file with CSV format" do
|
|
113
108
|
|
114
109
|
it "should not violate primary key constraint" do
|
115
110
|
expect{
|
116
|
-
|
111
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/comma_with_header.csv')
|
117
112
|
}.to_not raise_error
|
118
113
|
end
|
119
114
|
|
120
115
|
it "should upsert (update existing records and insert new records)" do
|
121
|
-
|
116
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t"
|
122
117
|
|
123
118
|
expect(
|
124
119
|
TestModel.find(1).attributes
|
@@ -128,21 +123,33 @@ describe "pg_upsert from file with CSV format" do
|
|
128
123
|
).to eq("id"=>2, "data"=>"test data 2", "created_at" => timestamp, "updated_at" => timestamp)
|
129
124
|
end
|
130
125
|
|
126
|
+
it "should return updated and inserted results" do
|
127
|
+
result = PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t"
|
128
|
+
|
129
|
+
expect(
|
130
|
+
result.updated
|
131
|
+
).to eq(1)
|
132
|
+
|
133
|
+
expect(
|
134
|
+
result.inserted
|
135
|
+
).to eq(1)
|
136
|
+
end
|
137
|
+
|
131
138
|
it "should require columns option if no header" do
|
132
139
|
expect{
|
133
|
-
|
140
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/comma_without_header.csv'), :header => false
|
134
141
|
}.to raise_error("Either the :columns option or :header => true are required")
|
135
142
|
end
|
136
143
|
|
137
144
|
it "should clean up the temp table after completion" do
|
138
|
-
|
139
|
-
|
145
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t"
|
146
|
+
|
140
147
|
ActiveRecord::Base.connection.tables.should_not include("test_models_temp")
|
141
148
|
end
|
142
149
|
|
143
150
|
it "should gracefully drop the temp table if it already exists" do
|
144
151
|
ActiveRecord::Base.connection.execute "CREATE TEMP TABLE test_models_temp (LIKE test_models);"
|
145
|
-
|
152
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t"
|
146
153
|
|
147
154
|
expect(
|
148
155
|
TestModel.find(1).attributes
|
@@ -154,7 +161,7 @@ describe "pg_upsert from file with CSV format" do
|
|
154
161
|
|
155
162
|
it "should be able to copy using custom set of columns" do
|
156
163
|
ThreeColumn.create(id: 1, data: "old stuff", extra: "neva change!", created_at: original_created_at)
|
157
|
-
|
164
|
+
PostgresUpsert.write(ThreeColumn, File.open(File.expand_path('spec/fixtures/tab_only_data.csv'), 'r'), :delimiter => "\t", :columns => ["id", "data"])
|
158
165
|
|
159
166
|
expect(
|
160
167
|
ThreeColumn.first.attributes
|
@@ -167,8 +174,7 @@ describe "pg_upsert from file with CSV format" do
|
|
167
174
|
three_col = ThreeColumn.create(id: 1, data: "old stuff", extra: "neva change!")
|
168
175
|
file = File.open(File.expand_path('spec/fixtures/no_id.csv'), 'r')
|
169
176
|
|
170
|
-
|
171
|
-
ThreeColumn.pg_upsert(file, :key_column => "data")
|
177
|
+
PostgresUpsert.write(ThreeColumn, file, :unique_key => "data")
|
172
178
|
expect(
|
173
179
|
three_col.reload.extra
|
174
180
|
).to eq("ABC: Always Be Changing.")
|
@@ -177,11 +183,29 @@ describe "pg_upsert from file with CSV format" do
|
|
177
183
|
it 'inserts records if the passed match column doesnt exist' do
|
178
184
|
file = File.open(File.expand_path('spec/fixtures/no_id.csv'), 'r')
|
179
185
|
|
180
|
-
|
186
|
+
PostgresUpsert.write(ThreeColumn, file, :unique_key => "data")
|
187
|
+
expect(
|
188
|
+
ThreeColumn.last.attributes
|
189
|
+
).to include("data" => "old stuff", "extra" => "ABC: Always Be Changing.")
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'allows key column to be a string or symbol' do
|
193
|
+
file = File.open(File.expand_path('spec/fixtures/no_id.csv'), 'r')
|
194
|
+
|
195
|
+
PostgresUpsert.write(ThreeColumn, file, :header => true, :unique_key => :data)
|
181
196
|
expect(
|
182
197
|
ThreeColumn.last.attributes
|
183
|
-
).to include("
|
198
|
+
).to include("data" => "old stuff", "extra" => "ABC: Always Be Changing.")
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'raises an error if the expected key column is not in data' do
|
202
|
+
file = File.open(File.expand_path('spec/fixtures/no_id.csv'), 'r')
|
203
|
+
|
204
|
+
expect{
|
205
|
+
PostgresUpsert.write(ThreeColumn, file, :header => true)
|
206
|
+
}.to raise_error (/Expected column 'id'/)
|
184
207
|
end
|
208
|
+
|
185
209
|
end
|
186
210
|
|
187
211
|
context 'update only' do
|
@@ -189,9 +213,9 @@ describe "pg_upsert from file with CSV format" do
|
|
189
213
|
before(:each) do
|
190
214
|
TestModel.create(id: 1, data: "From the before time, in the long long ago", :created_at => original_created_at)
|
191
215
|
end
|
192
|
-
it 'will only update and not insert if insert_only flag is passed.' do
|
193
|
-
TestModel.pg_upsert File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t", :update_only => true
|
194
216
|
|
217
|
+
it 'will only update and not insert if insert_only flag is passed.' do
|
218
|
+
PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t", :update_only => true
|
195
219
|
expect(
|
196
220
|
TestModel.find(1).attributes
|
197
221
|
).to eq("id"=>1, "data"=>"test data 1", "created_at" => original_created_at , "updated_at" => timestamp)
|
@@ -201,6 +225,40 @@ describe "pg_upsert from file with CSV format" do
|
|
201
225
|
|
202
226
|
end
|
203
227
|
|
228
|
+
it 'will return the number of updated rows' do
|
229
|
+
a = PostgresUpsert.write TestModel, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t", :update_only => true
|
230
|
+
expect(
|
231
|
+
a.updated
|
232
|
+
).to eq(1)
|
233
|
+
|
234
|
+
expect(
|
235
|
+
a.inserted
|
236
|
+
).to eq(0)
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
context 'using table_name' do
|
242
|
+
it "should import from file if path is passed without field_map" do
|
243
|
+
PostgresUpsert.write TestModel.table_name, File.expand_path('spec/fixtures/comma_with_header.csv')
|
244
|
+
expect(
|
245
|
+
TestModel.first.attributes
|
246
|
+
).to include('data' => 'test data 1', 'created_at' => timestamp, 'updated_at' => timestamp)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should still report results" do
|
250
|
+
TestModel.create(data: "test data 1")
|
251
|
+
result = PostgresUpsert.write TestModel.table_name, File.expand_path('spec/fixtures/tab_with_two_lines.csv'), :delimiter => "\t"
|
252
|
+
|
253
|
+
expect(
|
254
|
+
result.updated
|
255
|
+
).to eq(1)
|
256
|
+
|
257
|
+
expect(
|
258
|
+
result.inserted
|
259
|
+
).to eq(1)
|
260
|
+
end
|
261
|
+
|
204
262
|
end
|
205
263
|
end
|
206
264
|
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(__dir__ + '/spec_helper')
|
data/spec/spec_helper.rb
CHANGED
@@ -1,47 +1,19 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
require File.expand_path("../../config/environment", __FILE__)
|
2
3
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
4
|
require 'fixtures/test_model'
|
5
|
+
require 'fixtures/test_model_copy'
|
4
6
|
require 'fixtures/three_column'
|
5
7
|
require 'fixtures/reserved_word_model'
|
6
|
-
require '
|
8
|
+
require 'fixtures/composite_key_model'
|
9
|
+
require 'rspec/rails'
|
7
10
|
require 'rspec/autorun'
|
11
|
+
require 'database_cleaner/active_record'
|
8
12
|
|
9
13
|
RSpec.configure do |config|
|
10
|
-
config.before(:
|
11
|
-
|
12
|
-
# I do not use database users or password for the tests, using ident authentication instead
|
13
|
-
begin
|
14
|
-
ActiveRecord::Base.establish_connection(
|
15
|
-
:adapter => "postgresql",
|
16
|
-
:host => "localhost",
|
17
|
-
:username => "postgres",
|
18
|
-
:password => "postgres",
|
19
|
-
:port => 5432,
|
20
|
-
:database => "ar_pg_copy_test"
|
21
|
-
)
|
22
|
-
ActiveRecord::Base.connection.execute %{
|
23
|
-
SET client_min_messages TO warning;
|
24
|
-
DROP TABLE IF EXISTS test_models;
|
25
|
-
DROP TABLE IF EXISTS three_columns;
|
26
|
-
DROP TABLE IF EXISTS reserved_word_models;
|
27
|
-
CREATE TABLE test_models (id serial PRIMARY KEY, data text, created_at timestamp with time zone, updated_at timestamp with time zone );
|
28
|
-
CREATE TABLE three_columns (id serial PRIMARY KEY, data text, extra text, created_at timestamp with time zone, updated_at timestamp with time zone );
|
29
|
-
CREATE TABLE reserved_word_models (id serial PRIMARY KEY, "select" text, "group" text);
|
30
|
-
}
|
31
|
-
rescue Exception => e
|
32
|
-
puts "Exception: #{e}"
|
33
|
-
ActiveRecord::Base.establish_connection(
|
34
|
-
:adapter => "postgresql",
|
35
|
-
:host => "localhost",
|
36
|
-
:username => "postgres",
|
37
|
-
:password => "postgres",
|
38
|
-
:port => 5432,
|
39
|
-
:database => "postgres"
|
40
|
-
)
|
41
|
-
ActiveRecord::Base.connection.execute "DROP DATABASE IF EXISTS ar_pg_copy_test"
|
42
|
-
ActiveRecord::Base.connection.execute "CREATE DATABASE ar_pg_copy_test;"
|
43
|
-
retry
|
44
|
-
end
|
14
|
+
config.before(:example) do
|
15
|
+
DatabaseCleaner.clean_with(:truncation)
|
45
16
|
end
|
46
|
-
|
17
|
+
config.expose_current_running_example_as :example
|
18
|
+
config.infer_spec_type_from_file_location!
|
47
19
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgres_upsert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Mitchell
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-09-12 00:00:00.000000000 Z
|
@@ -14,100 +14,128 @@ dependencies:
|
|
14
14
|
name: pg
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.17.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pry-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-
|
84
|
+
name: pry-nav
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.9'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.9'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: database_cleaner-active_record
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
|
-
- -
|
115
|
+
- - ">="
|
88
116
|
- !ruby/object:Gem::Version
|
89
117
|
version: '0'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
|
-
- -
|
122
|
+
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
126
|
+
name: rubocop
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
|
-
- -
|
129
|
+
- - ">="
|
102
130
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
131
|
+
version: '0'
|
104
132
|
type: :development
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
|
-
- -
|
136
|
+
- - ">="
|
109
137
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
138
|
+
version: '0'
|
111
139
|
description: Uses Postgres's powerful COPY command to upsert large sets of data into
|
112
140
|
ActiveRecord tables
|
113
141
|
email: thestevemitchell@gmail.com
|
@@ -115,22 +143,57 @@ executables: []
|
|
115
143
|
extensions: []
|
116
144
|
extra_rdoc_files: []
|
117
145
|
files:
|
118
|
-
- .gitignore
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rubocop.yml"
|
148
|
+
- ".ruby-gemset"
|
149
|
+
- ".ruby-version"
|
150
|
+
- ".travis.yml"
|
119
151
|
- Gemfile
|
120
152
|
- Gemfile.lock
|
121
153
|
- LICENSE
|
122
154
|
- README.md
|
123
155
|
- Rakefile
|
124
|
-
-
|
156
|
+
- app/assets/config/manifest.js
|
157
|
+
- bin/bundle
|
158
|
+
- bin/rails
|
159
|
+
- bin/rake
|
160
|
+
- bin/setup
|
161
|
+
- config.ru
|
162
|
+
- config/application.rb
|
163
|
+
- config/boot.rb
|
164
|
+
- config/database.yml
|
165
|
+
- config/database.yml.travis
|
166
|
+
- config/environment.rb
|
167
|
+
- config/environments/development.rb
|
168
|
+
- config/environments/production.rb
|
169
|
+
- config/environments/test.rb
|
170
|
+
- config/locales/en.yml
|
171
|
+
- config/routes.rb
|
172
|
+
- config/secrets.yml
|
173
|
+
- db/migrate/20150214192135_create_test_tables.rb
|
174
|
+
- db/migrate/20150710162236_create_composite_models_table.rb
|
175
|
+
- db/schema.rb
|
176
|
+
- db/seeds.rb
|
125
177
|
- lib/postgres_upsert.rb
|
126
|
-
- lib/postgres_upsert/
|
178
|
+
- lib/postgres_upsert/model_to_model_adapter.rb
|
179
|
+
- lib/postgres_upsert/read_adapters/active_record_adapter.rb
|
180
|
+
- lib/postgres_upsert/read_adapters/file_adapter.rb
|
181
|
+
- lib/postgres_upsert/read_adapters/io_adapter.rb
|
182
|
+
- lib/postgres_upsert/result.rb
|
183
|
+
- lib/postgres_upsert/table_writer.rb
|
184
|
+
- lib/postgres_upsert/write_adapters/active_record_adapter.rb
|
185
|
+
- lib/postgres_upsert/write_adapters/table_adapter.rb
|
127
186
|
- lib/postgres_upsert/writer.rb
|
128
187
|
- postgres_upsert.gemspec
|
129
|
-
- spec/
|
188
|
+
- spec/composite_key_spec.rb
|
130
189
|
- spec/fixtures/comma_with_header.csv
|
131
190
|
- spec/fixtures/comma_with_header_and_comma_values.csv
|
132
191
|
- spec/fixtures/comma_with_header_and_unquoted_comma.csv
|
192
|
+
- spec/fixtures/comma_with_header_duplicate.csv
|
133
193
|
- spec/fixtures/comma_without_header.csv
|
194
|
+
- spec/fixtures/composite_key_model.rb
|
195
|
+
- spec/fixtures/composite_key_with_header.csv
|
196
|
+
- spec/fixtures/composite_nonkey_with_header.csv
|
134
197
|
- spec/fixtures/no_id.csv
|
135
198
|
- spec/fixtures/reserved_word_model.rb
|
136
199
|
- spec/fixtures/reserved_words.csv
|
@@ -143,41 +206,46 @@ files:
|
|
143
206
|
- spec/fixtures/tab_with_header.csv
|
144
207
|
- spec/fixtures/tab_with_two_lines.csv
|
145
208
|
- spec/fixtures/test_model.rb
|
209
|
+
- spec/fixtures/test_model_copy.rb
|
146
210
|
- spec/fixtures/three_column.rb
|
147
|
-
- spec/
|
211
|
+
- spec/from_table_spec.rb
|
148
212
|
- spec/pg_upsert_csv_spec.rb
|
149
|
-
- spec/
|
213
|
+
- spec/rails_helper.rb
|
150
214
|
- spec/spec_helper.rb
|
151
215
|
homepage: https://github.com/theSteveMitchell/postgres_upsert
|
152
|
-
licenses:
|
216
|
+
licenses:
|
217
|
+
- MIT
|
153
218
|
metadata: {}
|
154
|
-
post_install_message:
|
219
|
+
post_install_message:
|
155
220
|
rdoc_options: []
|
156
221
|
require_paths:
|
157
222
|
- lib
|
158
223
|
required_ruby_version: !ruby/object:Gem::Requirement
|
159
224
|
requirements:
|
160
|
-
- -
|
225
|
+
- - ">="
|
161
226
|
- !ruby/object:Gem::Version
|
162
227
|
version: 1.8.7
|
163
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
229
|
requirements:
|
165
|
-
- -
|
230
|
+
- - ">="
|
166
231
|
- !ruby/object:Gem::Version
|
167
232
|
version: '0'
|
168
233
|
requirements: []
|
169
|
-
|
170
|
-
|
171
|
-
signing_key:
|
234
|
+
rubygems_version: 3.2.3
|
235
|
+
signing_key:
|
172
236
|
specification_version: 4
|
173
237
|
summary: A rubygem that integrates with ActiveRecord to insert/update large data sets
|
174
238
|
into the database efficiently
|
175
239
|
test_files:
|
176
|
-
- spec/
|
240
|
+
- spec/composite_key_spec.rb
|
177
241
|
- spec/fixtures/comma_with_header.csv
|
178
242
|
- spec/fixtures/comma_with_header_and_comma_values.csv
|
179
243
|
- spec/fixtures/comma_with_header_and_unquoted_comma.csv
|
244
|
+
- spec/fixtures/comma_with_header_duplicate.csv
|
180
245
|
- spec/fixtures/comma_without_header.csv
|
246
|
+
- spec/fixtures/composite_key_model.rb
|
247
|
+
- spec/fixtures/composite_key_with_header.csv
|
248
|
+
- spec/fixtures/composite_nonkey_with_header.csv
|
181
249
|
- spec/fixtures/no_id.csv
|
182
250
|
- spec/fixtures/reserved_word_model.rb
|
183
251
|
- spec/fixtures/reserved_words.csv
|
@@ -190,8 +258,9 @@ test_files:
|
|
190
258
|
- spec/fixtures/tab_with_header.csv
|
191
259
|
- spec/fixtures/tab_with_two_lines.csv
|
192
260
|
- spec/fixtures/test_model.rb
|
261
|
+
- spec/fixtures/test_model_copy.rb
|
193
262
|
- spec/fixtures/three_column.rb
|
194
|
-
- spec/
|
263
|
+
- spec/from_table_spec.rb
|
195
264
|
- spec/pg_upsert_csv_spec.rb
|
196
|
-
- spec/
|
265
|
+
- spec/rails_helper.rb
|
197
266
|
- spec/spec_helper.rb
|