NAME

DBIx::Table::TestDataGenerator::SelfReference - self-reference handling

DESCRIPTION

Determines if there is a self-reference and if so, information about it.

SUBROUTINES/METHODS

_self_ref_condition

  • schema: DBIx schema of the target database

  • table: Name of the target table

Internal method, returns the name of the foreign key defining a self-reference and a hash relating the referencing to the referenced column in case there is a self-reference, returns undef otherwise.

get_self_reference

  • schema: DBIx schema of the target database

  • table: Name of the target table

If there is an fkey defining a self-reference, its name and the name of the referencing column are returned in a two-element array reference, otherwise undef is returned.

selfref_tree

Arguments:

  • schema: DBIx schema of the target database

  • table: Name of the target table

  • child_col: Name of the (unique) primary key column

  • parent_col: Name of the column referencing the primary key column

Returns a hash corresponding to the self-reference defined on the table.

num_roots

Arguments:

  • schema: DBIx schema of the target database

  • table: Name of the target table

Returns the number of roots in the target table in case a self-reference exists on it. A record is considered a root node if either the value for the parent primary key is equal to NULL or to the record's primary key value.

AUTHOR

Jose Diaz Seng, <josediazseng at gmx.de>

COPYRIGHT AND LICENSE

Copyright (C) 2012-2013, Jose Diaz Seng.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.