diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-03 12:11:52 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-03 12:11:52 +0000 |
commit | ac2b213135735af33b8fe107c599c3b72058128e (patch) | |
tree | b916be404faecbc587e99d269d77905e1fde8752 /activerecord | |
parent | 72640c61252e43ed51da368a3122fd507b7b93a6 (diff) | |
download | rails-ac2b213135735af33b8fe107c599c3b72058128e.tar.gz rails-ac2b213135735af33b8fe107c599c3b72058128e.tar.bz2 rails-ac2b213135735af33b8fe107c599c3b72058128e.zip |
MySQL: memoize column and table name quoting to reduce garbage
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8794 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 08d29419a5..c37bfd3e81 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -155,13 +155,14 @@ module ActiveRecord "Server shutdown in progress", "Broken pipe", "Lost connection to MySQL server during query", - "MySQL server has gone away" - ] + "MySQL server has gone away" ] + + QUOTED_TRUE, QUOTED_FALSE = '1', '0' def initialize(connection, logger, connection_options, config) super(connection, logger) @connection_options, @config = connection_options, config - + @quoted_column_names, @quoted_table_names = {}, {} connect end @@ -205,11 +206,11 @@ module ActiveRecord end def quote_column_name(name) #:nodoc: - "`#{name}`" + @quoted_column_names[name] ||= "`#{name}`" end def quote_table_name(name) #:nodoc: - quote_column_name(name).gsub('.', '`.`') + @quoted_table_names[name] ||= quote_column_name(name).gsub('.', '`.`') end def quote_string(string) #:nodoc: @@ -217,11 +218,11 @@ module ActiveRecord end def quoted_true - "1" + QUOTED_TRUE end def quoted_false - "0" + QUOTED_FALSE end # REFERENTIAL INTEGRITY ==================================== |