José Diaz Seng > DBIx-Table-TestDataGenerator-0.005 > DBIx::Table::TestDataGenerator::UniqueConstraint



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.005   Source  


DBIx::Table::TestDataGenerator::UniqueConstraint - unique constraint information


This class determines information about unique key constraints defined on the target table, in particular about the primary key.



Accessor for the DBIx::Class schema for the target database, required constructor argument.


Accessor for target table, required constructor argument.


Accessor for the method to be used to increment the primary key column chosen to be incremented, externally read-only.


Accessor for the name of the primary key column to be incremented, externally read-only.


Accessor for a reference to an array containing the names of the primary key columns, externally read-only.


Accessor for a reference to an array containing a list of SQL data type names sorted descendingly by the priority in which columns of the corresponding type will get selected for incrementing, externally read-only.


Accessor for a reference to an array containing the names of the columns in unique constraints which will be increased for new records, externally read-only.


Accessor which is true if the corresponding primary key column is auto-increment and false otherwise, externally read-only.


Arguments: none.

Determines information about the unique constraints on the target table.



In case handle_pkey is false, this method returns a hash reference of the following structure:

      UNIQUE_CONSTR_1 =>
        DATA_TYPE_1 => [ [ COL_NAME_1, MAX_VAL_1 ], ..., [COL_NAME_N, MAX_VAL_N] ],
        DATA_TYPE_2 => [ [ COL_NAME_N+1, MAX_VAL_N+1 ], ..., [COL_NAME_M, MAX_VAL_M] ],
      UNIQUE_CONSTR_2 => {...}

Here, the keys of the base hash are the names of all uniqueness constraints. For each such constraint, the value of the base hash is another hash having as values all the data types used for columns in the constraint and as values an array reference where each element is a pair (column_name, max_value) where column_name runs over all column names in the constraint and max_value is the corresponding current maximum value. (Please note the comment in the description of get_incrementor on how we currently determine this maximum in case of string data types.)

In case handle_pkey is true, the corresponding information is returned for the primary key constraint, in particular the base hash has only one key as there may be only one primary key constraint:

        DATA_TYPE_1 => [ [ COL_NAME_1, MAX_VAL_1 ], ..., [COL_NAME_N, MAX_VAL_N] ],
        DATA_TYPE_2 => [ [ COL_NAME_N+1, MAX_VAL_N+1 ], ..., [COL_NAME_M, MAX_VAL_M] ],



Checks if we have an auto-increment column. If we have one and it is not part of the primary key, we abort, otherwise, pkey_is_auto_increment is set to true.


This method is for handling an auto-increment primary key column when root nodes have pkey = referenced pkey and the referencing column does not allow null values. Since in this case we define a Row object and use it to retrieve the auto-increment value, i.e. the pkey value is not known beforehand, we need to pass a non-null value for the referencing column. The current method returns a valid temporary value.


Jose Diaz Seng, <josediazseng at>


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.

syntax highlighting: