aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2017-02-14 02:04:51 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2017-02-14 13:22:17 +0000
commit8a23fd4920a8f0b2b9b8c2d36c63006f46ae411b (patch)
treee767e648f67916c46885505e5ee509e613718a52 /activerecord
parente9949265d9fb6e20aa4c73f189147812db377edc (diff)
downloadrails-8a23fd4920a8f0b2b9b8c2d36c63006f46ae411b.tar.gz
rails-8a23fd4920a8f0b2b9b8c2d36c63006f46ae411b.tar.bz2
rails-8a23fd4920a8f0b2b9b8c2d36c63006f46ae411b.zip
Use ActiveRecord `bigint` type, not SQL literal bigint
Oracle database itself does not have `bigint` SQL type, then it gets `ORA-00902: invalid datatype`. It can be addressed by using ActiveRecord `bigint` type because Oracle enhanced adapter recognizes ActiveRecord `bigint` type and transfer it to its equivalent SQL type `NUMBER(19)`.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/migration/foreign_key_test.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/activerecord/test/cases/migration/foreign_key_test.rb b/activerecord/test/cases/migration/foreign_key_test.rb
index 2258290a3c..9d8f146693 100644
--- a/activerecord/test/cases/migration/foreign_key_test.rb
+++ b/activerecord/test/cases/migration/foreign_key_test.rb
@@ -94,20 +94,23 @@ if ActiveRecord::Base.connection.supports_foreign_keys?
end
def test_add_foreign_key_with_non_standard_primary_key
- with_example_table @connection, "space_shuttles", "pk BIGINT PRIMARY KEY" do
- @connection.add_foreign_key(:astronauts, :space_shuttles,
- column: "rocket_id", primary_key: "pk", name: "custom_pk")
+ @connection.create_table :space_shuttles, id: false, force: true do |t|
+ t.bigint :pk, primary_key: true
+ end
- foreign_keys = @connection.foreign_keys("astronauts")
- assert_equal 1, foreign_keys.size
+ @connection.add_foreign_key(:astronauts, :space_shuttles,
+ column: "rocket_id", primary_key: "pk", name: "custom_pk")
- fk = foreign_keys.first
- assert_equal "astronauts", fk.from_table
- assert_equal "space_shuttles", fk.to_table
- assert_equal "pk", fk.primary_key
+ foreign_keys = @connection.foreign_keys("astronauts")
+ assert_equal 1, foreign_keys.size
- @connection.remove_foreign_key :astronauts, name: "custom_pk"
- end
+ fk = foreign_keys.first
+ assert_equal "astronauts", fk.from_table
+ assert_equal "space_shuttles", fk.to_table
+ assert_equal "pk", fk.primary_key
+ ensure
+ @connection.remove_foreign_key :astronauts, name: "custom_pk"
+ @connection.drop_table :space_shuttles
end
def test_add_on_delete_restrict_foreign_key