Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #18494 _compareIntegerDefinition() ignores length change
Submitted: 2011-05-01 16:34 UTC
From: hschletz Assigned: danielc
Status: Closed Package: MDB2 (version 2.5.0b3)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 18 - 13 = ?

 
 [2011-05-01 16:34 UTC] hschletz (Holger Schletz)
Description: ------------ Changing a column from Int4 to Int8 and vice versa using MDB2_Schema fails because _compareIntegerDefinition() does not check for length changes. The bug would also show up under different circumstances where this method is called - MDB2_Schema does not need to be involved. It's actually a bug in the MDB2_Datatype_Common class. Interesting side note: This bug did not show up for me with PostgreSQL when 'unsigned' is set to 1 because PostgreSQL does not support unsigned integers. The result does not contain the 'length' field, but always 'unsigned'. Subsequently, the column is modified and the new length taken into account, giving the expected result (for a different reason). I detected this bug with MySQL which supports unsigned integers. In that case an empty array was returned and no action was taken. The attached patch compares the 'length' fields and adds a detected change to the result. A default length of 4 is assumed if a given length field is empty. Test script: --------------- $previous = array( 'notnull' => null, 'nativetype' => 'int', 'length' => 4, 'unsigned' => 1, 'default' => 42, 'type' => integer, 'mdb2type' => 'integer', 'was' => 'foo' ) $current = array( 'type' => 'integer', 'length' => 8, 'unsigned' => 1, 'default' => 42, 'was' => 'foo', 'notnull' => null ) $result = $mdb2->datatype->_compareIntegerDefinition($current, $previous); Expected result: ---------------- array( 'length' => 8 ) Actual result: -------------- array()

Comments

 [2011-05-01 16:34 UTC] hschletz (Holger Schletz)
 [2012-10-25 07:32 UTC] danielc (Daniel Convissor)
-Status: Open +Status: Closed -Assigned To: +Assigned To: danielc
Thanks for the patch. Fixed in SVN commit 328137.