lib/updateable_views_inheritance/postgresql_adapter.rb
# Creates aggregate updateable view of parent and child relations. The convention for naming child tables is
# <tt>"#{child_view}_data"</tt>. If you don't follow it, supply +child_table_name+ as third argument.
Creates aggregate updateable view of parent and child relations. The convention for naming child tables is
"#{child_view}_data". If you don't follow it, supply +child_table_name+ as third argument.
Creates aggregate updateable view of parent and child relations . The convention for naming child tables is " # { child_view } _data " . If you don ' t follow it supply + child_table_name + as third argument .
def create_child_view(parent_table, child_view, child_table=nil)
          child_table ||= child_view.to_s + "_data"
          parent_columns = columns(parent_table)
          child_columns  = columns(child_table)
          child_column_names = child_columns.collect{|c| c.name}
          parent_column_names = parent_columns.collect{|c| c.name}
          child_pk = pk_and_sequence_for(child_table)[0]
          child_column_names.delete(child_pk)
          parent_pk, parent_pk_seq = pk_and_sequence_for(parent_table)
          parent_column_names.delete(parent_pk)
          do_create_child_view(parent_table, parent_column_names, parent_pk, child_view, child_column_names, child_pk, child_table)
          make_child_view_updateable(parent_table, parent_column_names, parent_pk, parent_pk_seq, child_view, child_column_names, child_pk, child_table)
          set_defaults(child_view, parent_table)
          set_defaults(child_view, child_table)
          create_system_table_records(parent_table, child_view, child_table)
        end
def create_child_view ( parent_table , child_view , child_table = nil ) child_table ||= child_view . to_s + "_data" parent_columns = columns ( parent_table ) child_columns = columns ( child_table ) child_column_names = child_columns . collect { | c | c . name } parent_column_names = parent_columns . collect { | c | c . name } child_pk = pk_and_sequence_for ( child_table ) [ 0 ] child_column_names . delete ( child_pk ) parent_pk , parent_pk_seq = pk_and_sequence_for ( parent_table ) parent_column_names . delete ( parent_pk ) do_create_child_view ( parent_table , parent_column_names , parent_pk , child_view , child_column_names , child_pk , child_table ) make_child_view_updateable ( parent_table , parent_column_names , parent_pk , parent_pk_seq , child_view , child_column_names , child_pk , child_table ) set_defaults ( child_view , parent_table ) set_defaults ( child_view , child_table ) create_system_table_records ( parent_table , child_view , child_table ) end
Creates aggregate updateable view of parent and child relations.
Creates aggregate updateable view of parent and child relations .
# assign default values for table columns on the view - it is not automatic in Postgresql 8.1
parent_table
<not_specific>
child_view
<not_specific>
child_table
<not_specific>