postgres-copy 1.6.0 → 1.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff5750f062c23bbbaf42c2c4b54e0d10a2a18c45eda5a66e00abd2fa0d3d9cdc
4
- data.tar.gz: 10920c6056c38c5cc4a83ba0ace5164abf8a9eb6276e5cef7a4c19e39424de11
3
+ metadata.gz: bfe11c5653d850edd47a3df54bcbb83600f820b35a297f05d363b6e89b8b27ff
4
+ data.tar.gz: 25a187d205ca18ad00e9a35de9a3fabc400137a56af61fce58eac5f7713491af
5
5
  SHA512:
6
- metadata.gz: 25c750eb0da06933151e7707f67fa52b9973e603d2afe3288241acf34dc61f7004179483339e630e245660f4371c9f1ddb086e9e8f3a80b32c8bc5d180a79937
7
- data.tar.gz: 8e537afc3c20801bcac073f208225d8375cc25b14b40ebbe80f904eef79ffded4c00ed672987094a08691d84dbaf1818d71fbf0ec2aeedba8d9d2a611298b68d
6
+ metadata.gz: bf7bdfb2fc14b24ede0973c7e573ed30507c77c205cfe87aa13f9302ad31d988360bcebec83b5ee1c83d266c14d8b42728fb17d5a07c222babc3aab5438562ce
7
+ data.tar.gz: b0f085dbbd1fbd684a00d97eda965f7074d52b8e8f0fe07657f33a5a5fcbd9ab4041a71956e640c5b40140c125675f20479044e1aea5b7bea1d1aba9d51e4227
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- postgres-copy (1.6.0)
4
+ postgres-copy (1.6.1)
5
5
  activerecord (>= 5.1)
6
6
  pg (>= 0.17)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (7.0.1)
12
- activesupport (= 7.0.1)
13
- activerecord (7.0.1)
14
- activemodel (= 7.0.1)
15
- activesupport (= 7.0.1)
16
- activesupport (7.0.1)
11
+ activemodel (7.0.4)
12
+ activesupport (= 7.0.4)
13
+ activerecord (7.0.4)
14
+ activemodel (= 7.0.4)
15
+ activesupport (= 7.0.4)
16
+ activesupport (7.0.4)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
20
20
  tzinfo (~> 2.0)
21
- concurrent-ruby (1.1.9)
21
+ concurrent-ruby (1.1.10)
22
22
  diff-lcs (1.4.4)
23
- i18n (1.9.1)
23
+ i18n (1.12.0)
24
24
  concurrent-ruby (~> 1.0)
25
- minitest (5.15.0)
26
- pg (1.2.3)
25
+ minitest (5.16.3)
26
+ pg (1.4.3)
27
27
  rake (11.2.2)
28
28
  rdoc (6.2.1)
29
29
  rspec (2.99.0)
@@ -34,7 +34,7 @@ GEM
34
34
  rspec-expectations (2.99.2)
35
35
  diff-lcs (>= 1.1.3, < 2.0)
36
36
  rspec-mocks (2.99.4)
37
- tzinfo (2.0.4)
37
+ tzinfo (2.0.5)
38
38
  concurrent-ruby (~> 1.0)
39
39
 
40
40
  PLATFORMS
@@ -108,7 +108,7 @@ module PostgresCopy
108
108
  quoted_table_name
109
109
  end
110
110
 
111
- columns_list = columns_list.map{|c| options[:map][c.to_s] } if options[:map]
111
+ columns_list = columns_list.map{|c| options[:map][c.to_s] || c.to_s } if options[:map]
112
112
  columns_string = columns_list.size > 0 ? "(\"#{columns_list.join('","')}\")" : ""
113
113
  connection.raw_connection.copy_data %{COPY #{table} #{columns_string} FROM STDIN #{options_string}} do
114
114
  if options[:format] == :binary
@@ -5,7 +5,7 @@ $:.unshift lib unless $:.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "postgres-copy"
8
- s.version = "1.6.0"
8
+ s.version = "1.6.1"
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.required_ruby_version = ">= 1.9.3"
11
11
  s.authors = ["Diogo Biazus"]
@@ -14,6 +14,12 @@ describe "COPY FROM" do
14
14
  TestModel.order(:id).map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'test data 1'}]
15
15
  end
16
16
 
17
+ it "should import from file if path is with a field_map" do
18
+ TestModel.copy_from File.expand_path('spec/fixtures/comma_with_header_to_map.csv'), map: {'ref' => 'id'}
19
+ TestModel.order(:id).map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'test data 1'}]
20
+ end
21
+
22
+
17
23
  it "should import from IO without field_map" do
18
24
  TestModel.copy_from File.open(File.expand_path('spec/fixtures/comma_with_header.csv'), 'r')
19
25
  TestModel.order(:id).map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'test data 1'}]
@@ -0,0 +1,2 @@
1
+ ref,data
2
+ 1,test data 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres-copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diogo Biazus
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -127,6 +127,7 @@ files:
127
127
  - spec/fixtures/comma_with_header_and_scope.csv
128
128
  - spec/fixtures/comma_with_header_empty_values_at_the_end.csv
129
129
  - spec/fixtures/comma_with_header_multi.csv
130
+ - spec/fixtures/comma_with_header_to_map.csv
130
131
  - spec/fixtures/comma_without_header.csv
131
132
  - spec/fixtures/extra_field.rb
132
133
  - spec/fixtures/reserved_word_model.rb
@@ -151,7 +152,7 @@ files:
151
152
  homepage: http://github.com/diogob/postgres-copy
152
153
  licenses: []
153
154
  metadata: {}
154
- post_install_message:
155
+ post_install_message:
155
156
  rdoc_options: []
156
157
  require_paths:
157
158
  - lib
@@ -166,8 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  - !ruby/object:Gem::Version
167
168
  version: '0'
168
169
  requirements: []
169
- rubygems_version: 3.2.3
170
- signing_key:
170
+ rubygems_version: 3.1.6
171
+ signing_key:
171
172
  specification_version: 4
172
173
  summary: Put COPY command functionality in ActiveRecord's model class
173
174
  test_files: []