We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d9a2071 commit b9f66f4Copy full SHA for b9f66f4
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -720,9 +720,11 @@ def table_exists?(name)
720
721
exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
722
SELECT COUNT(*)
723
- FROM pg_tables
724
- WHERE tablename = $1
725
- 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')
726
+ AND c.relname = $1
727
+ AND n.nspname = #{schema ? '$2' : 'ANY (current_schemas(false))'}
728
SQL
729
end
730
0 commit comments