check_view and a change in how check_tables_exist raises

pull/14309/head
Simon Martín 6 years ago
parent f6a4e088e9
commit 9bbf528e69

@ -320,7 +320,9 @@ module Carto
return unless databases.present?
databases[:tables].each do |table|
check_table(table)
if (!check_table(table) && !check_view(table))
raise Carto::UnprocesableEntityError.new("relation \"#{table[:schema]}.#{table[:name]}\" does not exist")
end
end
end
@ -338,9 +340,24 @@ module Carto
raise_unprocessable_entity_error(e)
end
if result && result.count.zero?
raise Carto::UnprocesableEntityError.new("relation \"#{table[:schema]}.#{table[:name]}\" does not exist")
result && !result.count.zero?
end
def check_view(view)
begin
result = db_run(%{
SELECT *
FROM
pg_views
WHERE
schemaname = #{db_connection.quote(view[:schema])} AND
viewname = #{db_connection.quote(view[:name])}
})
rescue StandardError => e
raise_unprocessable_entity_error(e)
end
result && !result.count.zero?
end
def invalidate_cache

Loading…
Cancel
Save