|
|
|
@ -5,16 +5,20 @@ module Carto
|
|
|
|
|
# the tables than comprise the dataset.
|
|
|
|
|
module TableAndFriends
|
|
|
|
|
def self.apply(db_connection, schema, table_name, &block)
|
|
|
|
|
qualified_name = %{"#{schema.gsub('"', '""')}"."#{table_name.gsub('"', '""')}"}
|
|
|
|
|
qualified_name = qualified_table_name(schema, table_name)
|
|
|
|
|
block[schema, table_name, qualified_name]
|
|
|
|
|
overviews_service = Carto::OverviewsService.new(db_connection)
|
|
|
|
|
overviews_service.overview_tables(qualified_name).each do |overview_table|
|
|
|
|
|
block[schema, overview_table]
|
|
|
|
|
block[schema, overview_table, qualified_table_name(schema, overview_table)]
|
|
|
|
|
end
|
|
|
|
|
# TODO: should we apply also to raster overview tables?
|
|
|
|
|
# To do so we could use SupportTables class and modify it to make #tables public.
|
|
|
|
|
# Note that SupportTables handles only raster overviews and provides methods
|
|
|
|
|
# to rename them, delete them and change their schema.
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def self.qualified_table_name(schema, table_name)
|
|
|
|
|
%{"#{schema.gsub('"', '""')}"."#{table_name.gsub('"', '""')}"}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|