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

Bug #8415 field definition 'notnull' always false
Submitted: 2006-08-10 20:32 UTC
From: noodle Assigned: lsmith
Status: Closed Package: MDB2_Driver_mysql (version 1.2.0)
PHP Version: 4.4.2 OS: W2K
Roadmaps: (Not assigned)    

 [2006-08-10 20:32 UTC] noodle (Emmanuel)
Description: ------------ Dears, I've tried to dump a mysql(4) database into xml File using MDB2_Schema. XML schema done, all 'notnull' definitions were at 'false' value. mdb2/driver/reverse/mysql.php getTableFieldDefinition return always nonull at 'false' lines 100-103 : $notnull = false; if (!empty($column['null']) && $column['null'] != 'YES') { $notnull = true; } possible correction ? : $notnull = true; if (!empty($column['null']) && $column['null'] == 'YES') { $notnull = false; } Test script: --------------- CREATE TABLE table1 ( field1 int(11) NOT NULL ) SHOW COLUMNS FROM table1 LIKE 'field1' NULL field has null value CREATE TABLE table2 ( field2 int(11) ) SHOW COLUMNS FROM table2 LIKE 'field2' NULL field2 has 'YES' value <?php require_once 'MDB2/Schema.php'; $cfg['dsn'] = array( 'phptype' => 'mysql', 'username' => 'username', 'password' => 'password', 'hostspec' => 'localhost', 'database' => 'database', ); $schema =& MDB2_Schema::factory($cfg['dsn']); $dump_config = array( 'output_mode' => 'file', 'output' => 'dump.xml' ); $schema->getDefinitionFromDatabase());echo '</pre>'; $definition = $schema->getDefinitionFromDatabase(); $operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_ALL); ?> Expected result: ---------------- dump.xml : <table> <name>table1</name> <declaration> <field> <name>field1</name> ... <notnull>true</notnull> ... <table> <name>table2</name> <declaration> <field> <name>field2</name> ... <notnull>false</notnull> ... Actual result: -------------- <table> <name>table1</name> <declaration> <field> <name>field1</name> ... <notnull>false</notnull> ... <table> <name>table2</name> <declaration> <field> <name>field2</name> ... <notnull>false</notnull> ...


 [2006-08-11 08:02 UTC] lsmith (Lukas Smith)
The output looks perfectly fine when I test it on MySQL5 and PHP5. Could you give me the exact version of MySQL running? and you dump the $columns variable for both your test tables? $columns = $db->queryAll($query, null, MDB2_FETCHMODE_ASSOC); var_dump($columns);
 [2006-08-11 08:40 UTC] noodle
i'm at office, i will produce additional tests script (queryAll columns, var_dump ...) at 15:00 UTC my mysql server version is : 4.1.18 i've tried SHOW COLUMNS with Mysql5 and retrieve 'NO' for fields NOT NULL, 'YES' otherwise. Mysql4.1.18 return null and 'YES'
 [2006-08-11 13:39 UTC] lsmith (Lukas Smith)
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. I ran tests on mysql 4.1.21 to confirm the issue is fixed.