[CDBI] Class::DBI internal column swapping wierdness ?

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

From: "Richard.Foley
Subject: [CDBI] Class::DBI internal column swapping wierdness ?
Date: 14:29 on 29 Sep 2005
I have some very wierd behaviour going on using Class::DBI.  Columns
appear to be being swapped internally, which is seriously screwing our
application up.  Now I may be missing something obvious here, of course,
but here is the basic scenario:

Here's the stripped down package:

 package Att::Task;
 use strict;
 use base qw(Att::Dbi);

 __PACKAGE__->table  ('task');
 __PACKAGE__->columns(Primary    => qw(name));
 __PACKAGE__->columns(Essential    => qw(
     created created_by modified modified_by 
     title application stage seq enabled shared freetext
 ));

 __PACKAGE__->has_a(application  =>     qw(Att::Application));
 __PACKAGE__->has_a(stage        =>     qw(Att::Stage));
 __PACKAGE__->has_a(enabled      =>     qw(Att::EnabledDisabled));
 __PACKAGE__->has_a(shared  =>  qw(Att::YesNo));

 1

The relevant lines are shared (YesNo) and enabled(EnabledDisabled).  We
can take a look in the database to see what's in the relevant tables:


 mysql> SELECT name FROM enableddisabled;
 +----------+
 | name     |
 +----------+
 | DISABLED |
 | ENABLED  |
 +----------+

 mysql> SELECT name FROM yesno;
 +------+
 | name |
 +------+
 | NO   |
 | YES  |
 +------+


Just to be pedantic here's the database constraint definitions for the
relevant columns:

  CONSTRAINT `task_ibfk_2` FOREIGN KEY (`ENABLED`) REFERENCES
`enableddisabled` (`NAME`),
  CONSTRAINT `task_ibfk_5` FOREIGN KEY (`SHARED`) REFERENCES `yesno`
(`NAME`)

Pretty simple stuff so far.  Now let's take a look at a record from the
database.


 mysql> SELECT name, enabled, shared FROM task WHERE name LIKE
'thenew%';
 +--------------------------+---------+--------+
 | name                     | enabled | shared |
 +--------------------------+---------+--------+
 | thenewdeliverychec_02397 | ENABLED | YES    |
 +--------------------------+---------+--------+

As expected, enabled=ENABLED and shared=YES.  Now, take a look at what
Class::DBI returns:

Att::Task thenewdeliverychec_02397         $VAR1 = bless( {
    'stage' => bless( {
                     'name' => '2005-09-13 14:08:13'
                   }, 'Att::Stage' ),
    'name' => 'thenewdeliverychec_02397',
    'application' => bless( {
                           'name' => 'att'
                         }, 'Att::Application' ),
    'freetext' => 'Check what was delivered changed to analysis - ppt
pptcomp',
    'modified' => '0000000000analysis_00504',
    'created' => 'The new delivery check',
    'shared' => bless( {
                      'name' => 'ENABLED'
                    }, 'Att::YesNo' ),
    'modified_by' => '1',
    'title' => '2005-09-13 14:08:13',
    'seq' => bless( {
                   'id' => 'att'
                 }, 'Att::Sequence' ),
    'created_by' => 'pptcomp_25143',
    'enabled' => bless( {
                       'name' => 'YES'
                     }, 'Att::EnabledDisabled' )
}, 'Att::Task' );

All of a sudden, enabled=YES and shared=ENABLED!!!

How the hell did that happen...?!  If anyone has any bright ideas here,
before I pull my remaining hair out, I'd appreciate it.  TIA.

        -- 
        Ciao
Richard Foley
Ciao - shorter than aufwiedersehen





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

[CDBI] Class::DBI internal column swapping wierdness ?
"Richard.Foley 14:29 on 29 Sep 2005

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