svn: /pear/packages/MDB2/trunk/ MDB2/Driver/Datatype/mysql.php MDB2/Driver/Datatype/mysqli.php package_mysql.php package_mysqli.php

From: Date: Sun, 06 Mar 2011 12:11:52 +0000
Subject: svn: /pear/packages/MDB2/trunk/ MDB2/Driver/Datatype/mysql.php MDB2/Driver/Datatype/mysqli.php package_mysql.php package_mysqli.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-61352@lists.php.net to get a copy of this message
quipo Sun, 06 Mar 2011 12:11:52 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=308959 Log: fixed bug #18057: Result of getDeclaration() can have invalid syntax [hschletz] Bug: http://pear.php.net/bugs/18057 (unknown) Changed paths: U pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysql.php U pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysqli.php U pear/packages/MDB2/trunk/package_mysql.php U pear/packages/MDB2/trunk/package_mysqli.php Modified: pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysql.php =================================================================== --- pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysql.php 2011-03-06 12:09:14 UTC (rev 308958) +++ pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysql.php 2011-03-06 12:11:52 UTC (rev 308959) @@ -89,6 +89,35 @@ } // }}} + // {{{ getDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to declare + * of the given type + * + * @param string $type type to which the value should be converted to + * @param string $name name the field to be declared. + * @param string $field definition of the field + * + * @return string DBMS-specific SQL code portion that should be used to + * declare the specified field. + * @access public + */ + function getDeclaration($type, $name, $field) + { + // MySQL DDL syntax forbids combining NOT NULL with DEFAULT NULL. + // To get a default of NULL for NOT NULL columns, omit it. + if ( isset($field['notnull']) + && !empty($field['notnull']) + && array_key_exists('default', $field) // do not use isset() here! + && null === $field['default'] + ) { + unset($field['default']); + } + return parent::getDeclaration($type, $name, $field); + } + + // }}} // {{{ getTypeDeclaration() /** Modified: pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysqli.php =================================================================== --- pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysqli.php 2011-03-06 12:09:14 UTC (rev 308958) +++ pear/packages/MDB2/trunk/MDB2/Driver/Datatype/mysqli.php 2011-03-06 12:11:52 UTC (rev 308959) @@ -89,6 +89,35 @@ } // }}} + // {{{ getDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to declare + * of the given type + * + * @param string $type type to which the value should be converted to + * @param string $name name the field to be declared. + * @param string $field definition of the field + * + * @return string DBMS-specific SQL code portion that should be used to + * declare the specified field. + * @access public + */ + function getDeclaration($type, $name, $field) + { + // MySQL DDL syntax forbids combining NOT NULL with DEFAULT NULL. + // To get a default of NULL for NOT NULL columns, omit it. + if ( isset($field['notnull']) + && !empty($field['notnull']) + && array_key_exists('default', $field) // do not use isset() here! + && null === $field['default'] + ) { + unset($field['default']); + } + return parent::getDeclaration($type, $name, $field); + } + + // }}} // {{{ getTypeDeclaration() /** Modified: pear/packages/MDB2/trunk/package_mysql.php =================================================================== --- pear/packages/MDB2/trunk/package_mysql.php 2011-03-06 12:09:14 UTC (rev 308958) +++ pear/packages/MDB2/trunk/package_mysql.php 2011-03-06 12:11:52 UTC (rev 308959) @@ -6,6 +6,7 @@ $version = '1.5.0b4'; $state = 'beta'; $notes = <<<EOT +- fixed bug #18057: Result of getDeclaration() can have invalid syntax [hschletz] - request #18068: mapNativeDatatype() returns decimal places also for 'float' mdb2type note: Modified: pear/packages/MDB2/trunk/package_mysqli.php =================================================================== --- pear/packages/MDB2/trunk/package_mysqli.php 2011-03-06 12:09:14 UTC (rev 308958) +++ pear/packages/MDB2/trunk/package_mysqli.php 2011-03-06 12:11:52 UTC (rev 308959) @@ -7,6 +7,7 @@ $state = 'beta'; $notes = <<<EOT - fixed bug #17892: removed debug message [pdt256] +- fixed bug #18057: Result of getDeclaration() can have invalid syntax [hschletz] - request #18068: mapNativeDatatype() returns decimal places also for 'float' mdb2type open todo items:

« previous php.pear.cvs (#61352) next »