aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-18 07:52:58 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-18 07:52:58 +0000
commit03097d3a6047e269641a14f4c93838598011f0b5 (patch)
treea30a49108dfffc631ee4eb652fce7b41bb4b517e /activerecord/test
parentb8c07c0325fdfee701de1a68811c941bced606be (diff)
downloadrails-03097d3a6047e269641a14f4c93838598011f0b5.tar.gz
rails-03097d3a6047e269641a14f4c93838598011f0b5.tar.bz2
rails-03097d3a6047e269641a14f4c93838598011f0b5.zip
Fixed that fixtures were being deleted in the same order as inserts causing FK errors #890 [andrew.john.peters@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1205 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/fixtures/db_definitions/db2.sql11
-rwxr-xr-xactiverecord/test/fixtures/db_definitions/mysql.sql11
-rw-r--r--activerecord/test/fixtures/db_definitions/oci.sql9
-rw-r--r--activerecord/test/fixtures/db_definitions/postgresql.sql9
-rw-r--r--activerecord/test/fixtures/db_definitions/sqlite.sql11
-rw-r--r--activerecord/test/fixtures/db_definitions/sqlserver.sql11
-rw-r--r--activerecord/test/fixtures/fk_test_has_fk.yml3
-rw-r--r--activerecord/test/fixtures/fk_test_has_pk.yml2
-rwxr-xr-xactiverecord/test/fixtures_test.rb24
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
+
+
+
+
+
+