aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2011-05-18 18:01:01 +0900
committerAkira Matsuda <ronnie@dio.jp>2011-05-18 18:50:33 +0900
commita61556387af8b52386f1f3319e5f93b5385d78df (patch)
tree21b0214b09c19853a3d9925614a5e771f8fd3e2a
parent2692d3278a7b15699491f8c86b4180eaad9ce196 (diff)
downloadrails-a61556387af8b52386f1f3319e5f93b5385d78df.tar.gz
rails-a61556387af8b52386f1f3319e5f93b5385d78df.tar.bz2
rails-a61556387af8b52386f1f3319e5f93b5385d78df.zip
why not use JOIN statement for joining tables?
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index f4beeceb61..8cb01a834f 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -701,11 +701,11 @@ module ActiveRecord
schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
result = query(<<-SQL, name)
SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
- FROM pg_class t, pg_class i, pg_index d
+ FROM pg_class t
+ INNER JOIN pg_index d ON t.oid = d.indrelid
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
WHERE i.relkind = 'i'
- AND d.indexrelid = i.oid
AND d.indisprimary = 'f'
- AND t.oid = d.indrelid
AND t.relname = '#{table_name}'
AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (#{schemas}) )
ORDER BY i.relname