aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/primary_keys_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/primary_keys_test.rb')
-rw-r--r--activerecord/test/cases/primary_keys_test.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index df83fe0ea1..a36d786b40 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -334,16 +334,26 @@ class CompositePrimaryKeyTest < ActiveRecord::TestCase
t.string :region
t.integer :code
end
+ @connection.create_table(:travels, primary_key: ["from", "to"], force: true) do |t|
+ t.string :from
+ t.string :to
+ end
end
def teardown
- @connection.drop_table(:uber_barcodes, if_exists: true)
+ @connection.drop_table :uber_barcodes, if_exists: true
+ @connection.drop_table :barcodes_reverse, if_exists: true
+ @connection.drop_table :travels, if_exists: true
end
def test_composite_primary_key
assert_equal ["region", "code"], @connection.primary_keys("uber_barcodes")
end
+ def test_composite_primary_key_with_reserved_words
+ assert_equal ["from", "to"], @connection.primary_keys("travels")
+ end
+
def test_composite_primary_key_out_of_order
skip if current_adapter?(:SQLite3Adapter)
assert_equal ["code", "region"], @connection.primary_keys("barcodes_reverse")
@@ -434,7 +444,7 @@ if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter)
test "schema dump primary key with serial/integer" do
@connection.create_table(:widgets, id: @pk_type, force: true)
schema = dump_table_schema "widgets"
- assert_match %r{create_table "widgets", id: :#{@pk_type}, force: :cascade}, schema
+ assert_match %r{create_table "widgets", id: :#{@pk_type}, }, schema
end
if current_adapter?(:Mysql2Adapter)
@@ -447,7 +457,7 @@ if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter)
assert column.unsigned?
schema = dump_table_schema "widgets"
- assert_match %r{create_table "widgets", id: :integer, unsigned: true, force: :cascade}, schema
+ assert_match %r{create_table "widgets", id: :integer, unsigned: true, }, schema
end
test "bigint primary key with unsigned" do
@@ -459,7 +469,7 @@ if current_adapter?(:PostgreSQLAdapter, :Mysql2Adapter)
assert column.unsigned?
schema = dump_table_schema "widgets"
- assert_match %r{create_table "widgets", id: :bigint, unsigned: true, force: :cascade}, schema
+ assert_match %r{create_table "widgets", id: :bigint, unsigned: true, }, schema
end
end
end