diff options
author | Marcel Molina <marcel@vernix.org> | 2005-10-12 19:55:46 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2005-10-12 19:55:46 +0000 |
commit | f0b2b637ea9b7133fce95f1fc10eec6b1c7304d9 (patch) | |
tree | 9de4101cc210b7e8dbbb4b1d1c3e0dbebeef3fce /activerecord/test/fixtures | |
parent | de42f26df787af135baef65f59aa145873714aa5 (diff) | |
download | rails-f0b2b637ea9b7133fce95f1fc10eec6b1c7304d9.tar.gz rails-f0b2b637ea9b7133fce95f1fc10eec6b1c7304d9.tar.bz2 rails-f0b2b637ea9b7133fce95f1fc10eec6b1c7304d9.zip |
Add test coverage for customized primary keys including a failing test for #2444.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2540 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/fixtures')
14 files changed, 43 insertions, 5 deletions
diff --git a/activerecord/test/fixtures/db_definitions/db2.drop.sql b/activerecord/test/fixtures/db_definitions/db2.drop.sql index 5937b09515..07bffb6019 100644 --- a/activerecord/test/fixtures/db_definitions/db2.drop.sql +++ b/activerecord/test/fixtures/db_definitions/db2.drop.sql @@ -24,4 +24,4 @@ DROP TABLE categories; DROP TABLE categories_posts; DROP TABLE fk_test_has_pk; DROP TABLE fk_test_has_fk; - +DROP TABLE keyboards; diff --git a/activerecord/test/fixtures/db_definitions/db2.sql b/activerecord/test/fixtures/db_definitions/db2.sql index 9c41f7eede..49f31aba67 100644 --- a/activerecord/test/fixtures/db_definitions/db2.sql +++ b/activerecord/test/fixtures/db_definitions/db2.sql @@ -179,6 +179,11 @@ CREATE TABLE categories_posts ( post_id int NOT NULL ); +CREATE TABLE keyboards ( + key_number int generated by default as identity (start with +10000), + name VARCHAR(255) +); + CREATE TABLE fk_test_has_pk ( id INTEGER NOT NULL PRIMARY KEY ); diff --git a/activerecord/test/fixtures/db_definitions/mysql.drop.sql b/activerecord/test/fixtures/db_definitions/mysql.drop.sql index b4be3c625e..8a37e2deae 100644 --- a/activerecord/test/fixtures/db_definitions/mysql.drop.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.drop.sql @@ -24,3 +24,4 @@ DROP TABLE categories; DROP TABLE categories_posts; DROP TABLE fk_test_has_fk; DROP TABLE fk_test_has_pk; +DROP TABLE keyboards; diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql index 393a6e808e..d9b98042ae 100755 --- a/activerecord/test/fixtures/db_definitions/mysql.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.sql @@ -191,3 +191,9 @@ CREATE TABLE `fk_test_has_fk` ( FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`) ) TYPE=InnoDB; + + +CREATE TABLE `keyboards` ( + `key_number` int(11) NOT NULL auto_increment primary key, + `name` varchar(50) default NULL +); diff --git a/activerecord/test/fixtures/db_definitions/oci.drop.sql b/activerecord/test/fixtures/db_definitions/oci.drop.sql index 08534b8d92..5a3a663703 100644 --- a/activerecord/test/fixtures/db_definitions/oci.drop.sql +++ b/activerecord/test/fixtures/db_definitions/oci.drop.sql @@ -25,6 +25,7 @@ drop table categories; drop table posts; drop table fk_test_has_pk; drop table fk_test_has_fk; +drop table keyboards; drop sequence accounts_seq; drop sequence companies_nonstd_seq; drop sequence topics_seq; @@ -51,3 +52,4 @@ drop sequence categories_seq; drop sequence categories_posts_seq; drop sequence fk_test_has_pk_seq; drop sequence fk_test_has_fk_seq; +drop sequence keyboards_seq; diff --git a/activerecord/test/fixtures/db_definitions/oci.sql b/activerecord/test/fixtures/db_definitions/oci.sql index f6e958d7c2..8a8dcd0681 100644 --- a/activerecord/test/fixtures/db_definitions/oci.sql +++ b/activerecord/test/fixtures/db_definitions/oci.sql @@ -254,3 +254,8 @@ create table fk_test_has_fk ( fk_id integer not null references fk_test_has_fk initially deferred disable ); create sequence fk_test_has_fk_seq minvalue 10000; + +create table keyboards ( + key_number integer not null, + name varchar(50) default null +); diff --git a/activerecord/test/fixtures/db_definitions/postgresql.drop.sql b/activerecord/test/fixtures/db_definitions/postgresql.drop.sql index 3a883e973f..d8d41cf974 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.drop.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.drop.sql @@ -26,3 +26,4 @@ DROP TABLE defaults; DROP TABLE fk_test_has_fk; DROP TABLE fk_test_has_pk; DROP TABLE geometrics; +DROP TABLE keyboards; diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql index 89cc89ab78..feea20b827 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.sql @@ -218,3 +218,8 @@ CREATE TABLE geometrics ( a_polygon polygon, a_circle circle ); + +CREATE TABLE keyboards ( + key_number serial primary key, + "name" character varying(50) +); diff --git a/activerecord/test/fixtures/db_definitions/sqlite.drop.sql b/activerecord/test/fixtures/db_definitions/sqlite.drop.sql index b4be3c625e..8a37e2deae 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.drop.sql @@ -24,3 +24,4 @@ DROP TABLE categories; DROP TABLE categories_posts; DROP TABLE fk_test_has_fk; DROP TABLE fk_test_has_pk; +DROP TABLE keyboards; diff --git a/activerecord/test/fixtures/db_definitions/sqlite.sql b/activerecord/test/fixtures/db_definitions/sqlite.sql index ebc5cb3a37..2e643f5930 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.sql @@ -176,3 +176,8 @@ CREATE TABLE 'fk_test_has_fk' ( FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id') ); + +CREATE TABLE 'keyboards' ( + 'key_number' INTEGER PRIMARY KEY NOT NULL, + 'name' VARCHAR(255) DEFAULT NULL +); diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql index 242f8d464c..4d78d6fda1 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql @@ -24,3 +24,4 @@ DROP TABLE categories; DROP TABLE categories_posts; DROP TABLE fk_test_has_pd; DROP TABLE fk_test_has_fk; +DROP TABLE keyboards; diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index e43b7db1c6..e27364091f 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -176,3 +176,8 @@ CREATE TABLE fk_test_has_fk ( FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id) ); + +CREATE TABLE keyboards ( + key_number int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + name varchar(50) default NULL +); diff --git a/activerecord/test/fixtures/keyboard.rb b/activerecord/test/fixtures/keyboard.rb new file mode 100644 index 0000000000..32a4a7fad0 --- /dev/null +++ b/activerecord/test/fixtures/keyboard.rb @@ -0,0 +1,3 @@ +class Keyboard < ActiveRecord::Base + set_primary_key 'key_number' +end diff --git a/activerecord/test/fixtures/subscriber.rb b/activerecord/test/fixtures/subscriber.rb index e5e11724fd..51335a8f20 100644 --- a/activerecord/test/fixtures/subscriber.rb +++ b/activerecord/test/fixtures/subscriber.rb @@ -1,8 +1,6 @@ class Subscriber < ActiveRecord::Base - def self.primary_key - "nick" - end + set_primary_key 'nick' end class SpecialSubscriber < Subscriber -end
\ No newline at end of file +end |