Changeset 5123

Show
Ignore:
Timestamp:
10/21/08 23:07:34 (9 months ago)
Author:
jwage
Message:

[1.0, 1.1] fixes #1006

Location:
branches
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/DataDict/Mysql.php

    r4858 r5123  
    251251        } else { 
    252252            $length = strtok('(), '); 
    253             $decimal = strtok('(), '); 
     253            $decimal = strtok('(), ') ? strtok('(), '):null; 
    254254        } 
    255255        $type = array(); 
     
    261261 
    262262        $values = null; 
     263        $scale = null; 
    263264 
    264265        switch ($dbType) { 
     
    365366            case 'unknown': 
    366367            case 'decimal': 
     368                if ($decimal !== null) { 
     369                    $scale = $decimal; 
     370                } 
    367371            case 'numeric': 
    368372                $type[] = 'decimal'; 
     
    404408 
    405409        $length = ((int) $length == 0) ? null : (int) $length; 
    406  
    407         if ($values === null) { 
    408             return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 
    409         } else { 
    410             return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed, 'values' => $values); 
    411         } 
     410        $def =  array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 
     411        if ($values !== null) { 
     412            $def['values'] = $values; 
     413        } 
     414        if ($scale !== null) { 
     415            $def['scale'] = $scale; 
     416        } 
     417        return $def; 
    412418    } 
    413419 
  • branches/1.0/lib/Doctrine/Export/Schema.php

    r4196 r5123  
    7373            // Fix explicit length in schema, concat it to type in this format: type(length) 
    7474            foreach ($data['columns'] AS $name => $column) { 
    75                 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 
    76                 unset($data['columns'][$name]['length']); 
    77  
     75                if (isset($column['length']) && $column['length'] && isset($column['scale']) && $column['scale']) { 
     76                    $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ', ' . $column['scale'] . ')'; 
     77                    unset($data['columns'][$name]['length'], $data['columns'][$name]['scale']); 
     78                } else { 
     79                    $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 
     80                    unset($data['columns'][$name]['length']); 
     81                } 
    7882                // Strip out schema information which is not necessary to be dumped to the yaml schema file 
    7983                foreach ($remove as $value) { 
  • branches/1.0/lib/Doctrine/Import/Mysql.php

    r5026 r5123  
    168168                          'autoincrement' => (bool) (strpos($val['extra'], 'auto_increment') !== false), 
    169169                          ); 
     170            if (isset($decl['scale'])) { 
     171                $description['scale'] = $decl['scale']; 
     172            } 
    170173            $columns[$val['field']] = $description; 
    171174        } 
  • branches/1.0/lib/Doctrine/Import/Schema.php

    r5118 r5123  
    378378                    if (isset($e[0]) && isset($e[1])) { 
    379379                        $colDesc['type'] = $e[0]; 
    380                         $colDesc['length'] = substr($e[1], 0, strlen($e[1]) - 1); 
     380                        $value = substr($e[1], 0, strlen($e[1]) - 1); 
     381                        $e = explode(',', $value); 
     382                        $colDesc['length'] = $e[0]; 
     383                        if (isset($e[1]) && $e[1]) { 
     384                            $colDesc['scale'] = $e[1]; 
     385                        } 
    381386                    } else { 
    382387                        $colDesc['type'] = isset($field['type']) ? (string) $field['type']:null; 
  • branches/1.1/lib/Doctrine/DataDict/Mysql.php

    r4858 r5123  
    251251        } else { 
    252252            $length = strtok('(), '); 
    253             $decimal = strtok('(), '); 
     253            $decimal = strtok('(), ') ? strtok('(), '):null; 
    254254        } 
    255255        $type = array(); 
     
    261261 
    262262        $values = null; 
     263        $scale = null; 
    263264 
    264265        switch ($dbType) { 
     
    365366            case 'unknown': 
    366367            case 'decimal': 
     368                if ($decimal !== null) { 
     369                    $scale = $decimal; 
     370                } 
    367371            case 'numeric': 
    368372                $type[] = 'decimal'; 
     
    404408 
    405409        $length = ((int) $length == 0) ? null : (int) $length; 
    406  
    407         if ($values === null) { 
    408             return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 
    409         } else { 
    410             return array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed, 'values' => $values); 
    411         } 
     410        $def =  array('type' => $type, 'length' => $length, 'unsigned' => $unsigned, 'fixed' => $fixed); 
     411        if ($values !== null) { 
     412            $def['values'] = $values; 
     413        } 
     414        if ($scale !== null) { 
     415            $def['scale'] = $scale; 
     416        } 
     417        return $def; 
    412418    } 
    413419 
  • branches/1.1/lib/Doctrine/Export/Schema.php

    r4196 r5123  
    7373            // Fix explicit length in schema, concat it to type in this format: type(length) 
    7474            foreach ($data['columns'] AS $name => $column) { 
    75                 $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 
    76                 unset($data['columns'][$name]['length']); 
    77  
     75                if (isset($column['length']) && $column['length'] && isset($column['scale']) && $column['scale']) { 
     76                    $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ', ' . $column['scale'] . ')'; 
     77                    unset($data['columns'][$name]['length'], $data['columns'][$name]['scale']); 
     78                } else { 
     79                    $data['columns'][$name]['type'] = $column['type'] . '(' . $column['length'] . ')'; 
     80                    unset($data['columns'][$name]['length']); 
     81                } 
    7882                // Strip out schema information which is not necessary to be dumped to the yaml schema file 
    7983                foreach ($remove as $value) { 
  • branches/1.1/lib/Doctrine/Import/Mysql.php

    r5026 r5123  
    168168                          'autoincrement' => (bool) (strpos($val['extra'], 'auto_increment') !== false), 
    169169                          ); 
     170            if (isset($decl['scale'])) { 
     171                $description['scale'] = $decl['scale']; 
     172            } 
    170173            $columns[$val['field']] = $description; 
    171174        } 
  • branches/1.1/lib/Doctrine/Import/Schema.php

    r5118 r5123  
    378378                    if (isset($e[0]) && isset($e[1])) { 
    379379                        $colDesc['type'] = $e[0]; 
    380                         $colDesc['length'] = substr($e[1], 0, strlen($e[1]) - 1); 
     380                        $value = substr($e[1], 0, strlen($e[1]) - 1); 
     381                        $e = explode(',', $value); 
     382                        $colDesc['length'] = $e[0]; 
     383                        if (isset($e[1]) && $e[1]) { 
     384                            $colDesc['scale'] = $e[1]; 
     385                        } 
    381386                    } else { 
    382387                        $colDesc['type'] = isset($field['type']) ? (string) $field['type']:null;