diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-07 10:44:18 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-07 10:44:51 -0700 |
commit | b9f66f4db157eb6c85e1c72d9b1d577cd93cf9de (patch) | |
tree | 0caca8516675d9cfcec2f4e233e6b3426c103956 /activerecord/lib/active_record/connection_adapters | |
parent | d9a20711da15efb781a8b8402871be4890d05c6d (diff) | |
download | rails-b9f66f4db157eb6c85e1c72d9b1d577cd93cf9de.tar.gz rails-b9f66f4db157eb6c85e1c72d9b1d577cd93cf9de.tar.bz2 rails-b9f66f4db157eb6c85e1c72d9b1d577cd93cf9de.zip |
fixing view queries
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 8 |
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 45ca104ad3..272663a91d 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -720,9 +720,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 |