man Tangram::FlatArray () - map Perl array of strings or numbers

NAME

Tangram::FlatArray - map Perl array of strings or numbers

SYNOPSIS

   use Tangram::Core;
   use Tangram::FlatArray; # always

   $schema = Tangram::Schema->new(
      classes => { NaturalPerson => { fields => {

      flat_array =>
      {
         interests =>
         {
            table => 'NP_int',
            sql => 'VARCHAR(5)',
         },

         lucky_numbers => 'int', # use defaults
      }

DESCRIPTION

Maps references to a Perl array. The persistent fields are grouped in a hash under the CWarray key in the field hash.

The array may contain only 'simple' scalars like integers, strings or real numbers. It may not contain references. For arrays of objects, see Tangram::Array and Tangram::IntrArray.

Tangram uses a table to save the state of the collection. The table has three columns, which contain

* the id of the container object
* the position of the element in the array
* the value of the element

The field names are passed in a hash that associates a field name with a field descriptor. The field descriptor may be either a hash or a string. The hash uses the following fields:

* type
* table
* sql

Optional field CWtype specifies the type of the elements. If the type is CWstringTangram quotes the values as they are passed to the database. Not specifying a CWtype is exactly equivalent to specifying CWstring.

Optional field CWtable sets the name of the table that contains the elements. This defaults to 'C_F', where C is the class of the containing object and F is the field name.

Optional field CWsql specifies the type that deploy() (see Tangram::Deploy) should use for the column containing the elements. If this field is not present, the SQL type is derived from the CWtype field: if CWtype is CWstring (or is absent) VARCHAR(2) is used; otherwise, the CWtype field is interpreted as a SQL type.

If the descriptor is a string, it is interpreted as the value of the CWtype field and all the other fields take the default value.