diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-18 05:43:35 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-18 05:43:35 +0000 |
commit | 263479b5a344e5882f4941e3f18faf9f027b0615 (patch) | |
tree | 48651b12eb1af9c6b7d02b2d50c203cc9fe68b39 /activerecord/test | |
parent | 459559a8bced28f25888802e40c7182392ea94cc (diff) | |
download | rails-263479b5a344e5882f4941e3f18faf9f027b0615.tar.gz rails-263479b5a344e5882f4941e3f18faf9f027b0615.tar.bz2 rails-263479b5a344e5882f4941e3f18faf9f027b0615.zip |
Add AbstractAdapter#table_alias_for to create table aliases according to the rules of the current adapter. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3916 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/adapter_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/adapter_test.rb b/activerecord/test/adapter_test.rb index af76ebfc9a..2c98045cee 100644 --- a/activerecord/test/adapter_test.rb +++ b/activerecord/test/adapter_test.rb @@ -46,6 +46,19 @@ class AdapterTest < Test::Unit::TestCase end end + def test_table_alias + old = @connection.table_alias_length + def @connection.table_alias_length() 10; end + + assert_equal 'posts', @connection.table_alias_for('posts') + assert_equal 'posts', @connection.table_alias_for('posts', 1) + assert_equal 'posts_2', @connection.table_alias_for('posts', 2) + assert_equal 'posts_comm', @connection.table_alias_for('posts_comments') + assert_equal 'posts_co_2', @connection.table_alias_for('posts_comments', 2) + + def @connection.table_alias_length() old; end + end + # test resetting sequences in odd tables in postgreSQL if ActiveRecord::Base.connection.respond_to?(:reset_pk_sequence!) require 'fixtures/movie' |