Permalink
Browse files

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
  • Loading branch information...
1 parent 72640c6 commit ac2b213135735af33b8fe107c599c3b72058128e @jeremy jeremy committed Feb 3, 2008
Showing with 8 additions and 7 deletions.
  1. +8 −7 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -155,13 +155,14 @@ class MysqlAdapter < AbstractAdapter
"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,23 +206,23 @@ def quote(value, column = nil)
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:
@connection.quote(string)
end
def quoted_true
- "1"
+ QUOTED_TRUE
end
def quoted_false
- "0"
+ QUOTED_FALSE
end
# REFERENTIAL INTEGRITY ====================================

0 comments on commit ac2b213

Please sign in to comment.