view release on metacpan or search on metacpan
name quoting
- Fix problems with M.A.D. under CGI::SpeedyCGI (RT#65131)
- Reenable paging of cached resultsets - breakage erroneously added
in 0.08127
- Better error handling when prepare() fails silently
- Fixes skipped lines when a comment is followed by a statement
when deploying a schema via sql file
- Fix reverse_relationship_info on prototypical result sources
(sources not yet registered with a schema)
- Warn and skip relationships missing from a partial schema during
dbic cascade_delete
- Automatically require the requested cursor class before use
(RT#64795)
- Work around a Firebird ODBC driver bug exposed by DBD::ODBC 1.29
- Fix (to the extent allowed by the driver) transaction support in
DBD::Sybase compiled against FreeTDS
- Fix exiting via next warnings in ResultSource::sequence()
- Fix stripping of table qualifiers in update/delete in arrayref
condition elements
- Change SQLMaker carp-monkeypatch to be compatible with versions
of SQL::Abstract >= 1.73
- Fix nasty potentially data-eating bug when deleting/updating
a limited resultset
- Fix find() to use result_class set on object
- Fix result_class setter behaviour to not mistakenly stuff attrs.
- Don't try and ensure_class_loaded an object. This doesn't work.
- Fix as_subselect_rs to not inject resultset class-wide where
conditions outside of the resulting subquery
- Fix count() failing with {for} resultset attribute (RT#56257)
- Fixed incorrect detection of Limit dialect on unconnected $schema
- update() on row not in_storage no longer throws an exception
if there are no dirty columns to update (fixes cascaded update
annoyances)
- update()/delete() on prefetching resultsets no longer results
in malformed SQL (some $rs attributes were erroneously left in)
- Fix dbicadmin to allow deploy() on non-versioned schema
- Fix dbicadmin to respect sql_dir on upgrade() (RT#57732)
- Update Schema::Versioned to respect hashref style of
connection_info
- Do not recreate the same related object twice during MultiCreate
(solves the problem of orphaned IC::FS files)
- Fully qualify xp_msver selector when using DBD::Sybase with
loaded
- CDBICompat: override find_or_create to fix column casing when
ColumnCase is loaded
- reorganized and simplified tests
- added Ordered
- added the ability to set on_connect_do and the various sql_maker
options as part of Storage::DBI's connect_info.
0.06003 2006-05-19 15:37:30
- make find_or_create_related check defined() instead of truth
- don't unnecessarily fetch rels for cascade_update
- don't set_columns explicitly in update_or_create; instead use
update($hashref) so InflateColumn works
- fix for has_many prefetch with 0 related rows
- make limit error if rows => 0
- added memory cycle tests and a long-needed weaken call
0.06002 2006-04-20 00:42:41
- fix set_from_related to accept undef
- fix to Dumper-induced hash iteration bug
- fix to copy() with non-composed resultsource
- renamed cols attribute to columns (cols still supported)
- added has_column_loaded to Row
- Storage::DBI connect_info supports coderef returning dbh as 1st arg
- load_components() doesn't prepend base when comp. prefixed with +
- $schema->deploy
- HAVING support
- prefetch for has_many
- cache attr for resultsets
- PK::Auto::* no longer required since Storage::DBI::* handle auto-inc
- minor tweak to tests for join edge case
- added cascade_copy relationship attribute
(sponsored by Airspace Software, http://www.airspace.co.uk/)
- clean up set_from_related
- made copy() automatically null out auto-inc columns
- added txn_do() method to Schema, which allows a coderef to be
executed atomically
0.05007 2006-02-24 00:59:00
- tweak to Componentised for Class::C3 0.11
- fixes for auto-inc under MSSQL
demo/dbio-demo view on Meta::CPAN
# -- Update -----------------------------------------------------------------
step("Update: rename 'Die Mensch-Maschine' to 'The Man-Machine'");
my $cd = $schema->resultset('CD')->find({ title => 'Die Mensch-Maschine' });
$cd->update({ title => 'The Man-Machine' });
show("New title:", $cd->title);
# -- Delete -----------------------------------------------------------------
step("Delete: remove Nina Simone and cascade");
my $nina = $schema->resultset('Artist')->find({ name => 'Nina Simone' });
# manual cascade: delete tracks, then CDs, then artist
for my $nina_cd ($nina->cds->all) {
$nina_cd->tracks->delete;
$nina_cd->delete;
}
$nina->delete;
show("Artists now:", $schema->resultset('Artist')->count);
show("CDs now:", $schema->resultset('CD')->count);
show("Tracks now:", $schema->resultset('Track')->count);
# -- Transaction ------------------------------------------------------------
lib/DBIO/Cake.pm view on Meta::CPAN
my @table_funcs = qw(
table col primary_key unique
);
my @relationship_funcs = qw(
belongs_to has_one has_many might_have many_to_many
rel_one rel_many
);
my @cascade_funcs = qw(
ddl_cascade dbic_cascade
);
my @other_funcs = qw(
view idx
col_created col_updated cols_updated_created
);
@EXPORT = (
@col_types, @col_modifiers,
@table_funcs, @relationship_funcs,
@cascade_funcs, @other_funcs,
);
# Per-caller options storage
my %CALLER_OPTS;
sub import {
my ($class, @args) = @_;
my $caller = caller;
# Parse import options
lib/DBIO/Cake.pm view on Meta::CPAN
# rel_many: has_many (already LEFT JOIN by default, but explicit)
sub rel_many {
my ($name, $related, @rest) = @_;
my $class = _caller_class();
$class->has_many($name, $related, @rest);
}
# --- Cascade helpers ---
sub ddl_cascade {
return (
on_delete => 'CASCADE',
on_update => 'CASCADE',
);
}
sub dbic_cascade {
return (
cascade_delete => 1,
cascade_copy => 1,
);
}
# --- Views ---
sub view {
my ($name, $sql, %opts) = @_;
my $class = _caller_class();
$class->table_class('DBIO::ResultSource::View')
lib/DBIO/Cake.pm view on Meta::CPAN
=head2 rel_one
Like C<belongs_to> but forces C<join_type =E<gt> 'left'>.
=head2 rel_many
Alias for C<has_many>.
=head1 CASCADE HELPERS
=head2 ddl_cascade
Returns C<on_delete =E<gt> 'CASCADE', on_update =E<gt> 'CASCADE'> for use in
relationship attribute hashes.
=head2 dbic_cascade
Returns C<cascade_delete =E<gt> 1, cascade_copy =E<gt> 1>.
=head1 VIEW SUPPORT
=head2 view
view 'my_view', 'SELECT * FROM artists WHERE active = 1';
Declares a view-based result source.
=head1 TIMESTAMP HELPERS
lib/DBIO/Manual/FAQ.pod view on Meta::CPAN
Instead of supplying a single column name, all relationship types also
allow you to supply a hashref containing the condition across which
the tables are to be joined. The condition may contain as many fields
as you like. See L<DBIO::Relationship::Base>.
=item .. define a relationship bridge across an intermediate table? (many-to-many)
The term 'relationship' is used loosely with many_to_many as it is not considered a
relationship in the fullest sense. For more info, read the documentation on L<DBIO::Relationship/many_to_many>.
=item .. stop DBIO from attempting to cascade deletes on my has_many and might_have relationships?
By default, DBIO cascades deletes and updates across
C<has_many> and C<might_have> relationships. You can disable this
behaviour on a per-relationship basis by supplying
C<< cascade_delete => 0 >> in the relationship attributes.
The cascaded operations are performed after the requested delete or
update, so if your database has a constraint on the relationship, it
will have deleted/updated the related records or raised an exception
before DBIO gets to perform the cascaded operation.
See L<DBIO::Relationship>.
=item .. use a relationship?
Use its name. An accessor is created using the name. See examples in
L<DBIO::Manual::Cookbook/USING RELATIONSHIPS>.
=back
lib/DBIO/Relationship.pm view on Meta::CPAN
# in a Book class (where Author has_many Books)
__PACKAGE__->belongs_to(
author =>
'My::DBIO::Schema::Author',
'author',
{ join_type => 'left' }
);
Cascading deletes are off by default on a C<belongs_to>
relationship. To turn them on, pass C<< cascade_delete => 1 >>
in the $attr hashref.
By default, DBIO will return undef and avoid querying the database if a
C<belongs_to> accessor is called when any part of the foreign key IS NULL. To
disable this behavior, pass C<< undef_on_null_fk => 0 >> in the C<\%attrs>
hashref.
NOTE: If you are used to L<Class::DBI> relationships, this is the equivalent
of C<has_a>.
lib/DBIO/Relationship.pm view on Meta::CPAN
The second is almost exactly the same as the accessor method but "_rs"
is added to the end of the method name, eg C<$accessor_name_rs()>.
This method works just like the normal accessor, except that it always
returns a resultset, even in list context. The third method, named C<<
add_to_$rel_name >>, will also be added to your Row items; this allows
you to insert new related items, using the same mechanism as in
L<DBIO::Relationship::Base/"create_related">.
If you delete an object in a class with a C<has_many> relationship, all
the related objects will be deleted as well. To turn this behaviour off,
pass C<< cascade_delete => 0 >> in the C<$attr> hashref.
The cascaded operations are performed after the requested delete or
update, so if your database has a constraint on the relationship, it
will have deleted/updated the related records or raised an exception
before DBIO gets to perform the cascaded operation.
If you copy an object in a class with a C<has_many> relationship, all
the related objects will be copied as well. To turn this behaviour off,
pass C<< cascade_copy => 0 >> in the C<$attr> hashref. The behaviour
defaults to C<< cascade_copy => 1 >>.
See L<DBIO::Relationship::Base/attributes> for documentation on
relationship methods and valid relationship attributes. Also see
L<DBIO::ResultSet> for a L<list of standard resultset
attributes|DBIO::ResultSet/ATTRIBUTES> which can be assigned to
relationships as well.
=head2 might_have
=over 4
lib/DBIO/Relationship.pm view on Meta::CPAN
pseudonym =>
'My::DBIO::Schema::Pseudonym',
{ 'foreign.author_id' => 'self.id' },
);
# Usage
my $pname = $author->pseudonym; # to get the Pseudonym object
If you update or delete an object in a class with a C<might_have>
relationship, the related object will be updated or deleted as well. To
turn off this behavior, add C<< cascade_delete => 0 >> to the C<$attr>
hashref.
The cascaded operations are performed after the requested delete or
update, so if your database has a constraint on the relationship, it
will have deleted/updated the related records or raised an exception
before DBIO gets to perform the cascaded operation.
See L<DBIO::Relationship::Base/attributes> for documentation on
relationship methods and valid relationship attributes. Also see
L<DBIO::ResultSet> for a L<list of standard resultset
attributes|DBIO::ResultSet/ATTRIBUTES> which can be assigned to
relationships as well.
Note that if you supply a condition on which to join, and the column in the
current table allows nulls (i.e., has the C<is_nullable> attribute set to a
true value), than C<might_have> will warn about this because it's naughty and
lib/DBIO/Relationship/Base.pm view on Meta::CPAN
=item join_type
Explicitly specifies the type of join to use in the relationship. Any SQL
join type is valid, e.g. C<LEFT> or C<RIGHT>. It will be placed in the SQL
command immediately before C<JOIN>.
=item proxy =E<gt> $column | \@columns | \%column
The 'proxy' attribute can be used to retrieve values, and to perform
updates if the relationship has 'cascade_update' set. The 'might_have'
and 'has_one' relationships have this set by default; if you want a proxy
to update across a 'belongs_to' relationship, you must set the attribute
yourself.
=over 4
=item \@columns
An arrayref containing a list of accessors in the foreign class to create in
the main class. If, for example, you do the following:
lib/DBIO/Relationship/Base.pm view on Meta::CPAN
undef, {
proxy => [ qw/notes/ ],
});
Then, assuming MyApp::Schema::LinerNotes has an accessor named notes, you can do:
my $cd = MyApp::Schema::CD->find(1);
$cd->notes('Notes go here'); # set notes -- LinerNotes object is
# created if it doesn't exist
For a 'belongs_to relationship, note the 'cascade_update':
MyApp::Schema::Track->belongs_to( cd => 'MyApp::Schema::CD', 'cd,
{ proxy => ['title'], cascade_update => 1 }
);
$track->title('New Title');
$track->update; # updates title in CD
=item \%column
A hashref where each key is the accessor you want installed in the main class,
and its value is the name of the original in the foreign class.
MyApp::Schema::Track->belongs_to( cd => 'MyApp::Schema::CD', 'cd', {
lib/DBIO/Relationship/Base.pm view on Meta::CPAN
related object, but you also want the relationship accessor to double as
a column accessor). For C<multi> accessors, an add_to_* method is also
created, which calls C<create_related> for the relationship.
=item is_foreign_key_constraint
If you find that DBIO is creating constraints where it shouldn't, or not
creating them where it should, set this attribute to a true or false value
to override the detection of when to create constraints.
=item cascade_copy
If C<cascade_copy> is true on a C<has_many> relationship for an
object, then when you copy the object all the related objects will
be copied too. To turn this behaviour off, pass C<< cascade_copy => 0 >>
in the C<$attr> hashref.
The behaviour defaults to C<< cascade_copy => 1 >> for C<has_many>
relationships.
=item cascade_delete
By default, DBIO cascades deletes across C<has_many>,
C<has_one> and C<might_have> relationships. You can disable this
behaviour on a per-relationship basis by supplying
C<< cascade_delete => 0 >> in the relationship attributes.
The cascaded operations are performed after the requested delete,
so if your database has a constraint on the relationship, it will
have deleted/updated the related records or raised an exception
before DBIO gets to perform the cascaded operation.
=item cascade_update
By default, DBIO cascades updates across C<has_one> and
C<might_have> relationships. You can disable this behaviour on a
per-relationship basis by supplying C<< cascade_update => 0 >> in
the relationship attributes.
The C<belongs_to> relationship does not update across relationships
by default, so if you have a 'proxy' attribute on a belongs_to and want to
use 'update' on it, you must set C<< cascade_update => 1 >>.
This is not a RDMS style cascade update - it purely means that when
an object has update called on it, all the related objects also
have update called. It will not change foreign keys automatically -
you must arrange to do this yourself.
=item on_delete / on_update
Use these attributes to explicitly set the desired C<ON DELETE> or
C<ON UPDATE> constraint type. For any 'multi' relationship with
C<< cascade_delete => 1 >>, the corresponding belongs_to relationship
will be created with an C<ON DELETE CASCADE> constraint. For any relationship
bearing C<< cascade_copy => 1 >> the resulting belongs_to constraint will be
C<ON UPDATE CASCADE>. If you wish to disable this autodetection, and just use
the RDBMS' default constraint type, pass C<< on_delete => undef >> or
C<< on_delete => '' >>, and the same for C<on_update> respectively.
=item is_deferrable
Indicates that the foreign key constraint should be deferrable. In other
words, the user may request that the constraint be ignored until the end
of the transaction. Currently, only the PostgreSQL producer actually
supports this.
lib/DBIO/Relationship/CascadeActions.pm view on Meta::CPAN
sub delete {
my ($self, @rest) = @_;
return $self->next::method(@rest) unless ref $self;
# I'm just ignoring this for class deletes because hell, the db should
# be handling this anyway. Assuming we have joins we probably actually
# *could* do them, but I'd rather not.
my $source = $self->result_source;
my %rels = map { $_ => $source->relationship_info($_) } $source->relationships;
my @cascade = grep { $rels{$_}{attrs}{cascade_delete} } keys %rels;
if (@cascade) {
my $guard = $source->schema->txn_scope_guard;
my $ret = $self->next::method(@rest);
foreach my $rel (@cascade) {
if( my $rel_rs = eval{ $self->search_related($rel) } ) {
$rel_rs->delete_all;
} else {
carp "Skipping cascade delete on relationship '$rel' - related resultsource '$rels{$rel}{class}' is not registered with this schema";
next;
}
}
$guard->commit;
return $ret;
}
$self->next::method(@rest);
}
sub update {
my ($self, @rest) = @_;
return $self->next::method(@rest) unless ref $self;
# Because update cascades on a class *really* don't make sense!
my $source = $self->result_source;
my %rels = map { $_ => $source->relationship_info($_) } $source->relationships;
my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;
if (@cascade) {
my $guard = $source->schema->txn_scope_guard;
my $ret = $self->next::method(@rest);
foreach my $rel (@cascade) {
next if (
$rels{$rel}{attrs}{accessor}
&&
$rels{$rel}{attrs}{accessor} eq 'single'
&&
!exists($self->{_relationship_data}{$rel})
);
$_->update for grep defined, $self->$rel;
}
lib/DBIO/Relationship/HasMany.pm view on Meta::CPAN
# # only perform checks if the far side appears already loaded
# if (my $f_rsrc = try { $f_class->result_source_instance } ) {
# $class->throw_exception(
# "No such column '$f_key' on foreign class ${f_class} ($guess)"
# ) if !$f_rsrc->has_column($f_key);
# }
$cond = { "foreign.${f_key}" => "self.${pri}" };
}
my $default_cascade = ref $cond eq 'CODE' ? 0 : 1;
$class->add_relationship($rel, $f_class, $cond, {
accessor => 'multi',
join_type => 'LEFT',
cascade_delete => $default_cascade,
cascade_copy => $default_cascade,
is_depends_on => 0,
%{$attrs||{}}
});
}
1;
__END__
=pod
lib/DBIO/Relationship/HasOne.pm view on Meta::CPAN
# if (! $f_rsrc and $f_rsrc = try { $f_class->result_source_instance }) {
# $class->throw_exception(
# "No such column '$f_key' on foreign class ${f_class} ($guess)"
# ) if !$f_rsrc->has_column($f_key);
# }
$cond = { "foreign.${f_key}" => "self.${pri}" };
}
$class->_validate_has_one_condition($cond);
my $default_cascade = ref $cond eq 'CODE' ? 0 : 1;
$class->add_relationship($rel, $f_class,
$cond,
{ accessor => 'single',
cascade_update => $default_cascade,
cascade_delete => $default_cascade,
is_depends_on => 0,
($join_type ? ('join_type' => $join_type) : ()),
%{$attrs || {}} });
1;
}
sub _validate_has_one_condition {
my ($class, $cond ) = @_;
lib/DBIO/ResultSet.pm view on Meta::CPAN
=item Return Value: $underlying_storage_rv
=back
Sets the specified columns in the resultset to the supplied values in a
single query. Note that this will not run any accessor/set_column/update
triggers, nor will it update any result object instances derived from this
resultset (this includes the contents of the L<resultset cache|/set_cache>
if any). See L</update_all> if you need to execute any on-update
triggers or cascades defined either by you or a
L<result component|DBIO::Manual::Component/WHAT IS A COMPONENT>.
The return value is a pass through of what the underlying
storage backend returned, and may vary. See L<DBI/execute> for the most
common case.
=head3 CAVEAT
Note that L</update> does not process/deflate any of the values passed in.
This is unlike the corresponding L<DBIO::Row/update>. The user must
lib/DBIO/ResultSet.pm view on Meta::CPAN
=item Return Value: $underlying_storage_rv
=back
Deletes the rows matching this resultset in a single query. Note that this
will not run any delete triggers, nor will it alter the
L<in_storage|DBIO::Row/in_storage> status of any result object instances
derived from this resultset (this includes the contents of the
L<resultset cache|/set_cache> if any). See L</delete_all> if you need to
execute any on-delete triggers or cascades defined either by you or a
L<result component|DBIO::Manual::Component/WHAT IS A COMPONENT>.
The return value is a pass through of what the underlying storage backend
returned, and may vary. See L<DBI/execute> for the most common case.
=head2 delete_all
=over 4
=item Arguments: none
lib/DBIO/Row.pm view on Meta::CPAN
$new->insert;
# Its possible we'll have 2 relations to the same Source. We need to make
# sure we don't try to insert the same row twice else we'll violate unique
# constraints
my $rel_names_copied = {};
foreach my $rel_name ($rsrc->relationships) {
my $rel_info = $rsrc->relationship_info($rel_name);
next unless $rel_info->{attrs}{cascade_copy};
my $resolved = $rsrc->_resolve_condition(
$rel_info->{cond}, $rel_name, $new, $rel_name
);
my $copied = $rel_names_copied->{ $rel_info->{source} } ||= {};
foreach my $related ($self->search_related($rel_name)->all) {
$related->copy($resolved)
unless $copied->{$related->ID}++;
}
lib/DBIO/Row.pm view on Meta::CPAN
uniquely identifying the database row can not be constructed (see
L<significance of primary keys|DBIO::Manual::Intro/The Significance and Importance of Primary Keys>
for more details).
The object is still perfectly usable, but L</in_storage> will
now return 0 and the object must be reinserted using L</insert>
before it can be used to L</update> the row again.
If you delete an object in a class with a C<has_many> relationship, an
attempt is made to delete all the related objects as well. To turn
this behaviour off, pass C<< cascade_delete => 0 >> in the C<$attr>
hashref of the relationship, see L<DBIO::Relationship>. Any
database-level cascade or restrict will take precedence over a
DBIO-based cascading delete, since DBIO B<deletes the
main row first> and only then attempts to delete any remaining related
rows.
If you delete an object within a txn_do() (see L<DBIO::Storage/txn_do>)
and the transaction subsequently fails, the result object will remain marked as
not being in storage. If you know for a fact that the object is still in
storage (i.e. by inspecting the cause of the transaction's failure), you can
use C<< $obj->in_storage(1) >> to restore consistency between the object and
the database. This would allow a subsequent C<< $obj->delete >> to work
lib/DBIO/Row.pm view on Meta::CPAN
Inserts a new row into the database, as a copy of the original
object. If a hashref of replacement data is supplied, these will take
precedence over data in the original. Also any columns which have
the L<column info attribute|DBIO::ResultSource/add_columns>
C<< is_auto_increment => 1 >> are explicitly removed before the copy,
so that the database can insert its own autoincremented values into
the new object.
Relationships will be followed by the copy procedure B<only> if the
relationship specifies a true value for its
L<cascade_copy|DBIO::Relationship::Base> attribute. C<cascade_copy>
is set by default on C<has_many> relationships and unset on all others.
=head2 store_column
$result->store_column($col => $val);
=over
=item Arguments: $columnname, $value
lib/DBIO/Test/Schema/Artist.pm view on Meta::CPAN
__PACKAGE__->has_many(
cds_very_very_very_long_relationship_name => 'DBIO::Test::Schema::CD'
);
__PACKAGE__->has_many( twokeys => 'DBIO::Test::Schema::TwoKeys' );
__PACKAGE__->has_many( onekeys => 'DBIO::Test::Schema::OneKey' );
__PACKAGE__->has_many(
artist_undirected_maps => 'DBIO::Test::Schema::ArtistUndirectedMap',
[ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
{ cascade_copy => 0 } # this would *so* not make sense
);
__PACKAGE__->has_many(
artwork_to_artist => 'DBIO::Test::Schema::Artwork_to_Artist' => 'artist_id'
);
__PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork');
__PACKAGE__->has_many(
cds_without_genre => 'DBIO::Test::Schema::CD',
sub {
lib/DBIO/Test/Schema/ArtistUndirectedMap.pm view on Meta::CPAN
'id1' => { data_type => 'integer' },
'id2' => { data_type => 'integer' },
);
__PACKAGE__->set_primary_key(qw/id1 id2/);
__PACKAGE__->belongs_to( 'artist1', 'DBIO::Test::Schema::Artist', 'id1', { on_delete => 'RESTRICT', on_update => 'CASCADE'} );
__PACKAGE__->belongs_to( 'artist2', 'DBIO::Test::Schema::Artist', 'id2', { on_delete => undef, on_update => undef} );
__PACKAGE__->has_many(
'mapped_artists', 'DBIO::Test::Schema::Artist',
[ {'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'} ],
{ cascade_delete => 0 },
);
1;
__END__
=pod
=encoding UTF-8
lib/DBIO/Test/Schema/Link.pm view on Meta::CPAN
is_nullable => 1,
},
'title' => {
data_type => 'varchar',
size => 100,
is_nullable => 1,
},
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->has_many ( bookmarks => 'DBIO::Test::Schema::Bookmark', 'link', { cascade_delete => 0 } );
use overload '""' => sub { shift->url }, fallback=> 1;
1;
__END__
=pod
=encoding UTF-8
t/lib/MigrationsTest/BaseResult.pm view on Meta::CPAN
__PACKAGE__->table ('bogus');
__PACKAGE__->resultset_class ('MigrationsTest::BaseResultSet');
#sub add_relationship {
# my $self = shift;
# my $opts = $_[3] || {};
# if (grep { $_ eq $_[0] } qw/
# cds_90s cds_80s cds_84 artist_undirected_maps mapped_artists last_track
# /) {
# # nothing - join-dependent or non-cascadeable relationship
# }
# elsif ($opts->{is_foreign_key_constraint}) {
# $opts->{on_update} ||= 'cascade';
# }
# else {
# $opts->{cascade_rekey} = 1
# unless ref $_[2] eq 'CODE';
# }
# $self->next::method(@_[0..2], $opts);
#}
1;
t/lib/MigrationsTest/Schema/Artist.pm view on Meta::CPAN
__PACKAGE__->has_many(
cds_very_very_very_long_relationship_name => 'MigrationsTest::Schema::CD'
);
__PACKAGE__->has_many( twokeys => 'MigrationsTest::Schema::TwoKeys' );
__PACKAGE__->has_many( onekeys => 'MigrationsTest::Schema::OneKey' );
__PACKAGE__->has_many(
artist_undirected_maps => 'MigrationsTest::Schema::ArtistUndirectedMap',
[ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
{ cascade_copy => 0 } # this would *so* not make sense
);
__PACKAGE__->has_many(
artwork_to_artist => 'MigrationsTest::Schema::Artwork_to_Artist' => 'artist_id'
);
__PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork');
__PACKAGE__->has_many(
cds_without_genre => 'MigrationsTest::Schema::CD',
sub {
t/lib/MigrationsTest/Schema/ArtistUndirectedMap.pm view on Meta::CPAN
'id1' => { data_type => 'integer' },
'id2' => { data_type => 'integer' },
);
__PACKAGE__->set_primary_key(qw/id1 id2/);
__PACKAGE__->belongs_to( 'artist1', 'MigrationsTest::Schema::Artist', 'id1', { on_delete => 'RESTRICT', on_update => 'CASCADE'} );
__PACKAGE__->belongs_to( 'artist2', 'MigrationsTest::Schema::Artist', 'id2', { on_delete => undef, on_update => undef} );
__PACKAGE__->has_many(
'mapped_artists', 'MigrationsTest::Schema::Artist',
[ {'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'} ],
{ cascade_delete => 0 },
);
1;
t/lib/MigrationsTest/Schema/Link.pm view on Meta::CPAN
is_nullable => 1,
},
'title' => {
data_type => 'varchar',
size => 100,
is_nullable => 1,
},
);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->has_many ( bookmarks => 'MigrationsTest::Schema::Bookmark', 'link', { cascade_delete => 0 } );
use overload '""' => sub { shift->url }, fallback=> 1;
1;