aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-03-18 05:43:35 +0000
committerRick Olson <technoweenie@gmail.com>2006-03-18 05:43:35 +0000
commit263479b5a344e5882f4941e3f18faf9f027b0615 (patch)
tree48651b12eb1af9c6b7d02b2d50c203cc9fe68b39 /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
parent459559a8bced28f25888802e40c7182392ea94cc (diff)
downloadrails-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/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 76967c0fe0..d0b8a1ba1c 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -8,6 +8,20 @@ module ActiveRecord
{}
end
+ # This is the maximum length a table alias can be
+ def table_alias_length
+ 255
+ end
+
+ # Truncates a table alias according to the limits of the current adapter.
+ def table_alias_for(table_name, index = 1)
+ if index > 1
+ "#{table_name[0..table_alias_length-3]}_#{index}"
+ else
+ table_name[0..table_alias_length-1]
+ end
+ end
+
# def tables(name = nil) end
# Returns an array of indexes for the given table.