aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Lennox <marc.lennox@gmail.com>2013-09-27 10:10:27 -0400
committerMarc Lennox <marc.lennox@gmail.com>2013-09-27 14:26:17 -0400
commit747ccb0f7c9bdecb96369b2867aca8e746064b57 (patch)
treea6b90323b3ac0d581c235fc5bd804559993793dc
parent777b72ba1a89a7f100f528494f0b4e533cc0b20f (diff)
downloadrails-747ccb0f7c9bdecb96369b2867aca8e746064b57.tar.gz
rails-747ccb0f7c9bdecb96369b2867aca8e746064b57.tar.bz2
rails-747ccb0f7c9bdecb96369b2867aca8e746064b57.zip
Fixed issue #12327
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb4
-rw-r--r--activerecord/test/cases/base_test.rb9
2 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
index 86b96a77fb..85f645123e 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
@@ -157,8 +157,8 @@ module ActiveRecord
def exec_delete(sql, name = 'SQL', binds = [])
log(sql, name, binds) do
- result = binds.empty? ? exec_no_cache(sql, binds) :
- exec_cache(sql, binds)
+ result = without_prepared_statement?(binds) ? exec_no_cache(sql, binds) :
+ exec_cache(sql, binds)
affected = result.cmd_tuples
result.clear
affected
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 5812e20a1b..a2f350817c 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -566,6 +566,15 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal topic, Topic.find(topic.id)
end
+ def test_destroy_without_prepared_statement
+ topic = Topic.create(title: 'foo')
+ Topic.connection.unprepared_statement do
+ Topic.find(topic.id).destroy
+ end
+
+ assert_equal nil, Topic.find_by_id(topic.id)
+ end
+
def test_blank_ids
one = Subscriber.new(:id => '')
two = Subscriber.new(:id => '')