Skip to content

Commit 8a23fd4

Browse files
committed
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)`.
1 parent e994926 commit 8a23fd4

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

activerecord/test/cases/migration/foreign_key_test.rb

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,23 @@ def test_add_foreign_key_with_column
9494
end
9595

9696
def test_add_foreign_key_with_non_standard_primary_key
97-
with_example_table @connection, "space_shuttles", "pk BIGINT PRIMARY KEY" do
98-
@connection.add_foreign_key(:astronauts, :space_shuttles,
99-
column: "rocket_id", primary_key: "pk", name: "custom_pk")
97+
@connection.create_table :space_shuttles, id: false, force: true do |t|
98+
t.bigint :pk, primary_key: true
99+
end
100100

101-
foreign_keys = @connection.foreign_keys("astronauts")
102-
assert_equal 1, foreign_keys.size
101+
@connection.add_foreign_key(:astronauts, :space_shuttles,
102+
column: "rocket_id", primary_key: "pk", name: "custom_pk")
103103

104-
fk = foreign_keys.first
105-
assert_equal "astronauts", fk.from_table
106-
assert_equal "space_shuttles", fk.to_table
107-
assert_equal "pk", fk.primary_key
104+
foreign_keys = @connection.foreign_keys("astronauts")
105+
assert_equal 1, foreign_keys.size
108106

109-
@connection.remove_foreign_key :astronauts, name: "custom_pk"
110-
end
107+
fk = foreign_keys.first
108+
assert_equal "astronauts", fk.from_table
109+
assert_equal "space_shuttles", fk.to_table
110+
assert_equal "pk", fk.primary_key
111+
ensure
112+
@connection.remove_foreign_key :astronauts, name: "custom_pk"
113+
@connection.drop_table :space_shuttles
111114
end
112115

113116
def test_add_on_delete_restrict_foreign_key

0 commit comments

Comments
 (0)