From 4086ecea24446904bac4c69812f219ce7cbfbbba Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 24 Jun 2010 12:02:00 -0300 Subject: Remove block definition from method, is not needed since yield is used inside. --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index e84242601b..6fa4c50d6a 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -372,7 +372,7 @@ module ActiveRecord return false end - def disable_referential_integrity(&block) #:nodoc: + def disable_referential_integrity #:nodoc: if supports_disable_referential_integrity?() then execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";")) end -- cgit v1.2.3 From 7a7c608a26f03abb1245ff83d4e25040ad09cb44 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 23 Jun 2010 21:44:27 -0300 Subject: Your original TIME ZONE value on PostgreSQL is correctly restored now, after going through options :utc and then going back to :local MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4950 state:committed] Signed-off-by: José Valim --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index e84242601b..851e6d3718 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -216,7 +216,10 @@ module ActiveRecord super(connection, logger) @connection_parameters, @config = connection_parameters, config + # @local_tz is initialized as nil to avoid warnings when connect tries to use it + @local_tz = nil connect + @local_tz = execute('SHOW TIME ZONE').first["TimeZone"] end # Is this connection alive and ready for queries? @@ -929,9 +932,8 @@ module ActiveRecord # TIMESTAMP WITH ZONE types in UTC. if ActiveRecord::Base.default_timezone == :utc execute("SET time zone 'UTC'") - else - offset = Time.local(2000).utc_offset / 3600 - execute("SET time zone '#{offset}'") + elsif @local_tz + execute("SET time zone '#{@local_tz}'") end end -- cgit v1.2.3 From 4464d10e68045e6723d4eb62734213c4296ef339 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 25 Jun 2010 15:49:15 -0700 Subject: index dump should not include full text indexes. Thanks Ken Mayer for the original patch! [#4949 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../active_record/connection_adapters/postgresql_adapter.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index ef58a32074..26d88158d3 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -609,9 +609,7 @@ module ActiveRecord SQL - indexes = [] - - indexes = result.map do |row| + result.map do |row| index_name = row[0] unique = row[1] == 't' indkey = row[2].split(" ") @@ -625,11 +623,8 @@ module ActiveRecord SQL column_names = indkey.map {|attnum| columns[attnum] } - IndexDefinition.new(table_name, index_name, unique, column_names) - - end - - indexes + column_names.compact.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names) + end.compact end # Returns the list of all column definitions for a table. -- cgit v1.2.3 From 6e655732226eef6fa04d8fc0c4ee1f0436688c49 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 25 Jun 2010 16:32:09 -0700 Subject: refactoring the postgres adapter index method to avoid inject and use values_at. [#4976 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 26d88158d3..2fe2ae7136 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -615,15 +615,15 @@ module ActiveRecord indkey = row[2].split(" ") oid = row[3] - columns = query(<<-SQL, "Columns for index #{row[0]} on #{table_name}").inject({}) {|attlist, r| attlist[r[1]] = r[0]; attlist} - SELECT a.attname, a.attnum + columns = Hash[query(<<-SQL, "Columns for index #{row[0]} on #{table_name}")] + SELECT a.attnum, a.attname FROM pg_attribute a WHERE a.attrelid = #{oid} AND a.attnum IN (#{indkey.join(",")}) SQL - column_names = indkey.map {|attnum| columns[attnum] } - column_names.compact.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names) + column_names = columns.values_at(*indkey).compact + column_names.empty? ? nil : IndexDefinition.new(table_name, index_name, unique, column_names) end.compact end -- cgit v1.2.3