PEAR is archived and read-only

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

Home » Database » MDB2_Driver_mysql » Bug #6054

unsigned fields handling in reverse class

Details

Submitted2005-11-24 09:33 UTC
Fromalex at cgi-central dot net
Assignedlsmith
StatusClosed
PackageMDB2_Driver_mysql
PHP Version4.3.11
OSany
Roadmaps(Not assigned)

Comments

[2005-11-24 09:33 UTC] alex at cgi-central dot net

Description:
------------
Reverse driver seems to do not have any handling to determine unsigned fields. Code below adds this handling.

Also function name was wrong: getTableConstraintDefinition instead of getTableConstraintsDefinition in base class, this caused all kind of troubles.

Test script:
---------------
--- MDB2/Driver/Reverse/mysql.php 16 Oct 2005 09:39:50 -0000 1.34
+++ MDB2/Driver/Reverse/mysql.php 24 Nov 2005 09:31:23 -0000
@@ -93,6 +93,7 @@
}
if ($field_name == $column['field']) {
list($types, $length) = $db->datatype->mapNativeDatatype($column);
+ $unsigned = preg_match('/ unsigned/i', $column['type']);
$notnull = false;
if (array_key_exists('null', $column) && $column['null'] != 'YES') {
$notnull = true;
@@ -120,6 +121,9 @@
if ($default !== false) {
$definition[$key]['default'] = $default;
}
+ if ($unsigned) {
+ $definition[$key]['unsigned'] = 1;
+ }
if ($autoincrement !== false) {
$definition[$key]['autoincrement'] = $autoincrement;
}
@@ -201,7 +205,7 @@
}

// }}}
- // {{{ getTableConstraintDefinition()
+ // {{{ getTableConstraintsDefinition()

/**
* get the stucture of a constraint into an array
@@ -211,7 +215,7 @@
* @return mixed data array on success, a MDB2 error on failure
* @access public
*/
- function getTableConstraintDefinition($table, $index_name)
+ function getTableConstraintsDefinition($table, $index_name)
{
$db =& $this->getDBInstance();
if (PEAR::isError($db)) {
@@ -224,6 +228,7 @@
}
$definition = array();
while (is_array($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))) {
+
if (!($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE)
|| $db->options['field_case'] != CASE_LOWER
) {