Skip to content

Commit b9f66f4

Browse files
committed
fixing view queries
1 parent d9a2071 commit b9f66f4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,11 @@ def table_exists?(name)
720720

721721
exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
722722
SELECT COUNT(*)
723-
FROM pg_tables
724-
WHERE tablename = $1
725-
AND schemaname = #{schema ? "$2" : "ANY (current_schemas(false))"}
723+
FROM pg_class c
724+
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
725+
WHERE c.relkind in ('v','r')
726+
AND c.relname = $1
727+
AND n.nspname = #{schema ? '$2' : 'ANY (current_schemas(false))'}
726728
SQL
727729
end
728730

0 commit comments

Comments
 (0)