lib/updateable_views_inheritance/postgresql_adapter.rb
# Recreates views in the part of the hierarchy chain starting from the +parent_relation+.
Recreates views in the part of the hierarchy chain starting from the +parent_relation+.
Recreates views in the part of the hierarchy chain starting from the + parent_relation + .
def rebuild_parent_and_children_views(parent_relation)
          remove_parent_and_children_views(parent_relation)
          children = query(<<-end_sql)
            SELECT parent_relation, child_aggregate_view, child_relation
              FROM updateable_views_inheritance
             WHERE parent_relation = '#{parent_relation}'
          end_sql
          parent = query(<<-end_sql)[0]
            SELECT parent_relation, child_aggregate_view, child_relation
              FROM updateable_views_inheritance
             WHERE child_aggregate_view = '#{parent_relation}'
          end_sql
          create_child_view(parent[0], parent[1], parent[2]) if (parent && !parent.empty?)
          children.each do |child|
            create_child_view(child[0], child[1], child[2])
            rebuild_parent_and_children_views(child[1])
          end
        end
def rebuild_parent_and_children_views ( parent_relation ) remove_parent_and_children_views ( parent_relation ) children = query ( <<-end_sql ) 
            SELECT parent_relation, child_aggregate_view, child_relation
              FROM updateable_views_inheritance
             WHERE parent_relation = ' #{ parent_relation } '
           end_sql parent = query ( <<-end_sql ) [ 0 ] 
            SELECT parent_relation, child_aggregate_view, child_relation
              FROM updateable_views_inheritance
             WHERE child_aggregate_view = ' #{ parent_relation } '
           end_sql create_child_view ( parent [ 0 ] , parent [ 1 ] , parent [ 2 ] ) if ( parent && ! parent . empty? ) children . each do | child | create_child_view ( child [ 0 ] , child [ 1 ] , child [ 2 ] ) rebuild_parent_and_children_views ( child [ 1 ] ) end end
Recreates views in the part of the hierarchy chain starting from the +parent_relation+.
Recreates views in the part of the hierarchy chain starting from the + parent_relation + .
# Current implementation is not very efficient - it can drop and recreate one and the same view in the bottom of the hierarchy many times. #if the parent is in the middle of the inheritance chain, it's a view that should be rebuilt as well
parent_relation
<not_specific>