Skip to content

Commit

Permalink
fixing view queries
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Sep 7, 2011
1 parent d9a2071 commit b9f66f4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,11 @@ def table_exists?(name)

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

Expand Down

0 comments on commit b9f66f4

Please sign in to comment.