From 92d3ae708a048e5dba299429bf658c54c645e76a Mon Sep 17 00:00:00 2001 From: taise Date: Thu, 9 Jun 2016 21:39:55 +0900 Subject: [PATCH] Fix: PG::SyntaxError: Replace 'DISCARD ALL' query to similer operations. * DISCARD` was implemented on PostgreSQL since v8.3 However, Redshift is based on PostgreSQL 8.0.2 References * [PostgreSQL DISCARD](https://www.postgresql.org/docs/current/static/sql-discard.html) * [Amazon Redshift and PostgreSQL](http://docs.aws.amazon.com/redshift/latest/dg/c_redshift-and-postgres-sql.html) --- lib/active_record/connection_adapters/redshift_adapter.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/active_record/connection_adapters/redshift_adapter.rb b/lib/active_record/connection_adapters/redshift_adapter.rb index 977f083..118dab3 100644 --- a/lib/active_record/connection_adapters/redshift_adapter.rb +++ b/lib/active_record/connection_adapters/redshift_adapter.rb @@ -244,7 +244,10 @@ def reset! unless @connection.transaction_status == ::PG::PQTRANS_IDLE @connection.query 'ROLLBACK' end - @connection.query 'DISCARD ALL' + session_auth = 'DEFAULT' + @connection.query 'RESET ALL' + dealloc 'ALL' + @connection.query 'CLOSE ALL' configure_connection end