aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/primitives
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-04 16:50:03 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-04 16:50:03 -0700
commitf413129f37bbbc4100317cb60179f43291e69f8e (patch)
treef640bfb9223d60f7ed46add9f157f30048b245bb /lib/arel/primitives
parent85bc3b417dc4e1ecad76fa89b5d195e2db8f5ff5 (diff)
downloadrails-f413129f37bbbc4100317cb60179f43291e69f8e.tar.gz
rails-f413129f37bbbc4100317cb60179f43291e69f8e.tar.bz2
rails-f413129f37bbbc4100317cb60179f43291e69f8e.zip
Table names seem to be disambiguated.
- Code is a mess, about to undergo some refactoring
Diffstat (limited to 'lib/arel/primitives')
-rw-r--r--lib/arel/primitives/attribute.rb13
-rw-r--r--lib/arel/primitives/value.rb4
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index 797ebfd07b..9215ea64a0 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -7,6 +7,7 @@ module Arel
@relation, @name, @alias, @ancestor = relation, name, options[:alias], options[:ancestor]
end
+ # INVESTIGATE
def alias_or_name
@alias || name
end
@@ -117,14 +118,22 @@ module Arel
end
include Expressions
- def to_sql(formatter = Sql::WhereCondition.new(engine))
- formatter.attribute relation.prefix_for(self), name, self.alias
+ def to_sql(formatter = Sql::WhereCondition.new(relation))
+ formatter.attribute self
end
def format(object)
object.to_sql(formatter)
end
+ def original_relation
+ relation.relation_for(self)
+ end
+
+ def christener
+ relation.christener
+ end
+
private
def formatter
Sql::Attribute.new(self)
diff --git a/lib/arel/primitives/value.rb b/lib/arel/primitives/value.rb
index 650557559a..5142eb45ca 100644
--- a/lib/arel/primitives/value.rb
+++ b/lib/arel/primitives/value.rb
@@ -8,12 +8,12 @@ module Arel
@value, @relation = value, relation
end
- def to_sql(formatter = Sql::WhereCondition.new(relation.engine))
+ def to_sql(formatter = Sql::WhereCondition.new(relation))
formatter.value value
end
def format(object)
- object.to_sql(Sql::Value.new(relation.engine))
+ object.to_sql(Sql::Value.new(relation))
end
def ==(other)