aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/primitives
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-04-23 18:53:03 -0300
committerEmilio Tagua <miloops@gmail.com>2009-04-23 18:53:03 -0300
commita454d45403cd0b8a24b05b7ff37021e307905825 (patch)
tree1d5b989e1bd32f47f00f7e72d3bfe97cf085ac0e /lib/arel/primitives
parent318cf575eb2b7cf42cb133b3f24cd1aa5fa5e155 (diff)
downloadrails-a454d45403cd0b8a24b05b7ff37021e307905825.tar.gz
rails-a454d45403cd0b8a24b05b7ff37021e307905825.tar.bz2
rails-a454d45403cd0b8a24b05b7ff37021e307905825.zip
Fix insertion to work on SQLite3
Diffstat (limited to 'lib/arel/primitives')
-rw-r--r--lib/arel/primitives/attribute.rb42
-rw-r--r--lib/arel/primitives/expression.rb14
2 files changed, 28 insertions, 28 deletions
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index 30885dd129..7021e9f9ed 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -9,11 +9,11 @@ module Arel
def initialize(relation, name, options = {})
@relation, @name, @alias, @ancestor = relation, name, options[:alias], options[:ancestor]
end
-
+
def named?(hypothetical_name)
(@alias || name).to_s == hypothetical_name.to_s
end
-
+
def aggregation?
false
end
@@ -21,7 +21,7 @@ module Arel
def column
original_relation.column_for(self)
end
-
+
def format(object)
object.to_sql(Sql::Attribute.new(self))
end
@@ -30,19 +30,19 @@ module Arel
formatter.attribute self
end
- module Transformations
+ module Transformations
def self.included(klass)
klass.send :alias_method, :eql?, :==
end
-
+
def hash
@hash ||= history.size + name.hash + relation.hash
end
-
+
def as(aliaz = nil)
Attribute.new(relation, name, :alias => aliaz, :ancestor => self)
end
-
+
def bind(new_relation)
relation == new_relation ? self : Attribute.new(new_relation, name, :alias => @alias, :ancestor => self)
end
@@ -52,20 +52,20 @@ module Arel
end
end
include Transformations
-
+
module Congruence
def history
@history ||= [self] + (ancestor ? ancestor.history : [])
end
-
+
def join?
relation.join?
end
-
+
def root
history.last
end
-
+
def original_relation
@original_relation ||= original_attribute.relation
end
@@ -77,17 +77,17 @@ module Arel
def find_correlate_in(relation)
relation[self] || self
end
-
+
def descends_from?(other)
history.include?(other)
end
-
+
def /(other)
other ? (history & other.history).size : 0
end
end
include Congruence
-
+
module Predications
def eq(other)
Equality.new(self, other)
@@ -112,34 +112,34 @@ module Arel
def matches(regexp)
Match.new(self, regexp)
end
-
+
def in(array)
In.new(self, array)
end
end
include Predications
-
+
module Expressions
def count
Expression.new(self, "COUNT")
end
-
+
def sum
Expression.new(self, "SUM")
end
-
+
def maximum
Expression.new(self, "MAX")
end
-
+
def minimum
Expression.new(self, "MIN")
end
-
+
def average
Expression.new(self, "AVG")
end
end
include Expressions
end
-end \ No newline at end of file
+end
diff --git a/lib/arel/primitives/expression.rb b/lib/arel/primitives/expression.rb
index 26186ccad8..836f014745 100644
--- a/lib/arel/primitives/expression.rb
+++ b/lib/arel/primitives/expression.rb
@@ -4,32 +4,32 @@ module Arel
deriving :==
delegate :relation, :to => :attribute
alias_method :name, :alias
-
+
def initialize(attribute, function_sql, aliaz = nil, ancestor = nil)
@attribute, @function_sql, @alias, @ancestor = attribute, function_sql, aliaz, ancestor
end
-
+
def to_sql(formatter = Sql::SelectClause.new(relation))
formatter.expression self
end
-
+
def aggregation?
true
end
-
+
module Transformations
def as(aliaz)
Expression.new(attribute, function_sql, aliaz, self)
end
-
+
def bind(new_relation)
new_relation == relation ? self : Expression.new(attribute.bind(new_relation), function_sql, @alias, self)
end
-
+
def to_attribute
Attribute.new(relation, @alias, :ancestor => self)
end
end
include Transformations
end
-end \ No newline at end of file
+end