activerecord-import 0.2.3 → 0.2.4

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -129,7 +129,8 @@ module ActiveRecord::Import::AbstractAdapter
129
129
  array_of_attributes.each do |arr|
130
130
  my_values = []
131
131
  arr.each_with_index do |val,j|
132
- my_values << quote( val, columns[j] )
132
+ importable_value = columns[j].type_cast(val)
133
+ my_values << quote(importable_value, columns[j] )
133
134
  end
134
135
  values << my_values
135
136
  end
@@ -257,7 +257,7 @@ class ActiveRecord::Base
257
257
  def import_without_validations_or_callbacks( column_names, array_of_attributes, options={} )
258
258
  escaped_column_names = quote_column_names( column_names )
259
259
  columns = []
260
- array_of_attributes.first.each_with_index { |arr,i| columns << columns_hash[ column_names[i] ] }
260
+ array_of_attributes.first.each_with_index { |arr,i| columns << columns_hash[ column_names[i].to_s ] }
261
261
 
262
262
  if not supports_import?
263
263
  columns_sql = "(" + escaped_column_names.join( ',' ) + ")"
data/test/import_test.rb CHANGED
@@ -199,4 +199,16 @@ describe "#import" do
199
199
  end
200
200
  end
201
201
 
202
+ context "importing a datetime field" do
203
+ it "should import a date with MM/DD/YYYY format just fine" do
204
+ Topic.import [:author_name, :title, :last_read], [["Bob Jones", "Topic 1", "05/14/2010"]]
205
+ assert_equal "05/14/2010".to_date, Topic.last.last_read.to_date
206
+ end
207
+
208
+ it "should import a date with YYYY/MM/DD format just fine" do
209
+ Topic.import [:author_name, :title, :last_read], [["Bob Jones", "Topic 2", "2010/05/14"]]
210
+ assert_equal "05/14/2010".to_date, Topic.last.last_read.to_date
211
+ end
212
+ end
213
+
202
214
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-import
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Dennis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-03 00:00:00 -04:00
18
+ date: 2011-01-05 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency