Re: Order of before_delete trigger in docs

[prev] [thread] [next] [Date index for 2005/06/27]

From: Marius Feraru
Subject: Re: Order of before_delete trigger in docs
Date: 12:35 on 27 Jun 2005
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--185205259-104550171-1119875737=:26128
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


( sorry for the delay, 'been sleeping %-| )

On Jun 27, at 08:47 (+0100), 'Tony Bowden' wrote:
> On Mon, Jun 27, 2005 at 10:44:32AM +0300, Marius Feraru wrote:
>> Remember Tony that Bill is using Class::DBI::Loader magic ;-)
> I don't use CDBI::Loader so I dont' know what it does.

Neither do I, just made an (somehow) educated guess ;-)

>> CDBI::Loader seems to be automagically creating all possible
>> relationships between his tables, getting to where I stated in my
>> previous message.
>
> I don't understand this.

I don't understand what you don't understand, so, for our brains' sake, 
I just baked a "good morning" test script to demonstrate this flaw.
Attached.

I made a simple example using two classes: "Actors" and "Roles". Let's
say each Actor may have multiple (has_many) Roles and a Role is
occupied by a single (has_a) Actor. Now, presuming that each Role must
be occupied, we have to disable removing Actors that have some
Roles attributed to themselves. Hence, using a before_delete trigger on
Actors should do the trick, but... run the test script :)

a) ./cdbi-test.pl
  ^ should work as expected
b) ./cdbi-test.pl 1
  ^ fails, as triggers chain (not so bad) in reverse order (definitely
    bad).

hopefully now it's all clear.
- -- 
Marius Feraru                                   http://www.altblue.com/
"It isn't easy being the parent of a three-years-old.
  However, it's a pretty small price to pay for having somebody
  around the house who understands computers."
-----BEGIN PGP SIGNATURE-----

iD8DBQFCv/Kdn0ZKufYp8iURAsogAJ9E8ZPl1GZa5mxWrxhpXFSYWwcKywCbBDVk
9seNXrBVOeZ4OLpN3LHDcgU=
=0Ijs
-----END PGP SIGNATURE-----
--185205259-104550171-1119875737=:26128
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=cdbi-test.pl
Content-Transfer-Encoding: BASE64
Content-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bnQgJ1JlbW92aW5nIEFjdG9yICcsICRhY3Rvci0+
bmFtZTsNCgkkYWN0b3ItPmRlbGV0ZTsNCn0NCmR1bXBpdCAnQUZURVIgREVM
RVRFIEFDVE9SIChubyByb2xlcyk6JzsNCnsNCglteSAkYWN0b3IgPSBBY3Rv
cnMtPnJldHJpZXZlKDEpOw0KCXByaW50ICdSZW1vdmluZyBBY3RvciAnLCAk
YWN0b3ItPm5hbWU7DQoJZXZhbCB7ICRhY3Rvci0+ZGVsZXRlIH07DQoJd2Fy
biAkQCBpZiAkQDsNCn0NCmR1bXBpdCAnQUZURVIgREVMRVRFIEFDVE9SICho
YXZpbmcgcm9sZXMpOic7DQo=

--185205259-104550171-1119875737=:26128--

(message missing)

Order of before_delete trigger in docs
Bill Moseley 17:32 on 26 Jun 2005

Re: Order of before_delete trigger in docs
Tony Bowden 18:56 on 26 Jun 2005

Re: Order of before_delete trigger in docs
Marius Feraru 01:34 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Bill Moseley 07:22 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Tony Bowden 07:35 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Marius Feraru 07:44 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Tony Bowden 07:47 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Marius Feraru 07:54 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Marius Feraru 12:35 on 27 Jun 2005

Re: Order of before_delete trigger in docs
William Ross 14:03 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Bill Moseley 15:11 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Charles Bailey 16:23 on 27 Jun 2005

Re: Order of before_delete trigger in docs
William Ross 19:37 on 27 Jun 2005

Re: Order of before_delete trigger in docs
Tony Bowden 19:54 on 27 Jun 2005

Re: Order of before_delete trigger in docs
William Ross 20:52 on 27 Jun 2005

Generated at 16:37 on 28 Jul 2005 by mariachi v0.52