[CDBI] Wierd internal column swapping ?

[prev] [thread] [next] [Date index for 2005/09/29]

From: "Richard.Foley
Subject: [CDBI] Wierd internal column swapping ?
Date: 14:24 on 29 Sep 2005
--===============0136093710==
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<font style=3D"font-family: arial,helvetica,sans-serif;" size=3D"2"><p>I
have some very wierd behaviour going on using Class::DBI.=A0 Columns
appear to be being swapped internally, which is seriously screwing our
application up.=A0 Now I may be missing something obvious here, of course,
but here is the basic scenario:</p><p>Here's=A0the stripped down
package:</p><p>=A0package Att::Task;<br />=A0use strict;<br />=A0use base
qw(Att::Dbi);</p><p>=A0__PACKAGE__-&gt;table=A0 ('task');<br
/>=A0__PACKAGE__-&gt;columns(Primary=A0=A0=A0 =3D&gt; qw(name));<br
/>=A0__PACKAGE__-&gt;columns(Essential=A0=A0=A0 =3D&gt; qw(<br />=A0=A0=A0=
=A0 created
created_by modified modified_by <br />=A0=A0=A0=A0 title application stage =
seq
enabled shared freetext<br
/>=A0));</p><p>=A0__PACKAGE__-&gt;has_a(application=A0 =3D&gt;=A0=A0=A0
=A0qw(Att::Application));<br />=A0__PACKAGE__-&gt;has_a(stage=A0=A0=A0=A0=
=A0=A0=A0
=3D&gt;=A0=A0=A0 =A0qw(Att::Stage));<br />=A0__PACKAGE__-&gt;has_a(enabled=
=A0=A0=A0=A0=A0
=3D&gt;=A0=A0=A0 =A0qw(Att::EnabledDisabled));<br />=A0__PACKAGE__-&gt;has_=
a(shared
=A0=3D&gt; =A0qw(Att::YesNo));</p><p>=A01</p><p>The relevant lines are shar=
ed
(YesNo) and enabled(EnabledDisabled).=A0 We can take a look in the
database to see what's in the relevant tables:</p><p><br />=A0mysql&gt;
SELECT name FROM enableddisabled;<br />=A0+----------+<br />=A0| name=A0=A0=
=A0=A0
|<br />=A0+----------+<br />=A0| DISABLED |<br />=A0| ENABLED=A0 |<br
/>=A0+----------+</p><p>=A0mysql&gt; SELECT name FROM yesno;<br
/>=A0+------+<br />=A0| name |<br />=A0+------+<br />=A0| NO=A0=A0 |<br />=
=A0| YES=A0
|<br />=A0+------+</p><p><br />Just to be pedantic here's the database
constraint definitions for the relevant columns:</p><p>=A0 CONSTRAINT
`task_ibfk_2` FOREIGN KEY (`ENABLED`) REFERENCES `enableddisabled`
(`NAME`),<br />=A0 CONSTRAINT `task_ibfk_5` FOREIGN KEY (`SHARED`)
REFERENCES `yesno` (`NAME`)<br /><br />Pretty simple stuff so far.=A0 Now
let's take a look at a record from the database.</p><p><br />=A0mysql&gt;
SELECT name, enabled, shared FROM task WHERE name LIKE 'thenew%';<br
/>=A0+--------------------------+---------+--------+<br />=A0|
name=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | enabled =
| shared |<br
/>=A0+--------------------------+---------+--------+<br />=A0|
thenewdeliverychec_02397 | ENABLED | YES=A0=A0=A0 |<br
/>=A0+--------------------------+---------+--------+</p><p>As expected,
enabled=3DENABLED and shared=3DYES.=A0 Now, take a look at what Class::DBI
returns:</p><p>Att::Task thenewdeliverychec_02397=A0=A0=A0=A0=A0=A0=A0=A0 $=
VAR1 =3D bless(
{<br />=A0=A0=A0 'stage' =3D&gt; bless( {<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 'name' =3D&gt;
'2005-09-13 14:08:13'<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 }, 'Att::Stage' ),<br
/>=A0=A0=A0 'name' =3D&gt; 'thenewdeliverychec_02397',<br />=A0=A0=A0 'appl=
ication'
=3D&gt; bless( {<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0 'name' =3D&gt; 'att'<br
/>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =
}, 'Att::Application' ),<br />=A0=A0=A0 'freetext'
=3D&gt; 'Check what was delivered changed to analysis - ppt pptcomp',<br
/>=A0=A0=A0 'modified' =3D&gt; '0000000000analysis_00504',<br />=A0=A0=A0 '=
created'
=3D&gt; 'The new delivery check',<br />=A0=A0=A0 'shared' =3D&gt; bless( {<=
br
/>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 'name' =
=3D&gt; 'ENABLED'<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0
}, 'Att::YesNo' ),<br />=A0=A0=A0 'modified_by' =3D&gt; '1',<br />=A0=A0=A0=
 'title'
=3D&gt; '2005-09-13 14:08:13',<br />=A0=A0=A0 'seq' =3D&gt; bless( {<br
/>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 'id' =3D&gt; 'att'=
<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 },
'Att::Sequence' ),<br />=A0=A0=A0 'created_by' =3D&gt; 'pptcomp_25143',<br =
/>=A0=A0=A0
'enabled' =3D&gt; bless( {<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 'name' =3D&gt;
'YES'<br />=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 }, =
'Att::EnabledDisabled' )<br />},
'Att::Task' );<br /><br />All of a sudden, enabled=3DYES and
shared=3DENABLED!!!</p><p>How the hell did that happen...?!=A0 If anyone ha=
s
any bright ideas here, before I pull my remaining hair out, I'd
appreciate it.<br /><br />-- <br />Ciao<br />Richard Foley<br />Ciao -
shorter than aufwiedersehen</p><p /></font>




--===============0136093710==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

--===============0136093710==--

[CDBI] Wierd internal column swapping ?
"Richard.Foley 14:24 on 29 Sep 2005

Re: [CDBI] Wierd internal column swapping ?
Michael Peters 14:30 on 29 Sep 2005

Generated at 15:06 on 02 Oct 2005 by mariachi v0.52