aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
diff options
context:
space:
mode:
authorPaul Gallagher <gallagher.paul@gmail.com>2011-06-17 21:57:47 +0800
committerPaul Gallagher <gallagher.paul@gmail.com>2011-06-19 10:14:17 +0800
commitb0d59907f733841280095b16c98a95574b3a0938 (patch)
tree1508c1f8a14a36763e81d3e26e917b05885d7045 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
parentf8c4b374c831d6f37efb7b7685fe1d8fe101e096 (diff)
downloadrails-b0d59907f733841280095b16c98a95574b3a0938.tar.gz
rails-b0d59907f733841280095b16c98a95574b3a0938.tar.bz2
rails-b0d59907f733841280095b16c98a95574b3a0938.zip
Make PostgreSQL adapter view-compatible
* amongst other things, allows meta_search to run against view-backed models
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
1 files changed, 5 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 b6e7ddfc5b..03c31c2394 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -678,9 +678,11 @@ module ActiveRecord
exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
SELECT COUNT(*)
- FROM pg_tables
- WHERE tablename = $1
- AND schemaname = #{schema ? '$2' : 'ANY (current_schemas(false))'}
+ 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))'}
SQL
end