From 9ea913a2717844094663824118792ff42eabd1c3 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 3 Apr 2009 16:03:59 -0400 Subject: [PATCH] Return true or false based on the value of the standard_conforming_strings. supports_standard_conforming_strings? always returned true if the query was run successully regardless of the result of the query. --- .../connection_adapters/postgresql_adapter.rb | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 913bb52..27ce681 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -262,7 +262,10 @@ module ActiveRecord # PGresult instead. has_support = query('SHOW standard_conforming_strings')[0][0] rescue false self.client_min_messages = client_min_messages_old - has_support + + # 8.3.6 query returns "on" or "off", check for other booleans, returning either true or false + return has_support if has_support == true || has_support == false + return has_support.to_s =~ /[1|t|true|on]/i ? true : false end def supports_insert_with_returning? @@ -924,7 +927,7 @@ module ActiveRecord # See: http://www.postgresql.org/docs/current/static/runtime-config-compatible.html # If PostgreSQL doesn't know the standard_conforming_strings parameter then it doesn't # support escape string syntax. Don't override the inherited quoted_string_prefix. - if supports_standard_conforming_strings? + unless supports_standard_conforming_strings? self.class.instance_eval do define_method(:quoted_string_prefix) { 'E' } end -- 1.5.4.3