diff options
author | Paul Gallagher <gallagher.paul@gmail.com> | 2011-06-11 02:07:08 +0800 |
---|---|---|
committer | Paul Gallagher <gallagher.paul@gmail.com> | 2011-06-11 02:21:24 +0800 |
commit | 1d7c751bf703c729887e2d8a9ae104a8e6aef010 (patch) | |
tree | 948b3b7a008be903ba535ebfcd8e9d5c0b950103 /activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | |
parent | 019c263633242f4329f44f863705435f58e1d884 (diff) | |
download | rails-1d7c751bf703c729887e2d8a9ae104a8e6aef010.tar.gz rails-1d7c751bf703c729887e2d8a9ae104a8e6aef010.tar.bz2 rails-1d7c751bf703c729887e2d8a9ae104a8e6aef010.zip |
remove table quoting in primary_key method
* add/cleanup tests
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index 9943cd18f6..d57794daf8 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -74,6 +74,36 @@ module ActiveRecord @connection.default_sequence_name('zomg') end + def test_pk_and_sequence_for + pk, seq = @connection.pk_and_sequence_for('ex') + assert_equal 'id', pk + assert_equal @connection.default_sequence_name('ex', 'id'), seq + end + + def test_pk_and_sequence_for_with_non_standard_primary_key + @connection.exec_query('drop table if exists ex') + @connection.exec_query('create table ex(code serial primary key)') + pk, seq = @connection.pk_and_sequence_for('ex') + assert_equal 'code', pk + assert_equal @connection.default_sequence_name('ex', 'code'), seq + end + + def test_pk_and_sequence_for_returns_nil_if_no_seq + @connection.exec_query('drop table if exists ex') + @connection.exec_query('create table ex(id integer primary key)') + assert_nil @connection.pk_and_sequence_for('ex') + end + + def test_pk_and_sequence_for_returns_nil_if_no_pk + @connection.exec_query('drop table if exists ex') + @connection.exec_query('create table ex(id integer)') + assert_nil @connection.pk_and_sequence_for('ex') + end + + def test_pk_and_sequence_for_returns_nil_if_table_not_found + assert_nil @connection.pk_and_sequence_for('unobtainium') + end + def test_exec_insert_number insert(@connection, 'number' => 10) |