aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-04-24 17:10:52 -0300
committerEmilio Tagua <miloops@gmail.com>2009-04-24 17:10:52 -0300
commit1b1fc880bf7129a422901417bd6b9fede292aa7e (patch)
tree62fa68b6edeed1a61ab13887fa6fafe804abfc8d /lib
parenta454d45403cd0b8a24b05b7ff37021e307905825 (diff)
downloadrails-1b1fc880bf7129a422901417bd6b9fede292aa7e.tar.gz
rails-1b1fc880bf7129a422901417bd6b9fede292aa7e.tar.bz2
rails-1b1fc880bf7129a422901417bd6b9fede292aa7e.zip
Removed table quotings to be SQLite3 compliant. Delete and update will returrn the size of modified records to prevent addional queries to be done.
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/engine.rb6
-rw-r--r--lib/arel/primitives/value.rb8
-rw-r--r--lib/arel/relations/relation.rb4
-rw-r--r--lib/arel/relations/writes/delete.rb6
-rw-r--r--lib/arel/relations/writes/update.rb12
5 files changed, 18 insertions, 18 deletions
diff --git a/lib/arel/engine.rb b/lib/arel/engine.rb
index b0b7b4e955..5a5ef06878 100644
--- a/lib/arel/engine.rb
+++ b/lib/arel/engine.rb
@@ -6,13 +6,13 @@ module Arel
def initialize(ar = nil)
@ar = ar
end
-
+
def connection
@ar.connection
end
-
+
def method_missing(method, *args, &block)
@ar.connection.send(method, *args, &block)
end
end
-end \ No newline at end of file
+end
diff --git a/lib/arel/primitives/value.rb b/lib/arel/primitives/value.rb
index 809af7c206..74baa06e5b 100644
--- a/lib/arel/primitives/value.rb
+++ b/lib/arel/primitives/value.rb
@@ -3,8 +3,8 @@ module Arel
attributes :value, :relation
deriving :initialize, :==
delegate :inclusion_predicate_sql, :equality_predicate_sql, :to => :value
-
-
+
+
def to_sql(formatter = Sql::WhereCondition.new(relation))
formatter.value value
end
@@ -12,9 +12,9 @@ module Arel
def format(object)
object.to_sql(Sql::Value.new(relation))
end
-
+
def bind(relation)
Value.new(value, relation)
end
end
-end \ No newline at end of file
+end
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index d9ba9a108b..50110c7416 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -99,11 +99,11 @@ module Arel
end
def update(assignments)
- session.update Update.new(self, assignments); self
+ session.update Update.new(self, assignments)
end
def delete
- session.delete Deletion.new(self); self
+ session.delete Deletion.new(self)
end
end
include Writable
diff --git a/lib/arel/relations/writes/delete.rb b/lib/arel/relations/writes/delete.rb
index 318a299b8b..b1ff3bef27 100644
--- a/lib/arel/relations/writes/delete.rb
+++ b/lib/arel/relations/writes/delete.rb
@@ -11,9 +11,9 @@ module Arel
("LIMIT #{taken}" unless taken.blank? ),
].compact.join("\n")
end
-
- def call(connection = engine.connection)
+
+ def call(connection = engine)
connection.delete(to_sql)
end
end
-end \ No newline at end of file
+end
diff --git a/lib/arel/relations/writes/update.rb b/lib/arel/relations/writes/update.rb
index 720b9d697d..3b43152ad6 100644
--- a/lib/arel/relations/writes/update.rb
+++ b/lib/arel/relations/writes/update.rb
@@ -2,7 +2,7 @@ module Arel
class Update < Compound
attributes :relation, :assignments
deriving :==
-
+
def initialize(relation, assignments)
@relation, @assignments = relation, assignments.bind(relation)
end
@@ -11,15 +11,15 @@ module Arel
[
"UPDATE #{table_sql} SET",
assignments.collect do |attribute, value|
- "#{value.format(attribute)} = #{attribute.format(value)}"
+ "#{engine.quote_column_name(attribute.name)} = #{attribute.format(value)}"
end.join(",\n"),
- ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ),
+ ("WHERE #{wheres.map(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ),
("LIMIT #{taken}" unless taken.blank? )
].join("\n")
end
-
- def call(connection = engine.connection)
+
+ def call(connection = engine)
connection.update(to_sql)
end
end
-end \ No newline at end of file
+end