Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

working against arel/collector branch

  • Loading branch information...
commit 3321d1a2d1908f25d962169d0a88b55bca3c2370 1 parent a38e957
@tenderlove tenderlove authored
View
2  Gemfile
@@ -11,7 +11,7 @@ gem 'rack-cache', '~> 1.2'
gem 'jquery-rails', '~> 3.1.0'
gem 'turbolinks'
gem 'coffee-rails', '~> 4.0.0'
-gem 'arel', github: 'rails/arel'
+gem 'arel', path: '/Users/aaron/git/arel'
# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
View
3  activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -10,9 +10,10 @@ def initialize
def to_sql(arel, binds = [])
if arel.respond_to?(:ast)
binds = binds.dup
- visitor.accept(arel.ast) do
+ c = visitor.accept(arel.ast, Arel::Collectors::SQLString.new) do
quote(*binds.shift.reverse)
end
+ c.value
else
arel
end
View
3  activerecord/lib/active_record/relation.rb
@@ -520,9 +520,10 @@ def to_sql
arel = relation.arel
binds = arel.bind_values + relation.bind_values
- visitor.accept(arel.ast) do
+ c = visitor.accept(arel.ast, Arel::Collectors::SQLString.new) do
connection.quote(*binds.shift.reverse)
end
+ c.value
end
end
View
2  activerecord/lib/active_record/sanitization.rb
@@ -92,7 +92,7 @@ def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name
table = Arel::Table.new(table_name, arel_engine).alias(default_table_name)
PredicateBuilder.build_from_hash(self, attrs, table).map { |b|
- connection.visitor.accept b
+ connection.visitor.compile b
}.join(' AND ')
end
alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions
View
2  activerecord/lib/active_record/statement_cache.rb
@@ -33,7 +33,7 @@ def sql_for(binds, connection)
end
def self.query(visitor, ast)
- Query.new visitor.accept(ast)
+ Query.new visitor.accept(ast, Arel::Collectors::SQLString.new).value
end
def self.partial_query(visitor, ast)
View
6 activerecord/test/cases/adapters/sqlite3/explain_test.rb
@@ -9,15 +9,15 @@ class ExplainTest < ActiveRecord::TestCase
def test_explain_for_one_query
explain = Developer.where(:id => 1).explain
- assert_match %(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = ?), explain
+ assert_match %(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = ?), explain
assert_match(/(SEARCH )?TABLE developers USING (INTEGER )?PRIMARY KEY/, explain)
end
def test_explain_with_eager_loading
explain = Developer.where(:id => 1).includes(:audit_logs).explain
- assert_match %(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = ?), explain
+ assert_match %(EXPLAIN for: SELECT "developers".* FROM "developers" WHERE "developers"."id" = ?), explain
assert_match(/(SEARCH )?TABLE developers USING (INTEGER )?PRIMARY KEY/, explain)
- assert_match %(EXPLAIN for: SELECT "audit_logs".* FROM "audit_logs" WHERE "audit_logs"."developer_id" IN (1)), explain
+ assert_match %(EXPLAIN for: SELECT "audit_logs".* FROM "audit_logs" WHERE "audit_logs"."developer_id" IN (1)), explain
assert_match(/(SCAN )?TABLE audit_logs/, explain)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.