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
t/regressions/preferences_table.t view on Meta::CPAN
use YAML::Any qw( LoadFile );
# Needs the following where-clause in the has_many()
# {
# where => { 'me.type' => 'artist' },
# cascade_delete => 0,
# cache_for => 1,
# }
BEGIN {
use loader qw(build_schema);
view all matches for this distribution
view release on metacpan or search on metacpan
t/02-schema-helper-row-definition.t view on Meta::CPAN
my $relationship_info = $schema->Book->result_source->relationship_info('editions');
my $expected_relationship_info = {
'attrs' => {
'accessor' => 'multi',
'cascade_copy' => 1,
'cascade_delete' => 1,
'is_depends_on' => 0,
'join_type' => 'LEFT'
},
'class' => 'TestFor::DBIx::Class::Smooth::Schema::Result::Edition',
'cond' => {
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/Tree/Mobius.pm view on Meta::CPAN
});
$class->has_many( '_children' => $1 => {
"foreign.".$class->_mobius_b_column => "self.".$class->_mobius_a_column,
"foreign.".$class->_mobius_d_column => "self.".$class->_mobius_c_column,
}, { cascade_delete => 0 });
}
Math::BigFloat->accuracy(53);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Tree/NestedSet.pm view on Meta::CPAN
$class->has_many(
'nodes' => $class,
\%join_cond,{
order_by => "me.$left",
cascade_delete => 0,
},
);
$class->has_many(
'descendants' => $class,
\%join_cond, {
where => \"me.$left > parent.$left AND me.$right < parent.$right", #"
order_by => "me.$left",
from => "$table me, $table parent",
cascade_delete => 0,
},
);
$class->has_many(
'children' => $class,
\%join_cond, {
where => \"me.$left > parent.$left AND me.$right < parent.$right AND me.$level = parent.$level + 1", #"
order_by => "me.$left",
from => "$table me, $table parent",
cascade_delete => 0,
},
);
$class->has_many(
'ancestors' => $class,
\%join_cond, {
where => \"child.$left > me.$left AND child.$right < me.$right", #"
order_by => "me.$right",
from => "$table me, $table child",
cascade_delete => 0,
},
);
$class->_tree_columns($args);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Tree/AdjacencyList.pm view on Meta::CPAN
if (@_) {
my $parent_col = shift;
my $primary_col = ($class->primary_columns())[0];
$class->belongs_to( '_parent' => $class => { "foreign.$primary_col" => "self.$parent_col" } );
$class->has_many( 'children' => $class => { "foreign.$parent_col" => "self.$primary_col" } );
$class->has_many( 'parents' => $class => { "foreign.$primary_col" => "self.$parent_col" }, { cascade_delete => 0, cascade_copy => 0 } );
$class->_parent_column( $parent_col );
return 1;
}
return $class->_parent_column();
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/Class/Visualizer.pm view on Meta::CPAN
"origin_table": "TableName",
"origin_column": "a_column_id",
"destination_table": "AnotherTableName"
"destination_column": "a_column_id",
"relation_type": "has_many",
"cascade_delete": 1,
},
...
],
}">a_column_id</text>
view all matches for this distribution
view release on metacpan or search on metacpan
DBO2/Fields.pm view on Meta::CPAN
=head3 restrict_delete Interface
Identical to the default interface except as follows: an ok_delete hook is installed to check for the existance of any related records, in which case the deletion is cancelled. This prevents you from deleting the "parent" record for a number of relat...
=head3 cascade_delete Interface
Identical to the default interface except as follows: a post_delete hook is installed to delete all of the related records after the parent record is deleted.
=head3 nullify_delete Interface
DBO2/Fields.pm view on Meta::CPAN
-params => {
delete_default => undef,
hook => { post_delete => 'nullify_*' }
},
},
cascade_delete => {
-base => 'default',
-params => {
hook => { post_delete => 'delete_*' }
},
},
view all matches for this distribution
view release on metacpan or search on metacpan
t/data/chado-cvterm.sql view on Meta::CPAN
create table db (
db_id serial not null,
primary key (db_id),
name varchar(255) not null,
contact_id int,
foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED,
description varchar(255) null,
urlprefix varchar(255) null,
url varchar(255) null,
constraint db_c1 unique (name)
);
t/data/chado-cvterm.sql view on Meta::CPAN
create table dbxref (
dbxref_id serial not null,
primary key (dbxref_id),
db_id int not null,
foreign key (db_id) references db (db_id) on delete cascade INITIALLY DEFERRED,
accession varchar(255) not null,
version varchar(255) not null default '',
description text,
constraint dbxref_c1 unique (db_id,accession,version)
);
t/data/chado-cvterm.sql view on Meta::CPAN
create table cvterm (
cvterm_id serial not null,
primary key (cvterm_id),
cv_id int not null,
foreign key (cv_id) references cv (cv_id) on delete cascade INITIALLY DEFERRED,
name varchar(1024) not null,
definition text,
dbxref_id int not null,
foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED,
is_obsolete int not null default 0,
t/data/chado-cvterm.sql view on Meta::CPAN
create table cvterm_relationship (
cvterm_relationship_id serial not null,
primary key (cvterm_relationship_id),
type_id int not null,
foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
subject_id int not null,
foreign key (subject_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
object_id int not null,
foreign key (object_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
constraint cvterm_relationship_c1 unique (subject_id,object_id,type_id)
);
COMMENT ON TABLE cvterm_relationship IS
'A relationship linking two cvterms. A relationship can be thought of
as an edge in a graph, or as a natural language statement about
t/data/chado-cvterm.sql view on Meta::CPAN
cvtermpath_id serial not null,
primary key (cvtermpath_id),
type_id int,
foreign key (type_id) references cvterm (cvterm_id) on delete set null INITIALLY DEFERRED,
subject_id int not null,
foreign key (subject_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
object_id int not null,
foreign key (object_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
cv_id int not null,
foreign key (cv_id) references cv (cv_id) on delete cascade INITIALLY DEFERRED,
pathdistance int,
constraint cvtermpath_c1 unique (subject_id,object_id,type_id,pathdistance)
);
create index cvtermpath_idx1 on cvtermpath (type_id);
create index cvtermpath_idx2 on cvtermpath (subject_id);
t/data/chado-cvterm.sql view on Meta::CPAN
create table cvtermsynonym (
cvtermsynonym_id serial not null,
primary key (cvtermsynonym_id),
cvterm_id int not null,
foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
synonym varchar(1024) not null,
type_id int,
foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
constraint cvtermsynonym_c1 unique (cvterm_id,synonym)
);
create index cvtermsynonym_idx1 on cvtermsynonym (cvterm_id);
-- ================================================
t/data/chado-cvterm.sql view on Meta::CPAN
create table cvterm_dbxref (
cvterm_dbxref_id serial not null,
primary key (cvterm_dbxref_id),
cvterm_id int not null,
foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
dbxref_id int not null,
foreign key (dbxref_id) references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED,
is_for_definition int not null default 0,
constraint cvterm_dbxref_c1 unique (cvterm_id,dbxref_id)
);
create index cvterm_dbxref_idx1 on cvterm_dbxref (cvterm_id);
create index cvterm_dbxref_idx2 on cvterm_dbxref (dbxref_id);
t/data/chado-cvterm.sql view on Meta::CPAN
create table cvtermprop (
cvtermprop_id serial not null,
primary key (cvtermprop_id),
cvterm_id int not null,
foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade,
type_id int not null,
foreign key (type_id) references cvterm (cvterm_id) on delete cascade,
value text not null default '',
rank int not null default 0,
unique(cvterm_id, type_id, value, rank)
);
t/data/chado-cvterm.sql view on Meta::CPAN
create table organism_dbxref (
organism_dbxref_id serial not null,
primary key (organism_dbxref_id),
organism_id int not null,
foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED,
dbxref_id int not null,
foreign key (dbxref_id) references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED,
constraint organism_dbxref_c1 unique (organism_id,dbxref_id)
);
create index organism_dbxref_idx1 on organism_dbxref (organism_id);
create index organism_dbxref_idx2 on organism_dbxref (dbxref_id);
t/data/chado-cvterm.sql view on Meta::CPAN
create table organismprop (
organismprop_id serial not null,
primary key (organismprop_id),
organism_id int not null,
foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED,
type_id int not null,
foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED,
value text null,
rank int not null default 0,
constraint organismprop_c1 unique (organism_id,type_id,rank)
);
create index organismprop_idx1 on organismprop (organism_id);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/DataModel.pm view on Meta::CPAN
C<DBIx::DataModel> does not keep track of data mutations
in memory, and therefore provides no support for automatically
propagating changes into the database; the client code has to
explicitly manage C<insert> and C<update> operations.
=item no 'cascaded update' nor 'insert or update'
Cascaded inserts and deletes are supported, but not cascaded updates.
This would need 'insert or update', which is not supported.
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/EAV.pm view on Meta::CPAN
my ( $orig, $class, @args ) = @_;
my $params = @args == 1 && ref $args[0] ? $args[0] : { @args };
my $schema_config = delete $params->{schema_config} || {};
my @schema_params = grep { exists $params->{$_} } qw/
tenant_id data_types database_cascade_delete static_attributes
table_prefix id_type default_attribute_type enable_multi_tenancy
/;
@{$schema_config}{@schema_params} = delete @{$params}{@schema_params};
view all matches for this distribution