aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-27 15:26:12 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-27 15:26:12 -0700
commit1f25ba3786ff6aaa1e04e038a84acafa4138ee17 (patch)
tree5e75585570d7d8a5292ce45d06d6b76e241e7505
parent9b5ca7a78f53da1ba1a817041e1c78ae673887a0 (diff)
downloadrails-1f25ba3786ff6aaa1e04e038a84acafa4138ee17.tar.gz
rails-1f25ba3786ff6aaa1e04e038a84acafa4138ee17.tar.bz2
rails-1f25ba3786ff6aaa1e04e038a84acafa4138ee17.zip
PERF: eliminating method_missing
-rw-r--r--lib/arel/engines/sql/compilers/oracle_compiler.rb10
-rw-r--r--lib/arel/engines/sql/compilers/postgresql_compiler.rb2
-rw-r--r--lib/arel/engines/sql/engine.rb8
-rw-r--r--lib/arel/engines/sql/relations/compiler.rb8
-rw-r--r--lib/arel/engines/sql/relations/table.rb4
-rw-r--r--spec/engines/sql/unit/engine_spec.rb7
6 files changed, 12 insertions, 27 deletions
diff --git a/lib/arel/engines/sql/compilers/oracle_compiler.rb b/lib/arel/engines/sql/compilers/oracle_compiler.rb
index 66a91cecb5..1963454d36 100644
--- a/lib/arel/engines/sql/compilers/oracle_compiler.rb
+++ b/lib/arel/engines/sql/compilers/oracle_compiler.rb
@@ -16,7 +16,7 @@ module Arel
# when limit or offset subquery is used then cannot use FOR UPDATE directly
# and need to construct separate subquery for primary key
if use_subquery_for_lock = limit_or_offset && !locked.blank?
- quoted_primary_key = engine.quote_column_name(primary_key)
+ quoted_primary_key = engine.connection.quote_column_name(primary_key)
end
select_attributes_string = use_subquery_for_lock ? quoted_primary_key : select_clauses.join(', ')
@@ -39,7 +39,7 @@ module Arel
("ORDER BY #{order_clauses_array.join(', ')}" unless order_clauses_array.blank? )
# Use existing method from oracle_enhanced adapter to implement limit and offset using subqueries
- engine.add_limit_offset!(query, :limit => taken, :offset => skipped) if limit_or_offset
+ engine.connection.add_limit_offset!(query, :limit => taken, :offset => skipped) if limit_or_offset
if use_subquery_for_lock
build_query \
@@ -83,10 +83,10 @@ module Arel
def limited_update_conditions(conditions, taken)
# need to add ORDER BY only if just taken ones should be updated
conditions << " ORDER BY #{order_clauses.join(', ')}" unless orders.blank?
- quoted_primary_key = engine.quote_column_name(primary_key)
- subquery = "SELECT #{quoted_primary_key} FROM #{engine.connection.quote_table_name table.name} #{conditions}"
+ quoted_primary_key = engine.connection.quote_column_name(primary_key)
+ subquery = "SELECT #{quoted_primary_key} FROM #{engine.connection.connection.quote_table_name table.name} #{conditions}"
# Use existing method from oracle_enhanced adapter to get taken records when ORDER BY is used
- engine.add_limit_offset!(subquery, :limit => taken) unless orders.blank?
+ engine.connection.add_limit_offset!(subquery, :limit => taken) unless orders.blank?
"WHERE #{quoted_primary_key} IN (#{subquery})"
end
diff --git a/lib/arel/engines/sql/compilers/postgresql_compiler.rb b/lib/arel/engines/sql/compilers/postgresql_compiler.rb
index 1f6e74d57a..3f814255e9 100644
--- a/lib/arel/engines/sql/compilers/postgresql_compiler.rb
+++ b/lib/arel/engines/sql/compilers/postgresql_compiler.rb
@@ -35,7 +35,7 @@ module Arel
end
def supports_insert_with_returning?
- engine.postgresql_version >= 80200
+ engine.connection.send(:postgresql_version) >= 80200
end
end
end
diff --git a/lib/arel/engines/sql/engine.rb b/lib/arel/engines/sql/engine.rb
index 8504fec3c5..7e841d68bb 100644
--- a/lib/arel/engines/sql/engine.rb
+++ b/lib/arel/engines/sql/engine.rb
@@ -19,14 +19,6 @@ module Arel
end
end
- def method_missing(method, *args)
- if block_given?
- connection.send(method, *args) { |*block_args| yield(*block_args) }
- else
- connection.send(method, *args)
- end
- end
-
def create(relation)
primary_key_value = if relation.primary_key.blank?
nil
diff --git a/lib/arel/engines/sql/relations/compiler.rb b/lib/arel/engines/sql/relations/compiler.rb
index 2941fc2a06..9691c8518c 100644
--- a/lib/arel/engines/sql/relations/compiler.rb
+++ b/lib/arel/engines/sql/relations/compiler.rb
@@ -68,7 +68,7 @@ module Arel
end
first = attributes.collect do |key|
- engine.quote_column_name(key.name)
+ engine.connection.quote_column_name(key.name)
end.join(', ')
second = attributes.collect do |key|
@@ -82,7 +82,7 @@ module Arel
"INSERT",
"INTO #{table_sql}",
insertion_attributes_values_sql,
- ("RETURNING #{engine.quote_column_name(primary_key)}" if include_returning && compiler.supports_insert_with_returning?)
+ ("RETURNING #{engine.connection.quote_column_name(primary_key)}" if include_returning && compiler.supports_insert_with_returning?)
end
def supports_insert_with_returning?
@@ -117,7 +117,7 @@ module Arel
attributes.map do |attribute|
value = assignments[attribute]
- "#{engine.quote_column_name(attribute.name)} = #{attribute.format(value)}"
+ "#{engine.connection.quote_column_name(attribute.name)} = #{attribute.format(value)}"
end.join(", ")
else
assignments.value
@@ -138,7 +138,7 @@ module Arel
def limited_update_conditions(conditions, taken)
conditions << " LIMIT #{taken}"
- quoted_primary_key = engine.quote_column_name(primary_key)
+ quoted_primary_key = engine.connection.quote_column_name(primary_key)
"WHERE #{quoted_primary_key} IN (SELECT #{quoted_primary_key} FROM #{engine.connection.quote_table_name table.name} #{conditions})"
end
diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb
index 94843ec62d..236a36c7a7 100644
--- a/lib/arel/engines/sql/relations/table.rb
+++ b/lib/arel/engines/sql/relations/table.rb
@@ -42,7 +42,7 @@ module Arel
end
end
- @@tables ||= engine.tables
+ @@tables ||= engine.connection.tables
end
end
@@ -85,7 +85,7 @@ module Arel
end
def columns
- @columns ||= engine.columns(name, "#{name} Columns")
+ @columns ||= engine.connection.columns(name, "#{name} Columns")
end
def reset
diff --git a/spec/engines/sql/unit/engine_spec.rb b/spec/engines/sql/unit/engine_spec.rb
index 85a9dc5bfb..9d3c41ccc0 100644
--- a/spec/engines/sql/unit/engine_spec.rb
+++ b/spec/engines/sql/unit/engine_spec.rb
@@ -17,13 +17,6 @@ module Arel
end
describe "method missing" do
- it "should pass through" do
- conn = FakeConnection.new
- engine = Arel::Sql::Engine.new FakeAR.new conn
- engine.foo
- conn.called.should == [[:foo, [], nil]]
- end
-
it "should ask for a connection" do
conn = FakeConnection.new
ar = FakeAR.new conn