DB-Object
view release on metacpan or search on metacpan
lib/DB/Object/Constraint/Foreign.pm view on Meta::CPAN
=head2 name
Sets or gets the foreign key constraint name.
It returns a L<scalar object|Module::Generic::Scalar>
=head2 on_delete
Sets or gets the action taken by the database upon deletion of this foreign key.
For example: C<nothing>, C<restrict>, C<cascade>, C<null> or C<default>
It returns a L<scalar object|Module::Generic::Scalar>
=head2 on_update
Sets or gets the action taken by the database upon update of this foreign key.
For example: C<nothing>, C<restrict>, C<cascade>, C<null> or C<default>
It returns a L<scalar object|Module::Generic::Scalar>
=head2 table
Sets or gets the table name for this foreign key.
It returns a L<scalar object|Module::Generic::Scalar>
=head1 AUTHOR
lib/DB/Object/Postgres/Tables.pm view on Meta::CPAN
sub drop
{
my $self = shift( @_ );
my $table = $self->{table} ||
return( $self->error( "No table was provided to drop." ) );
my $opts = $self->_get_args_as_hash( @_ );
my $query = 'DROP TABLE';
$query .= ' IF EXISTS' if( $opts->{ 'if-exists' } || $opts->{if_exists} );
$query .= " $table";
if( $opts->{cascade} )
{
$query .= ' CASCADE';
}
## Default Postgres behavior
elsif( $opts->{restrict} )
{
$query .= ' RESTRICT';
}
my $sth = $self->database_object->prepare( $query ) ||
return( $self->error( "Error while preparing query to drop table '$table':\n$query", $self->database_object->errstr() ) );
lib/DB/Object/Postgres/Tables.pm view on Meta::CPAN
WHEN r.conindid > 0 THEN (SELECT c3.relname FROM pg_catalog.pg_class c3 WHERE c3.oid = r.conindid)
ELSE NULL
END AS "foreign_index_name"
,CASE
WHEN r.confrelid > 0 THEN (SELECT c4.relname FROM pg_catalog.pg_class c4 WHERE c4.oid = r.confrelid)
ELSE NULL
END AS "foreign_table"
,CASE r.confupdtype
WHEN 'a' THEN 'nothing'
WHEN 'r' THEN 'restrict'
WHEN 'c' THEN 'cascade'
WHEN 'n' THEN 'null'
WHEN 'd' THEN 'default'
ELSE NULL
END AS "foreign_update_action"
,CASE r.confdeltype
WHEN 'a' THEN 'nothing'
WHEN 'r' THEN 'restrict'
WHEN 'c' THEN 'cascade'
WHEN 'n' THEN 'null'
WHEN 'd' THEN 'default'
ELSE NULL
END AS "foreign_delete_action"
,CASE r.confmatchtype
WHEN 'f' THEN 'full'
WHEN 'p' THEN 'partial'
WHEN 's' THEN 'simple'
ELSE NULL
END AS "foreign_match"
lib/DB/Object/Postgres/Tables.pm view on Meta::CPAN
=head2 drop
This will prepare a drop statement to drop the current table.
If it is called in void context, then the statement is executed immediately and returned, otherwise it is just returned.
It takes the following options:
=over 4
=item * C<cascade>
If true, C<CASCADE> will be added to the C<DROP> query.
=item * C<if_exists>
If true, this will add a C<IF EXISTS> to the C<DROP> query.
You can also use I<if-exists>
=item * C<restrict>
lib/DB/Object/Postgres/Tables.pm view on Meta::CPAN
=item * C<expr>
The foreign key expression used when creating the table schema.
=item * C<match>
Typical value is C<full>, C<partial> and C<simple>
=item * C<on_delete>
The action the database is to take upon deletion. For example: C<nothing>, C<restrict>, C<cascade>, C<null> or C<default>
=item * C<on_update>
The action the database is to take upon update. For example: C<nothing>, C<restrict>, C<cascade>, C<null> or C<default>
=item * C<table>
The table name of the foreign key.
=item * C<fields>
The associated table column names for this foreign key constraint.
=item * C<name>
lib/DB/Object/Tables.pm view on Meta::CPAN
Each key in the hash represents the foreign key constraint name and its value is an L<foreign key constraint object|DB::Object::Constraint::Foreign> that contains the following methods:
=over 4
=item * C<match>
Typical value is C<full>, C<partial> and C<simple>
=item * C<on_delete>
The action the database is to take upon deletion. For example: C<nothing>, C<restrict>, C<cascade>, C<null> or C<default>
=item * C<on_update>
The action the database is to take upon update. For example: C<nothing>, C<restrict>, C<cascade>, C<null> or C<default>
=item * C<table>
The table name of the foreign key.
=item * C<fields>
The L<array object|Module::Generic::Array> of associated column names for this foreign key constraint.
=item * C<name>
( run in 0.543 second using v1.01-cache-2.11-cpan-49f99fa48dc )