aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-09-07 10:24:25 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-09-07 10:44:50 -0700
commitf5ea24b3db952071eea73cdef7fd52e38e7e540f (patch)
tree11a31866fb887b05e01c005b950caa335be410c0 /activerecord/lib
parent9dd5c0391986cae96d9399f3f51f0fccb95bee71 (diff)
downloadrails-f5ea24b3db952071eea73cdef7fd52e38e7e540f.tar.gz
rails-f5ea24b3db952071eea73cdef7fd52e38e7e540f.tar.bz2
rails-f5ea24b3db952071eea73cdef7fd52e38e7e540f.zip
Merge commit 'refs/pull/2909/head' of https://github.com/rails/rails into rawr
* https://github.com/rails/rails: Postgresql adapter: added current_schema check for table_exists? Postgresql adapter: added current_schema check for table_exists?
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index a09bf9c73f..9181cc78fc 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -719,12 +719,10 @@ module ActiveRecord
binds << [nil, schema] if schema
exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
- SELECT COUNT(*)
- FROM pg_class c
- LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
- WHERE c.relkind in ('v','r')
- AND c.relname = $1
- AND n.nspname = #{schema ? '$2' : 'ANY (current_schemas(false))'}
+ SELECT COUNT(*)
+ FROM pg_tables
+ WHERE tablename = $1
+ AND schemaname = #{schema ? "'#{schema}'" : "ANY (current_schemas(false))"}
SQL
end