diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/fixtures/db_definitions/db2.sql | 11 | ||||
-rwxr-xr-x | activerecord/test/fixtures/db_definitions/mysql.sql | 11 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/oci.sql | 9 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/postgresql.sql | 9 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/sqlite.sql | 11 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/sqlserver.sql | 11 | ||||
-rw-r--r-- | activerecord/test/fixtures/fk_test_has_fk.yml | 3 | ||||
-rw-r--r-- | activerecord/test/fixtures/fk_test_has_pk.yml | 2 | ||||
-rwxr-xr-x | activerecord/test/fixtures_test.rb | 24 |
9 files changed, 91 insertions, 0 deletions
diff --git a/activerecord/test/fixtures/db_definitions/db2.sql b/activerecord/test/fixtures/db_definitions/db2.sql index 35efa3f6c7..1097568ce3 100644 --- a/activerecord/test/fixtures/db_definitions/db2.sql +++ b/activerecord/test/fixtures/db_definitions/db2.sql @@ -164,3 +164,14 @@ CREATE TABLE categories_posts ( category_id int NOT NULL, post_id int NOT NULL ); + +CREATE TABLE fk_test_has_pk ( + id INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE fk_test_has_fk ( + id INTEGER NOT NULL PRIMARY KEY, + fk_id INTEGER NOT NULL, + + FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id) +); diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql index 294f227be3..da4a69252f 100755 --- a/activerecord/test/fixtures/db_definitions/mysql.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.sql @@ -166,3 +166,14 @@ CREATE TABLE `categories_posts` ( `category_id` int(11) NOT NULL, `post_id` int(11) NOT NULL ); + +CREATE TABLE `fk_test_has_pk` ( + `id` INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE `fk_test_has_fk` ( + `id` INTEGER NOT NULL PRIMARY KEY, + `fk_id` INTEGER NOT NULL, + + FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`) +); diff --git a/activerecord/test/fixtures/db_definitions/oci.sql b/activerecord/test/fixtures/db_definitions/oci.sql index 29e6c76e2a..62f9ae9fb4 100644 --- a/activerecord/test/fixtures/db_definitions/oci.sql +++ b/activerecord/test/fixtures/db_definitions/oci.sql @@ -202,3 +202,12 @@ create table categories_posts ( category_id integer not null references developers initially deferred disable, post_id int integer not null references developers initially deferred disable ); + +create table fk_test_has_pk ( + id integer not null primary key +); + +create table fk_test_has_fk ( + id integer not null primary key, + fk_id integer not null references fk_test_has_fk initially deferred disable, +); diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql index 2bc18dfb2b..9b57866368 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.sql @@ -183,3 +183,12 @@ CREATE TABLE categories_posts ( category_id integer NOT NULL, post_id integer NOT NULL ); + +CREATE TABLE fk_test_has_pk ( + id INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE fk_test_has_fk ( + id INTEGER NOT NULL PRIMARY KEY, + fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id) +); diff --git a/activerecord/test/fixtures/db_definitions/sqlite.sql b/activerecord/test/fixtures/db_definitions/sqlite.sql index 33c85b4d1c..4507e2c4b2 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.sql @@ -151,3 +151,14 @@ CREATE TABLE 'categories_posts' ( 'category_id' INTEGER NOT NULL, 'post_id' INTEGER NOT NULL ); + +CREATE TABLE 'fk_test_has_pk' ( + 'id' INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE 'fk_test_has_fk' ( + 'id' INTEGER NOT NULL PRIMARY KEY, + 'fk_id' INTEGER NOT NULL, + + FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id') +); diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index c6cec8312d..776ac23610 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -151,3 +151,14 @@ CREATE TABLE categories_posts ( category_id int NOT NULL, post_id int NOT NULL ); + +CREATE TABLE fk_test_has_pk ( + id INTEGER NOT NULL PRIMARY KEY +); + +CREATE TABLE fk_test_has_fk ( + id INTEGER NOT NULL PRIMARY KEY, + fk_id INTEGER NOT NULL, + + FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id) +); diff --git a/activerecord/test/fixtures/fk_test_has_fk.yml b/activerecord/test/fixtures/fk_test_has_fk.yml new file mode 100644 index 0000000000..67d914e130 --- /dev/null +++ b/activerecord/test/fixtures/fk_test_has_fk.yml @@ -0,0 +1,3 @@ +first: + id: 1 + fk_id: 1 diff --git a/activerecord/test/fixtures/fk_test_has_pk.yml b/activerecord/test/fixtures/fk_test_has_pk.yml new file mode 100644 index 0000000000..c93952180b --- /dev/null +++ b/activerecord/test/fixtures/fk_test_has_pk.yml @@ -0,0 +1,2 @@ +first: + id: 1
\ No newline at end of file diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb index 687ce817f6..e1f2f6d24c 100755 --- a/activerecord/test/fixtures_test.rb +++ b/activerecord/test/fixtures_test.rb @@ -179,3 +179,27 @@ class OverlappingFixturesTest < Test::Unit::TestCase assert_equal([:topics, :developers, :accounts], fixture_table_names) end end + + +class ForeignKeyFixturesTest < Test::Unit::TestCase + fixtures :fk_test_has_pk, :fk_test_has_fk + + # if foreign keys are implemented and fixtures + # are not deleted in reverse order then this test + # case will raise StatementInvalid + + def test_number1 + assert true + end + + def test_number2 + assert true + end + +end + + + + + + |