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

Bug #8820 compareDefintion() problem
Submitted: 2006-09-30 16:25 UTC
From: kuu at pochta dot ru Assigned: ifeghali
Status: Closed Package: MDB2_Schema (version 0.6.0)
PHP Version: 5.1.1 OS: win32
Roadmaps: (Not assigned)    
Comments Add Comment Add patch

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:
Solve the problem : 35 + 15 = ?

 [2006-09-30 16:25 UTC] kuu at pochta dot ru (Victor Socolov)
Description: ------------ I am saving database structure to file and just than i am trying to restore database from that file. MDB2_Scheme is trying to update non-changing id field. MDB2 and MDB2_Driver_Mysql versions are last. Test script: --------------- 1. Saving db structure. // Db::$db is MDB2 object. $schema = &MDB2_Schema::factory( Db::$db ); $dbDef = $schema->getDefinitionFromDatabase(); $schema->dumpDatabase( $dbDef, array( 'output_mode'=>'file', 'output'=>'config/db.xml' ), MDB2_SCHEMA_DUMP_STRUCTURE ); 2. Updating database schema without changing db.xml. $schema = &MDB2_Schema::factory( Db::$db ); $dbCur = $schema->getDefinitionFromDatabase(); if (file_exists('config/db.xml')) { $dbNew = $schema->parseDatabaseDefinitionFile( 'config/db.xml' ); } echo $schema->updateDatabase( $dbNew, $dbCur )->getDebugInfo(); 3. Error is in MDB2_Driver_Mysql, line 790: if ($previous_default !== $default) { $change['default'] = true; } $previous_default is int and $previous is string. To fix it I replaced '!==' with '!='. Expected result: ---------------- No changes. Actual result: -------------- Error: _doQuery: [Error message: Could not execute statement] [Last query: ALTER TABLE subscribers CHANGE id id INT NOT NULL AUTO_INCREMENT PRIMARY KEY] [Native code: 1068] [Native message: Multiple primary key defined]


 [2006-10-27 01:11 UTC] ifeghali (Igor Feghali)
please could you paste the SQL dump of both databases you are comparing ?
 [2006-10-28 04:42 UTC] ifeghali (Igor Feghali)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Parsed "default" was being assigned to strings, although that same key contains an integer (for autoincrement fields) when dumping definition directly from database. This was fixed in MDB2_Schema_Validate::validateField() which now casts "default" content to int when necessary.