view release on metacpan or search on metacpan
lib/DB/Object/Constraint/Foreign.pm view on Meta::CPAN
=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
view all matches for this distribution
view release on metacpan or search on metacpan
will *not* be accepted if the foreign key doesn't exist (as primary key) in the parent table; you will
get an error message. But for multi-column foreign keys dtF/SQL cannot check the referential integrity. A
record will be accepted even if the foreign key doesn't exist (as primary key) in the parent table. Don't rely
on this feature.
* The dtF/SQL cascaded delete feature (ON DELETE DELETE or ON DELETE CASCADE action-constraint/trigger),
which helps to preserve the referential integrity of a database, doesn't work properly. Let's say, table
A is the parent table with primary key [A.id]. Table B is the dependent table, i.e. contains a foreign key
[B.id] which is the primary key of table A. The primary key of table B is a multi-column key [B.id, B.id2],
i.e. the foreign key [B.id] of table B is part of its primary key. Table B was created with the cascaded
delete action-constraint set for this foreign key [B.id]. If you now delete a record in table A, dtF/SQL will,
as you expect, delete the corresponding records (where A.id = B.id) in table B too. *But*, if you try to
insert one of the just deleted records into table B again (same multi-column primary key), you will get a
referential integrity error, saying "UNIQUE value exists for column 'B.id' ", i.e. dtF/SQL hasn't realized,
that the primary key is free for use again. This doesn't happen if you delete the corresponding records in
table B by hand, i.e. with a DELETE statement. Because this cascaded delete behavior is not what you might
expect, don't rely on this feature.
* dtF/SQL is also a bit weak on documentation. It contains some errors (e.g. wrong cross-references in
the C/C++/Java Reference manual), but generally it's not that bad that one can't work with it. All in
all, it doesn't go into deep detail and is very brief on some relevant topics (auto-commit behavior,
view all matches for this distribution
view release on metacpan or search on metacpan
if (0==strcmp(word, "both")) return DBDPG_TRUE;
if (0==strcmp(word, "by")) return DBDPG_TRUE;
if (0==strcmp(word, "cache")) return DBDPG_TRUE;
if (0==strcmp(word, "call")) return DBDPG_TRUE;
if (0==strcmp(word, "called")) return DBDPG_TRUE;
if (0==strcmp(word, "cascade")) return DBDPG_TRUE;
if (0==strcmp(word, "cascaded")) return DBDPG_TRUE;
if (0==strcmp(word, "case")) return DBDPG_TRUE;
if (0==strcmp(word, "cast")) return DBDPG_TRUE;
if (0==strcmp(word, "catalog")) return DBDPG_TRUE;
if (0==strcmp(word, "chain")) return DBDPG_TRUE;
if (0==strcmp(word, "char")) return DBDPG_TRUE;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/SQLAnywhere/GetInfo.pm view on Meta::CPAN
bottom
break
by
call
capability
cascade
case
cast
char
char_convert
character
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/SQLite.pm view on Meta::CPAN
UNIQUE_OR_PRIMARY
);
my $DEFERRABLE_RE = qr/
(?:(?:
on \s+ (?:delete|update) \s+ (?:set \s+ null|set \s+ default|cascade|restrict|no \s+ action)
|
match \s* (?:\S+|".+?(?<!")")
) \s*)*
((?:not)? \s* deferrable (?: \s* initially \s* (?: immediate | deferred))?)?
/sxi;
view all matches for this distribution
view release on metacpan or search on metacpan
cci-src/src/compat/dbi_compat.h view on Meta::CPAN
/* Class definition */
extern DB_OBJECT *db_create_class (const char *name);
extern DB_OBJECT *db_create_vclass (const char *name);
extern int db_drop_class (DB_OBJECT * classobj);
extern int db_drop_class_ex (DB_OBJECT * classobj, bool is_cascade_constraints);
extern int db_rename_class (DB_OBJECT * classobj, const char *new_name);
extern int db_add_index (DB_OBJECT * classobj, const char *attname);
extern int db_drop_index (DB_OBJECT * classobj, const char *attname);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBICx/MaterializedPath.pm view on Meta::CPAN
Sets the materialized path.
=item update
Updates which change the parent of a record necessarily cascade through all their children and grandchildren to recompute and set their new materialized paths. E.g., given this treeE<ndash>
1
|
3
/ \
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/CDTest/Schema/Result/Artist.pm view on Meta::CPAN
__PACKAGE__->has_many(
"artwork_to_artists",
"CDTest::Schema::Result::ArtworkToArtist",
{ "foreign.artist_id" => "self.artistid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 cds
Type: has_many
t/lib/CDTest/Schema/Result/Artist.pm view on Meta::CPAN
__PACKAGE__->has_many(
"cds",
"CDTest::Schema::Result::CD",
{ "foreign.artist" => "self.artistid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 artwork_cds
Type: many_to_many
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/AuditAny/Collector/AutoDBIC.pm view on Meta::CPAN
set_primary_key => ['id'],
has_many => [
$self->change_data_rel,
$namespace . '::' . $self->change_source_name,
{ "foreign.changeset_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
]
]
},
$self->change_source_name => {
table_name => $self->change_table_name,
lib/DBIx/Class/AuditAny/Collector/AutoDBIC.pm view on Meta::CPAN
],
has_many => [
$self->column_data_rel,
$namespace . '::' . $self->column_change_source_name,
{ "foreign.change_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
]
]
},
$self->column_change_source_name => {
table_name => $self->column_change_table_name,
view all matches for this distribution
view release on metacpan or search on metacpan
t/011_update_on_deleted_row.t view on Meta::CPAN
]);
my $title = $schema->resultset('Title')->first;
$schema->txn_do(sub {
$title->book->delete;
$title->update({name => 'test2'}); # update cascades to deleted book
});
is $al_schema->resultset('AuditLogChangeset')->count, 1, 'One changeset logged';
my $cset = $al_schema->resultset('AuditLogChangeset')->first ;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Bootstrap/Simple.pm view on Meta::CPAN
},
references => {
company => {
class => 'YourApp::DB::Company',
column => 'company_id',
cascade_update => 1, #defaults to 0
cascade_delete => 1, #defaults to 0
cascade_copy => 1, #defaults to 0
},
password => {
class => 'YourApp::DB::Password',
column => 'password_id',
lib/DBIx/Class/Bootstrap/Simple.pm view on Meta::CPAN
},
references => {
company => {
class => 'YourApp::DB::Company',
column => 'company_id',
cascade_update => 1, # defaults to 0
cascade_delete => 1, # defaults to 0
cascade_copy => 1, # defaults to 0
},
password => {
class => 'YourApp::DB::Password',
column => 'password_id',
lib/DBIx/Class/Bootstrap/Simple.pm view on Meta::CPAN
{
$module->has_many(
$rkey, $reference->{class},
{ "foreign.$remote_col", "self.$local_col" },
{
cascade_delete => $reference->{cascade_delete} || 0,
cascade_copy => $reference->{cascade_copy} || 0,
cascade_update => $reference->{cascade_update} || 0,
accessor => 'multi',
},
);
$reference->{class}->belongs_to( $remote_col => $module );
}
lib/DBIx/Class/Bootstrap/Simple.pm view on Meta::CPAN
$module->$meth(
$local_col, $reference->{class},
{ "foreign.$remote_col", "self.$local_col" },
{
cascade_delete => $reference->{cascade_delete} || 0,
cascade_copy => $reference->{cascade_copy} || 0,
cascade_update => $reference->{cascade_update} || 0,
accessor => 'filter',
},
);
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/DeleteAction.pm view on Meta::CPAN
=item * null
Set all columns in related rows pointing to this record to NULL. Only works
on 'has_many' relationships.
=item * delete OR cascade
Delete all related records one by one. This can trigger further delete
actions.
=item * deleteall
lib/DBIx/Class/DeleteAction.pm view on Meta::CPAN
# Ignore relation with no 'delete_action' key set
next RELATIONSHIP
unless $relationship_info->{attrs}{delete_action};
# Unset DBIC key cascade_delete attribute, so that we do not
# work twice
$relationship_info->{attrs}{cascade_delete} = 0;
# Get delete action parameter value
my $delete_action = $relationship_info->{attrs}{delete_action};
next RELATIONSHIP
lib/DBIx/Class/DeleteAction.pm view on Meta::CPAN
$related->update($update);
} else {
warn("Delete action 'null' does not work with ".$relationship_info->{attrs}{accessor}." relations");
}
# Action: DELETE
} elsif ($delete_action eq 'delete' || $delete_action eq 'cascade') {
warn('DeleteAction: DELETE '.$self.'->'.$relationship) if $debug;
if ($related->isa('DBIx::Class::ResultSet')) {
while (my $item = $related->next) {
$item->delete($params);
}
lib/DBIx/Class/DeleteAction.pm view on Meta::CPAN
=head1 CAVEATS
Note that the C<delete> method in L<DBIx::Class::ResultSet> will not run
DeleteAction triggers. See C<delete_all> if you need triggers to run.
Any database-level cascade, restrict or trigger will be performed AFTER
DBIx-Class-DeleteAction based triggers.
Always use transactions, or else you might end up with inconsistent data.
=head1 SUPPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/DeploymentHandler.pm view on Meta::CPAN
To enable the various logging levels all you need to do is set an environment
variables: C<DBICDH_FATAL>, C<DBICDH_ERROR>, C<DBICDH_WARN>, C<DBICDH_INFO>,
C<DBICDH_DEBUG>, and C<DBICDH_TRACE>. Each level can be set on its own,
but the default is the first three on and the last three off, and the levels
cascade, so if you turn on trace the rest will turn on automatically.
=head1 DONATIONS
If you'd like to thank me for the work I've done on this module, don't give me
a donation. I spend a lot of free time creating free software, but I do it
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Sample/Schema/Result/Album.pm view on Meta::CPAN
__PACKAGE__->has_many(
"people",
"Sample::Schema::Result::Person",
{ "foreign.favorite_album_id" => "self.album_id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 producer
Type: belongs_to
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Events.pm view on Meta::CPAN
Default is C<events>, but you can override it:
__PACKAGE__->has_many(
'cd_events' =>
( 'MyApp::Schema::Result::ArtistEvents', 'cdid' ),
{ cascade_delete => 0 },
);
__PACKAGE__->events_relationship('cd_events');
=head2 Tables
lib/DBIx/Class/Events.pm view on Meta::CPAN
__PACKAGE__->load_components( qw/ Events / );
# A different name can be used with the "events_relationship" attribute
__PACKAGE__->has_many(
'events' => ( 'MyApp::Schema::Result::ArtistEvent', 'artistid' ),
{ cascade_delete => 0 },
);
You can also add custom events to track when something happens. For example,
you can create a method to add events when an artist changes their name:
lib/DBIx/Class/Events.pm view on Meta::CPAN
last_name_change_id => { data_type => 'integer' } );
__PACKAGE__->has_one(
'last_name_change' => 'MyApp::Schema::Result::ArtistEvent',
{ 'foreign.artisteventid' => 'self.last_name_change_id' },
{ cascade_delete => 0 },
);
sub change_name {
my ( $self, $new_name ) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Fixtures.pm view on Meta::CPAN
$self->msg("- clearing DB of existing tables");
$pre_schema->storage->txn_do(sub {
$pre_schema->storage->with_deferred_fk_checks(sub {
foreach my $table (@tables) {
eval {
$dbh->do("drop table $table" . ($params->{cascade} ? ' cascade' : '') )
};
}
});
});
lib/DBIx/Class/Fixtures.pm view on Meta::CPAN
# DDL to deploy after populating records, ie. FK constraints
post_ddl => '/home/me/app/sql/post_ddl.sql',
# use CASCADE option when dropping tables
cascade => 1,
# optional, set to 1 to run ddl but not populate
no_populate => 0,
# optional, set to 1 to run each fixture through ->create rather than have
lib/DBIx/Class/Fixtures.pm view on Meta::CPAN
If needed, you can specify a post_ddl attribute which is a DDL to be applied
after all the fixtures have been added to the database. A good use of this
option would be to add foreign key constraints since databases like Postgresql
cannot disable foreign key checks.
If your tables have foreign key constraints you may want to use the cascade
attribute which will make the drop table functionality cascade, ie 'DROP TABLE
$table CASCADE'.
C<directory> is a required attribute.
If you wish for DBIx::Class::Fixtures to clear the database for you pass in
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/CDTest/Schema/Result/Artist.pm view on Meta::CPAN
__PACKAGE__->has_many(
"artwork_to_artists",
"CDTest::Schema::Result::ArtworkToArtist",
{ "foreign.artist_id" => "self.artistid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 cds
Type: has_many
t/lib/CDTest/Schema/Result/Artist.pm view on Meta::CPAN
__PACKAGE__->has_many(
"cds",
"CDTest::Schema::Result::CD",
{ "foreign.artist" => "self.artistid" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 artwork_cds
Type: many_to_many
view all matches for this distribution
view release on metacpan or search on metacpan
examples/MusicBase/share/migrations/_source/deploy/1/001-auto-__VERSION.yml view on Meta::CPAN
- artist_id
_relationships:
cd_rs:
attrs:
accessor: multi
cascade_copy: 1
cascade_delete: 1
join_type: LEFT
class: MusicBase::Schema::Result::Cd
cond:
foreign.artist_fk: self.artist_id
source: MusicBase::Schema::Result::Cd
examples/MusicBase/share/migrations/_source/deploy/1/001-auto-__VERSION.yml view on Meta::CPAN
foreign.artist_id: self.artist_fk
source: MusicBase::Schema::Result::Artist
track_rs:
attrs:
accessor: multi
cascade_copy: 1
cascade_delete: 1
join_type: LEFT
class: MusicBase::Schema::Result::Track
cond:
foreign.cd_fk: self.cd_id
source: MusicBase::Schema::Result::Track
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Sample/Schema/Result/Customer.pm view on Meta::CPAN
__PACKAGE__->has_many(
"orders",
"Sample::Schema::Result::Order",
{ "foreign.customer_id" => "self.customer_id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 person
Type: belongs_to
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/PgLogTest/Schema/Result/Role.pm view on Meta::CPAN
__PACKAGE__->has_many(
"user_roles",
"PgLogTest::Schema::Result::UserRole",
{ "foreign.RoleId" => "self.Id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 users
Type: many_to_many
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/ResultSource/Table/Previewed.pm view on Meta::CPAN
);
$new_source->result_class( $target_class );
$target_class->result_source_instance($new_source)
if $target_class->can('result_source_instance');
$new_source->relationship_info($_)->{attrs}{cascade_delete} = 0
for $new_source->relationships;
my $new_source_name =
$self->source_name . '::preview';
$schema->register_extra_source( $new_source_name => $new_source );
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-rdbohelpers.t view on Meta::CPAN
ok( exists $m2m_tracks->{m2m}, "cd_tracks is a m2m" );
is_deeply(
$m2m_tracks,
{ attrs => {
accessor => "multi",
cascade_copy => 1,
cascade_delete => 1,
is_depends_on => 0,
join_type => "LEFT",
},
class => "MyDBIC::Schema::CdTrackJoin",
cond => { "foreign.cdid" => "self.cdid" },
t/01-rdbohelpers.t view on Meta::CPAN
ok( exists $m2m_cds->{m2m}, "track_cds is a m2m" );
is_deeply(
$m2m_cds,
{ attrs => {
accessor => "multi",
cascade_copy => 1,
cascade_delete => 1,
is_depends_on => 0,
join_type => "LEFT",
},
class => "MyDBIC::Schema::CdTrackJoin",
cond => { "foreign.trackid" => "self.trackid" },
t/01-rdbohelpers.t view on Meta::CPAN
# m2m to itself must be tested in a resultsource object not class
is_deeply(
$cd1->relationship_info('relationships'),
{ attrs => {
accessor => "multi",
cascade_copy => 1,
cascade_delete => 1,
is_depends_on => 0,
join_type => "LEFT",
},
class => "MyDBIC::Schema::CdToItself",
cond => { "foreign.cdid_one" => "self.cdid" },
view all matches for this distribution
view release on metacpan or search on metacpan
t/03_prefetch_problem.t view on Meta::CPAN
__PACKAGE__->load_components(qw/RandomStringColumns Core/);
__PACKAGE__->table('bar');
__PACKAGE__->add_columns(qw(foo_id session_id u_rand_id));
__PACKAGE__->set_primary_key('session_id');
__PACKAGE__->belongs_to('foo_id', 'TestDB::Schema::Foo', 'foo_id', {cascade_delete => 0});
__PACKAGE__->resultset_attributes({where => {'foo_id.delete_fg' => 0}, prefetch => 'foo_id', order_by => 'me.session_id DESC'});
__PACKAGE__->random_string_columns('u_rand_id');
__PACKAGE__->random_string_columns('session_id');
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/ResultDDL.pm view on Meta::CPAN
blob tinyblob mediumblob longblob text tinytext mediumtext longtext ntext bytea
date datetime timestamp enum bool boolean
uuid json jsonb inflate_json array
primary_key idx create_index unique sqlt_add_index sqlt_add_constraint
rel_one rel_many has_one might_have has_many belongs_to many_to_many
ddl_cascade dbic_cascade
);
our %EXPORT_TAGS;
$EXPORT_TAGS{V2}= \@V2;
export @V2;
lib/DBIx/Class/ResultDDL.pm view on Meta::CPAN
is_foreign_key_constraint => 1,
undef_on_null_fk => 1,
) : (
is_depends_on => 0,
)),
cascade_copy => 0, cascade_delete => 0,
%$opts
}
);
} else {
require DBIx::Class::Core;
DBIx::Class::Core->can($reltype)->($pkg, $relname, $rel_pkg, $dbic_colmap, $opts);
}
}
sub ddl_cascade {
my $mode= shift;
$mode= 'CASCADE' if !defined $mode || $mode eq '1';
$mode= 'RESTRICT' if $mode eq '0';
return
on_update => $mode,
on_delete => $mode;
}
sub dbic_cascade {
my $mode= defined $_[0]? $_[0] : 1;
return
cascade_copy => $mode,
cascade_delete => $mode;
}
sub view {
my ($name, $definition, %opts) = @_;
lib/DBIx/Class/ResultDDL.pm view on Meta::CPAN
blob tinyblob mediumblob longblob text tinytext mediumtext longtext ntext bytea
date datetime timestamp enum bool boolean
uuid json jsonb inflate_json array
primary_key idx create_index unique sqlt_add_index sqlt_add_constraint
rel_one rel_many has_one might_have has_many belongs_to many_to_many
ddl_cascade dbic_cascade
=head2 C<:V1>
See L<DBIx::Class::ResultDDL::V1>. The primary difference from V2 is a bug in
C<datetime($timezone)> where the timezone generated the wrong DBIC arguments.
lib/DBIx/Class/ResultDDL.pm view on Meta::CPAN
__PACKAGE__->add_relationship(
$rel_name, $peer_class, { "foreign.$fcol" => "self.$mycol" },
{
join_type => 'LEFT',
accessor => 'single',
cascade_copy => 0,
cascade_delete => 0,
is_depends_on => $is_f_pk, # auto-detected, unless specified
($is_f_pk? fk_columns => { $mycol => 1 } : ()),
@attr_list
}
);
lib/DBIx/Class/ResultDDL.pm view on Meta::CPAN
rel_many $name => { $my_col => "$class.$col", ... }, @attr_list;
rel_many $name => 'JOIN $peer_class ON $sql', @attr_list;
Same as L</rel_one>, but generates a one-to-many relation with a multi-accessor.
=head2 ddl_cascade
ddl_cascade; # same as ddl_cascade("CASCADE");
ddl_cascade(1); # same as ddl_cascade("CASCADE");
ddl_cascade(0); # same as ddl_cascade("RESTRICT");
ddl_cascade($mode);
Helper method to generate C<@options> for above. It generates
on_update => $mode, on_delete => $mode
This does not affect client-side cascade, and is only used by Schema::Loader to generate DDL
for the foreign keys when the table is deployed.
=head2 dbic_cascade
dbic_cascade; # same as dbic_cascade(1)
dbic_cascade($enabled);
Helper method to generate C<@options> for above. It generates
cascade_copy => $enabled, cascade_delete => $enabled
This re-enables the dbic-side cascading that was disabled by default in the C<rel_> functions.
=head2 view
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/AnotherTestDB/OnePK/Schema/Result/Item.pm view on Meta::CPAN
__PACKAGE__->has_many(
"relateditems",
"AnotherTestDB::OnePK::Schema::Result::RelatedItem",
{ "foreign.item_id" => "self.idcol" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"true_relateditems",
"AnotherTestDB::OnePK::Schema::Result::RelatedItem",
{ "foreign.item_id" => "self.idcol" },
{where => { 'conditionitems.condition' => 'true'},
'join' => qq/conditionitems/,
cascade_copy => 0, cascade_delete => 0 },
);
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Schema/Diff.pm view on Meta::CPAN
$hash = $D->filter_out({ events => [qw(added deleted)] })
->filter_out('Album','Genre')
->filter('constraints')
->diff;
# All changes to relationship attrs except for 'cascade_delete' in
# relationships named 'artists':
$hash = $D->filter_out('relationships/artists.attrs.cascade_delete')
->filter('relationships/*.attrs')
->diff;
=head1 DESCRIPTION
lib/DBIx/Class/Schema/Diff.pm view on Meta::CPAN
},
staffs => {
_event => "changed",
diff => {
attrs => {
cascade_delete => 1
}
}
}
}
},
lib/DBIx/Class/Schema/Diff.pm view on Meta::CPAN
'Artist:columns/my_enum.extra.list'
The structure is specific to the type. The dot-separated path applies to the data returned by L<column_info|DBIx::Class::ResultSource#column_info> for columns and
L<relationship_info|DBIx::Class::ResultSource#relationship_info> for relationships. For instance,
the following matches changes to C<cascade_delete> of a specific relationship named 'some_rel'
in the 'Artist' source:
'Artist:relationships/some_rel.attrs.cascade_delete'
Filter arguments can also match I<broadly> using the wildcard asterisk character (C<*>). For
instance, to match I<'isa'> changes in any source:
'*:isa'
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/dbixcsl_common_tests.pm view on Meta::CPAN
ok ($rsobj4->result_source->has_relationship('loader_test5s_from'),
"rel with preposition 'from' pluralized correctly");
# check default relationship attributes
is try { $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{cascade_delete} }, 0,
'cascade_delete => 0 on has_many by default';
is try { $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{cascade_copy} }, 0,
'cascade_copy => 0 on has_many by default';
ok ((not try { exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{on_delete} }),
'has_many does not have on_delete');
ok ((not try { exists $rsobj3->result_source->relationship_info('loader_test4zes')->{attrs}{on_update} }),
t/lib/dbixcsl_common_tests.pm view on Meta::CPAN
is try { $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{is_deferrable} },
$default_is_deferrable,
"is_deferrable => $default_is_deferrable on belongs_to by default";
ok ((not try { exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_delete} }),
'belongs_to does not have cascade_delete');
ok ((not try { exists $rsobj4->result_source->relationship_info('fkid_singular')->{attrs}{cascade_copy} }),
'belongs_to does not have cascade_copy');
is try { $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{cascade_delete} }, 0,
'cascade_delete => 0 on might_have by default';
is try { $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{cascade_copy} }, 0,
'cascade_copy => 0 on might_have by default';
ok ((not try { exists $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{on_delete} }),
'might_have does not have on_delete');
ok ((not try { exists $rsobj27->result_source->relationship_info('loader_test28')->{attrs}{on_update} }),
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Schema/Loader/Base.pm view on Meta::CPAN
override the introspected attributes of the foreign key if any.
For example:
relationship_attrs => {
has_many => { cascade_delete => 1, cascade_copy => 1 },
might_have => { cascade_delete => 1, cascade_copy => 1 },
},
use this to turn L<DBIx::Class> cascades to on on your
L<has_many|DBIx::Class::Relationship/has_many> and
L<might_have|DBIx::Class::Relationship/might_have> relationships, they default
to off.
Can also be a coderef, for more precise control, in which case the coderef gets
lib/DBIx/Class/Schema/Loader/Base.pm view on Meta::CPAN
},
These are the default attributes:
has_many => {
cascade_delete => 0,
cascade_copy => 0,
},
might_have => {
cascade_delete => 0,
cascade_copy => 0,
},
belongs_to => {
on_delete => 'CASCADE',
on_update => 'CASCADE',
is_deferrable => 1,
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Test/Deploy.pm view on Meta::CPAN
};
my $bar_relations = {
trees => {
attrs => {
accessor => "multi",
cascade_copy => 1,
cascade_delete => 1,
join_type => "LEFT",
},
class => $self->schema_class . "::Result::Tree",
cond => { "foreign.bars_id" => "self.bars_id" },
source => $self->schema_class . "::Result::Tree"
t/lib/Test/Deploy.pm view on Meta::CPAN
};
my $bar_relations = {
trees => {
attrs => {
accessor => "multi",
cascade_copy => 1,
cascade_delete => 1,
join_type => "LEFT",
},
class => $self->schema_class . "::Result::Tree",
cond => { "foreign.bars_id" => "self.bars_id" },
source => $self->schema_class . "::Result::Tree"
t/lib/Test/Deploy.pm view on Meta::CPAN
};
my $bar_relations = {
trees => {
attrs => {
accessor => "multi",
cascade_copy => 1,
cascade_delete => 1,
join_type => "LEFT",
},
class => $self->schema_class . "::Result::Tree",
cond => { "foreign.bars_id" => "self.bars_id" },
source => $self->schema_class . "::Result::Tree"
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/CDBICompat/Relationships.pm view on Meta::CPAN
}
if (ref $f_key eq 'HASH' && !$args) { $args = $f_key; undef $f_key; };
$args ||= {};
my $cascade = delete $args->{cascade} || '';
if (delete $args->{no_cascade_delete} || $cascade eq 'None') {
$args->{cascade_delete} = 0;
}
elsif( $cascade eq 'Delete' ) {
$args->{cascade_delete} = 1;
}
elsif( length $cascade ) {
warn "Unemulated cascade option '$cascade' in $class->has_many($rel => $f_class)";
}
if( !$f_key and !@f_method ) {
$class->ensure_class_loaded($f_class);
my $f_source = $f_class->result_source_instance;
view all matches for this distribution