diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-11 14:38:42 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-11 14:38:42 -0700 |
commit | 622f23b604546784aeab3cca5a47f0d6b281cf91 (patch) | |
tree | 10e61826a12b5c767a221b925d8e507c748227e8 /activerecord/test/cases/adapters/postgresql | |
parent | 75dc9fbac76a2da78b8d21e1ede16fea38d16564 (diff) | |
download | rails-622f23b604546784aeab3cca5a47f0d6b281cf91.tar.gz rails-622f23b604546784aeab3cca5a47f0d6b281cf91.tar.bz2 rails-622f23b604546784aeab3cca5a47f0d6b281cf91.zip |
wrap the pg_get_serial_sequence function and reuse it for the default sequence name
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | 25 |
1 files changed, 25 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 861e3344b2..2d412a6e2a 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -10,6 +10,31 @@ module ActiveRecord @connection.exec_query('create table ex(id serial primary key, number integer, data character varying(255))') end + def test_serial_sequence + assert_equal 'public.accounts_id_seq', + @connection.serial_sequence('accounts', 'id') + + assert_raises(ActiveRecord::StatementInvalid) do + @connection.serial_sequence('zomg', 'id') + end + end + + def test_default_sequence_name + assert_equal 'accounts_id_seq', + @connection.default_sequence_name('accounts', 'id') + + assert_equal 'accounts_id_seq', + @connection.default_sequence_name('accounts') + end + + def test_default_sequence_name_bad_table + assert_equal 'zomg_id_seq', + @connection.default_sequence_name('zomg', 'id') + + assert_equal 'zomg_id_seq', + @connection.default_sequence_name('zomg') + end + def test_exec_insert_number insert(@connection, 'number' => 10) |