GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SQL::Translator::Schema::Constraint(3) User Contributed Perl Documentation SQL::Translator::Schema::Constraint(3)

SQL::Translator::Schema::Constraint - SQL::Translator constraint object

  use SQL::Translator::Schema::Constraint;
  my $constraint = SQL::Translator::Schema::Constraint->new(
      name   => 'foo',
      fields => [ id ],
      type   => PRIMARY_KEY,
  );

"SQL::Translator::Schema::Constraint" is the constraint object.

Object constructor.

  my $schema           =  SQL::Translator::Schema::Constraint->new(
      table            => $table,        # table to which it belongs
      type             => 'foreign_key', # type of table constraint
      name             => 'fk_phone_id', # name of the constraint
      fields           => 'phone_id',    # field in the referring table
      reference_fields => 'phone_id',    # referenced field
      reference_table  => 'phone',       # referenced table
      match_type       => 'full',        # how to match
      on_delete        => 'cascade',     # what to do on deletes
      on_update        => '',            # what to do on updates
  );

Get or set whether the constraint is deferrable. If not defined, then returns "1." The argument is evaluated by Perl for True or False, so the following are equivalent:

  $deferrable = $field->deferrable(0);
  $deferrable = $field->deferrable('');
  $deferrable = $field->deferrable('0');

Gets and set the expression used in a CHECK constraint.

  my $expression = $constraint->expression('...');

Determine whether the constraint is valid or not.

  my $ok = $constraint->is_valid;

Gets and set the fields the constraint is on. Accepts a string, list or arrayref; returns an array or array reference. Will unique the field names and keep them in order by the first occurrence of a field name.

The fields are returned as Field objects if they exist or as plain names if not. (If you just want the names and want to avoid the Field's overload magic use "field_names").

Returns undef or an empty list if the constraint has no fields set.

  $constraint->fields('id');
  $constraint->fields('id', 'name');
  $constraint->fields( 'id, name' );
  $constraint->fields( [ 'id', 'name' ] );
  $constraint->fields( qw[ id name ] );

  my @fields = $constraint->fields;

Read-only method to return a list or array ref of the field names. Returns undef or an empty list if the constraint has no fields set. Useful if you want to avoid the overload magic of the Field objects returned by the fields method.

  my @names = $constraint->field_names;

Get or set the constraint's match_type. Only valid values are "full" "partial" and "simple"

  my $match_type = $constraint->match_type('FULL');

Get or set the constraint's name.

  my $name = $constraint->name('foo');

Gets or adds to the constraints's options (e.g., "INITIALLY IMMEDIATE"). Returns an array or array reference.

  $constraint->options('NORELY');
  my @options = $constraint->options;

Get or set the constraint's "on delete" action.

  my $action = $constraint->on_delete('cascade');

Get or set the constraint's "on update" action.

  my $action = $constraint->on_update('no action');

Gets and set the fields in the referred table. Accepts a string, list or arrayref; returns an array or array reference.

  $constraint->reference_fields('id');
  $constraint->reference_fields('id', 'name');
  $constraint->reference_fields( 'id, name' );
  $constraint->reference_fields( [ 'id', 'name' ] );
  $constraint->reference_fields( qw[ id name ] );

  my @reference_fields = $constraint->reference_fields;

Get or set the table referred to by the constraint.

  my $reference_table = $constraint->reference_table('foo');

Get or set the constraint's table object.

  my $table = $field->table;

Get or set the constraint's type.

  my $type = $constraint->type( PRIMARY_KEY );

Determines if this constraint is the same as another

  my $isIdentical = $constraint1->equals( $constraint2 );

Ken Youens-Clark <kclark@cpan.org>.
2020-09-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.