aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 17:49:06 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-03-16 17:49:06 -0700
commitcae95fc02af1fff885dca4a29b2fd3711b809cab (patch)
treee177c3721d20596b4cc60e336b0999060e6e82a6 /lib
parent2d3681bb3c9ed8136fc46857828b74ae39b6d990 (diff)
downloadrails-cae95fc02af1fff885dca4a29b2fd3711b809cab.tar.gz
rails-cae95fc02af1fff885dca4a29b2fd3711b809cab.tar.bz2
rails-cae95fc02af1fff885dca4a29b2fd3711b809cab.zip
projections now support string passthrough
- there is a weird inconsistency in where bind is called on values; this needs to be resolved
Diffstat (limited to 'lib')
-rw-r--r--lib/active_relation/relations/relation.rb4
-rw-r--r--lib/active_relation/sql.rb6
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb
index fa66bd039b..88d1bce4a8 100644
--- a/lib/active_relation/relations/relation.rb
+++ b/lib/active_relation/relations/relation.rb
@@ -42,7 +42,7 @@ module ActiveRelation
end
def project(*attributes)
- Projection.new(self, *attributes.collect {|a| a.bind(self)})
+ Projection.new(self, *attributes)
end
def as(aliaz)
@@ -103,7 +103,7 @@ module ActiveRelation
def to_sql(formatter = Sql::SelectStatement.new(engine))
formatter.select [
- "SELECT #{attributes.collect { |a| a.to_sql(Sql::SelectExpression.new(engine)) }.join(', ')}",
+ "SELECT #{attributes.collect { |a| a.to_sql(Sql::SelectClause.new(engine)) }.join(', ')}",
"FROM #{table_sql}",
(joins unless joins.blank? ),
("WHERE #{selects.collect { |s| s.to_sql(Sql::WhereClause.new(engine)) }.join("\n\tAND ")}" unless selects.blank? ),
diff --git a/lib/active_relation/sql.rb b/lib/active_relation/sql.rb
index 3a773fdf6e..0b9b0fc18b 100644
--- a/lib/active_relation/sql.rb
+++ b/lib/active_relation/sql.rb
@@ -14,7 +14,7 @@ module ActiveRelation
end
end
- class SelectExpression < Formatter
+ class SelectClause < Formatter
def attribute(relation_name, attribute_name, aliaz)
"#{quote_table_name(relation_name)}.#{quote_column_name(attribute_name)}" + (aliaz ? " AS #{quote(aliaz.to_s)}" : "")
end
@@ -22,6 +22,10 @@ module ActiveRelation
def select(select_sql, aliaz)
"(#{select_sql})" + (aliaz ? " AS #{quote(aliaz)}" : "")
end
+
+ def value(value)
+ value
+ end
end
class PassThrough < Formatter