Class-DBI-Frozen-301

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

      off caching if required) [gfalck]
    - We now warn about column names clashing with any inherited methods,
      not just ones defined in Class::DBI itself [Dan Thill]
    - Silence some test warnings reported by Paul Makepeace

0.94  Wed Aug 27 2003

  New Functionality
    - allow has_a() columns to hold NULL values (Dominic Mitchell)
    - cascading deletions can be turned off by passing argument to
      has_many setup: no_cascade_delete => 1 (undocumented/untested)
      [now implemented as a trigger]
    - classes and objects can be marked as read_only (experimental and
      undocumented, although tested)

  Documentation
    - no longer refer to Class::DBI::Join, which is dead
    - warn about inflating a primary key using has_a
    - rewrite of docs on transactions
    - numerous small tweaks from Jay Strauss, Alexander Karelas and Brad
      Bowman

Changes  view on Meta::CPAN


0.34  Sat Oct  6 2001
    - Don't die if a value is a reference. (Ima::DBI does this for us,
       and better in case of overloaded objects)
    - fix minor problem with mutual hasa / hasa_list referencing
    - better diagnostics if hasa_list is miscalled

0.33  Sat Sep 15 2001
    + Added create_filter(), and with it retrieve_all()
    + added docs on how to set-up many-to-many relationships
    + _cascade delete now split out to allow overriding
    + copy() and move() can now take multiple arguments to change
       (thanks to Jonathan Swartz)

0.32  Sun Sep  9 2001
    + delete() now removes any foreign elements, to avoid orphans

0.31  Sun Sep  9 2001
    + split out _column_placeholder (thanks to Jonathan Swartz)
    + added hasa() checks for orphaned rows

lib/Class/DBI/Frozen/301/Relationship/HasMany.pm  view on Meta::CPAN


sub _set_up_class_data {
	my $self = shift;
	$self->class->_extend_class_data(
		__hasa_list => $self->foreign_class => $self->args->{foreign_key});
	$self->SUPER::_set_up_class_data;
}

sub triggers {
	my $self = shift;
	return if $self->args->{no_cascade_delete};    # undocumented and untestsd!
	return (
		before_delete => sub {
			$self->foreign_class->search($self->args->{foreign_key} => shift->id)
				->delete_all;
		});
}

sub methods {
	my $self     = shift;
	my $accessor = $self->accessor;

t/10-mysql.t  view on Meta::CPAN

	ok MyStar->has_many(filmids => [ MyStarLink => 'film', 'id' ]),
		"**** Multi-map";
	my @filmid = $s1->filmids;
	ok !ref $filmid[0], "Film-id is not a reference";

	my $first = $s1->filmids->first;
	ok !ref $first, "First is not a reference";
	is $first, $filmid[0], "But it's the same as filmid[0]";
}

{    # cascades correctly
	my $lenin  = MyFilm->create({ title    => "Leningrad Cowboys Go America" });
	my $pimme  = MyStar->create({ name     => "Pimme Korhonen" });
	my $cowboy = MyStarLink->create({ film => $lenin, star => $pimme });
	$lenin->delete;
	is MyStar->search(name => 'Pimme Korhonen')->count, 1, "Pimme still exists";
	is MyStarLink->search(star => $pimme->id)->count, 0, "But in no films";
}

{
	ok MyStar->has_many(filmids_mcpk => [ MyStarLinkMCPK => 'film', 'id' ]),

t/14-might_have.t  view on Meta::CPAN

	is $bt->blurb, $info->blurb, "Blurb is the same as fetching the long way";
	ok $bt->blurb("New blurb"), "We can set the blurb";
	$bt->update;
	is $bt->blurb, $info->blurb, "Blurb has been set";

	$bt->rating(18);
	eval { $bt->update };
	is $@, '', "No problems updating when do have";
	is $bt->rating, 18, "Updated OK";

	# cascade delete?
	{
		my $blurb = Blurb->retrieve('Bad Taste');
		isa_ok $blurb => "Blurb";
		$bt->delete;
		$blurb = Blurb->retrieve('Bad Taste');
		is $blurb, undef, "Blurb has gone";
	}
		
}



( run in 1.176 second using v1.01-cache-2.11-cpan-49f99fa48dc )