diff options
Diffstat (limited to 'lib/arel/primitives')
-rw-r--r-- | lib/arel/primitives/attribute.rb | 13 | ||||
-rw-r--r-- | lib/arel/primitives/value.rb | 4 |
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) |