diff options
author | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 14:38:09 -0400 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 14:38:09 -0400 |
commit | b0a45d52fdb7d8ce564f4dc2013bc790f98f1da3 (patch) | |
tree | e9553add3be978b3392735a40b869bfdbc53ea7a /lib/arel/engines/sql/relations | |
parent | 7032a50297fce4d7724d1735e81e5df5fd919e71 (diff) | |
download | rails-b0a45d52fdb7d8ce564f4dc2013bc790f98f1da3.tar.gz rails-b0a45d52fdb7d8ce564f4dc2013bc790f98f1da3.tar.bz2 rails-b0a45d52fdb7d8ce564f4dc2013bc790f98f1da3.zip |
consolidated files
Conflicts:
lib/arel/algebra/predicates.rb
lib/arel/algebra/relations/writes/delete.rb
lib/arel/algebra/relations/writes/insert.rb
lib/arel/algebra/relations/writes/update.rb
lib/arel/engines/memory/predicates.rb
lib/arel/engines/memory/relations.rb
lib/arel/engines/sql/primitives/attribute.rb
lib/arel/engines/sql/relations/writes/insert.rb
lib/arel/engines/sql/relations/writes/update.rb
Diffstat (limited to 'lib/arel/engines/sql/relations')
-rw-r--r-- | lib/arel/engines/sql/relations/writes.rb | 36 | ||||
-rw-r--r-- | lib/arel/engines/sql/relations/writes/delete.rb | 12 | ||||
-rw-r--r-- | lib/arel/engines/sql/relations/writes/insert.rb | 12 | ||||
-rw-r--r-- | lib/arel/engines/sql/relations/writes/update.rb | 14 |
4 files changed, 36 insertions, 38 deletions
diff --git a/lib/arel/engines/sql/relations/writes.rb b/lib/arel/engines/sql/relations/writes.rb new file mode 100644 index 0000000000..edfd9f7233 --- /dev/null +++ b/lib/arel/engines/sql/relations/writes.rb @@ -0,0 +1,36 @@ +module Arel + class Deletion < Compound + def to_sql(formatter = nil) + [ + "DELETE", + "FROM #{table_sql}", + ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), + ("LIMIT #{taken}" unless taken.blank? ), + ].compact.join("\n") + end + end + + class Insert < Compound + def to_sql(formatter = nil) + [ + "INSERT", + "INTO #{table_sql}", + "(#{record.keys.collect { |key| engine.quote_column_name(key.name) }.join(', ')})", + "VALUES (#{record.collect { |key, value| key.format(value) }.join(', ')})" + ].join("\n") + end + end + + class Update < Compound + def to_sql(formatter = nil) + [ + "UPDATE #{table_sql} SET", + assignments.collect do |attribute, value| + "#{engine.quote_column_name(attribute.name)} = #{attribute.format(value)}" + end.join(",\n"), + ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), + ("LIMIT #{taken}" unless taken.blank? ) + ].join("\n") + end + end +end
\ No newline at end of file diff --git a/lib/arel/engines/sql/relations/writes/delete.rb b/lib/arel/engines/sql/relations/writes/delete.rb deleted file mode 100644 index b22ee51e24..0000000000 --- a/lib/arel/engines/sql/relations/writes/delete.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Arel - class Deletion < Compound - def to_sql(formatter = nil) - [ - "DELETE", - "FROM #{table_sql}", - ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), - ("LIMIT #{taken}" unless taken.blank? ), - ].compact.join("\n") - end - end -end
\ No newline at end of file diff --git a/lib/arel/engines/sql/relations/writes/insert.rb b/lib/arel/engines/sql/relations/writes/insert.rb deleted file mode 100644 index aac9c87a5b..0000000000 --- a/lib/arel/engines/sql/relations/writes/insert.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Arel - class Insert < Compound - def to_sql(formatter = nil) - [ - "INSERT", - "INTO #{table_sql}", - "(#{record.keys.collect { |key| engine.quote_column_name(key.name) }.join(', ')})", - "VALUES (#{record.collect { |key, value| key.format(value) }.join(', ')})" - ].join("\n") - end - end -end
\ No newline at end of file diff --git a/lib/arel/engines/sql/relations/writes/update.rb b/lib/arel/engines/sql/relations/writes/update.rb deleted file mode 100644 index 3e35a0d5cc..0000000000 --- a/lib/arel/engines/sql/relations/writes/update.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Arel - class Update < Compound - def to_sql(formatter = nil) - [ - "UPDATE #{table_sql} SET", - assignments.collect do |attribute, value| - "#{engine.quote_column_name(attribute.name)} = #{attribute.format(value)}" - end.join(",\n"), - ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), - ("LIMIT #{taken}" unless taken.blank? ) - ].join("\n") - end - end -end
\ No newline at end of file |