Re: Warning if primary key is changed (was Re: Ignorance prevention)

[prev] [thread] [next] [Date index for 2004/10/07]

From: William McKee
Subject: Re: Warning if primary key is changed (was Re: Ignorance prevention)
Date: 22:45 on 07 Oct 2004
--a1QUDc0q7S3U7/Jg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

> I've attached my patch against v0.96 along with a patch to t/02-Film.t
> which adds a new test for this function. All tests that I can run are
> passing. Hope this patch in some form or another can get included in the
> next release.

Ooops! Ignore those patches I just sent. They were from some other work
I was doing. Here's the correct patches.


William

        -- 
        Knowmad Services Inc.
http://www.knowmad.com

--a1QUDc0q7S3U7/Jg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="DBI.pm.diff"

--- DBI.pm.orig	2004-10-07 18:24:05.000000000 -0400
+++ DBI.pm	2004-10-07 18:24:36.000000000 -0400
@@ -868,6 +868,7 @@
 
 	while (my ($column, $value) = each %$column_values) {
 		my $col = $self->find_column($column) or die "No such column: $column\n";
+		return $self->_croak("Changing the value of a primary key is unsupported.") if ($col eq $self->primary_column);
 		$self->_attribute_set($col => $value);
 
 		# $self->SUPER::set($column, $value);

--a1QUDc0q7S3U7/Jg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="02-Film.t.diff"

7c7
< 	plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 90);
---
> 	plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 92);
300a301,307
> # Changing primary key causes error
> is $blrunner->id, $blrunner->title, "Verify id";
> eval {
>   $blrunner->title('ScissorHands');
> };
> like $@, qr/Changing the value/, "Cannot change a primary key";
> 

--a1QUDc0q7S3U7/Jg--

(message missing)

Ignorance prevention
William McKee 11:59 on 16 Sep 2004

Re: Ignorance prevention
Perrin Harkins 14:12 on 16 Sep 2004

Re: Warning if primary key is changed (was Re: Ignorance prevention)
William McKee 22:45 on 07 Oct 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52