aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-04-28 15:35:19 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-04-29 11:09:37 -0700
commitf1df6b2dce8bda94186d66b9edd5e727e0d05878 (patch)
tree2e9c45f02b204d15ea43b4b18bbe94c2b123e583 /activerecord/lib/active_record/persistence.rb
parent850b3ca4779da201d4805a12fe29d9d9a491739e (diff)
downloadrails-f1df6b2dce8bda94186d66b9edd5e727e0d05878.tar.gz
rails-f1df6b2dce8bda94186d66b9edd5e727e0d05878.tar.bz2
rails-f1df6b2dce8bda94186d66b9edd5e727e0d05878.zip
postgresql supports prepare statement deletes
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 787ac977e0..b4531ed35f 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -77,7 +77,15 @@ module ActiveRecord
def destroy
if persisted?
IdentityMap.remove(self) if IdentityMap.enabled?
- self.class.unscoped.where(self.class.arel_table[self.class.primary_key].eq(id)).delete_all
+ pk = self.class.primary_key
+ column = self.class.columns_hash[pk]
+ substitute = connection.substitute_at(column, 0)
+
+ relation = self.class.unscoped.where(
+ self.class.arel_table[pk].eq(substitute))
+
+ relation.bind_values = [[column, id]]
+ relation.delete_all
end
@destroyed = true