From 263479b5a344e5882f4941e3f18faf9f027b0615 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sat, 18 Mar 2006 05:43:35 +0000 Subject: 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 --- activerecord/test/adapter_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activerecord/test') 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' -- cgit v1.2.3