aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-06-02 11:40:01 -0300
committerEmilio Tagua <miloops@gmail.com>2009-06-02 11:40:01 -0300
commit522711952bf315bc52353e941183237a41f61b23 (patch)
treedebb3e1956a6e9b61fc0ff0df8b898d984c8cbf8 /activerecord/lib/active_record/base.rb
parentb3d40546923b194a89be0d9e00758864fa60b9e8 (diff)
downloadrails-522711952bf315bc52353e941183237a41f61b23.tar.gz
rails-522711952bf315bc52353e941183237a41f61b23.tar.bz2
rails-522711952bf315bc52353e941183237a41f61b23.zip
Refactors to work with latest Arel implementation.
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 56f3bd9faa..81969d11c5 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -909,7 +909,11 @@ module ActiveRecord #:nodoc:
# Both calls delete the affected posts all at once with a single DELETE statement. If you need to destroy dependent
# associations or call your <tt>before_*</tt> or +after_destroy+ callbacks, use the +destroy_all+ method instead.
def delete_all(conditions = nil)
- arel_table.where(construct_conditions(conditions, scope(:find))).delete
+ if conditions
+ arel_table.where(Arel::SqlLiteral.new(construct_conditions(conditions, scope(:find)))).delete
+ else
+ arel_table.delete
+ end
end
# Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part.
@@ -1691,7 +1695,7 @@ module ActiveRecord #:nodoc:
end
def arel_table(table = table_name)
- @arel_table = Arel(table)
+ @arel_table = Arel::Table.new(table, ActiveRecord::Base.connection)
end
def construct_finder_arel(options)
@@ -3058,7 +3062,7 @@ module ActiveRecord #:nodoc:
end
def arel_table
- @arel_table ||= Arel(self.class.table_name)
+ @arel_table ||= Arel::Table.new(self.class.table_name, ActiveRecord::Base.connection)
end
def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
@@ -3069,7 +3073,7 @@ module ActiveRecord #:nodoc:
value = read_attribute(name)
if include_readonly_attributes || (!include_readonly_attributes && !self.class.readonly_attributes.include?(name))
- attrs[arel_table[name]] = value
+ attrs[arel_table[name]] = value.is_a?(Hash) ? value.to_yaml : value
end
end
end