PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2_Schema » Bug #8820

compareDefintion() problem

Details

Submitted2006-09-30 16:25 UTC
Fromkuu at pochta dot ru
Assignedifeghali
StatusClosed
PackageMDB2_Schema
PHP Version5.1.1
OSwin32
Roadmaps(Not assigned)

Comments

[2006-09-30 16:25 UTC] kuu at pochta dot ru

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]