Skip to content
Browse files

Fixed issue #12327

  • Loading branch information...
1 parent 777b72b commit 747ccb0f7c9bdecb96369b2867aca8e746064b57 @marclennox marclennox committed
View
4 activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
@@ -157,8 +157,8 @@ def exec_query(sql, name = 'SQL', binds = [])
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
View
9 activerecord/test/cases/base_test.rb
@@ -566,6 +566,15 @@ def test_create_without_prepared_statement
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 => '')

0 comments on commit 747ccb0

Please sign in to comment.
Something went wrong with that request. Please try again.