Enable ImportSupport on Postgresql - the test suite now passes in full
This commit is contained in:
parent
7bd0e2693a
commit
a3e9b4f040
|
@ -1,5 +1,11 @@
|
||||||
module ActiveRecord::Import::PostgreSQLAdapter
|
module ActiveRecord::Import::PostgreSQLAdapter
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
def self.included(klass)
|
||||||
|
klass.instance_eval do
|
||||||
|
include ActiveRecord::Import::ImportSupport
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def next_value_for_sequence(sequence_name)
|
def next_value_for_sequence(sequence_name)
|
||||||
%{nextval('#{sequence_name}')}
|
%{nextval('#{sequence_name}')}
|
||||||
end
|
end
|
||||||
|
|
20
test/postgresql/import_test.rb
Normal file
20
test/postgresql/import_test.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
|
describe "#supports_imports?" do
|
||||||
|
it "should support import" do
|
||||||
|
assert ActiveRecord::Base.supports_import?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#import" do
|
||||||
|
it "should import with a single insert" do
|
||||||
|
# see ActiveRecord::ConnectionAdapters::AbstractAdapter test for more specifics
|
||||||
|
assert_difference "Topic.count", +10 do
|
||||||
|
result = Topic.import Build(3, :topics)
|
||||||
|
assert_equal 1, result.num_inserts
|
||||||
|
|
||||||
|
result = Topic.import Build(7, :topics)
|
||||||
|
assert_equal 1, result.num_inserts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue