Changeset 5116

Show
Ignore:
Timestamp:
10/21/08 20:35:42 (9 months ago)
Author:
adrive
Message:

[1.0, 1.1] Oracle DataDict? allowed to export VARCHAR2 and NUMBER bigger than allowed Oracle size. Max limit for VARCHAR2 is 4000 bytes and NUMBER precision 38. Clob used when string is bigger than 4000.

Location:
branches/1.0
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/lib/Doctrine/Connection/Oracle.php

    r5069 r5116  
    6060                          'pattern_escaping'     => true, 
    6161                          ); 
    62         $this->sql_file_delimiter = "\n/\n"; 
     62         
     63        $this->properties['sql_file_delimiter']   = "\n/\n"; 
     64        $this->properties['varchar2_max_length']  = 4000; 
     65        $this->properties['number_max_precision'] = 38; 
     66         
    6367        parent::__construct($manager, $adapter); 
    6468    } 
  • branches/1.0/lib/Doctrine/DataDict/Oracle.php

    r4768 r5116  
    6767            case 'char': 
    6868            case 'varchar': 
    69                 $length = !empty($field['length']) 
    70                     ? $field['length'] : 16777215; // TODO: $this->conn->options['default_text_field_length']; 
     69                $length = !empty($field['length']) ? $field['length'] : false; 
    7170 
    7271                $fixed  = ((isset($field['fixed']) && $field['fixed']) || $field['type'] == 'char') ? true : false; 
    73  
    74                 return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; 
     72                 
     73                if ($length && $length <= $this->conn->varchar2_max_length) { 
     74                    return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')'; 
     75                } 
    7576            case 'clob': 
    7677                return 'CLOB'; 
     
    7980            case 'integer': 
    8081            case 'int': 
    81                 if ( ! empty($field['length'])) { 
     82                if ( ! empty($field['length']) && $field['length'] <= $this->conn->number_max_precision) { 
    8283                    return 'NUMBER('.$field['length'].')'; 
    8384                } 
  • branches/1.0/tests/DataDict/OracleTestCase.php

    r3884 r5116  
    211211 
    212212        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'NUMBER(2)'); 
     213         
     214        unset($a['length']); 
     215         
     216        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'INT'); 
    213217    } 
    214218 
     
    277281        $a = array('type' => 'string'); 
    278282 
    279         $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR2(16777215)'); 
     283        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CLOB'); 
    280284    } 
    281285    public function testGetNativeDefinitionSupportsArrayType2()  
     
    283287        $a = array('type' => 'array'); 
    284288 
    285         $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR2(16777215)'); 
     289        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CLOB'); 
    286290    } 
    287291    public function testGetNativeDefinitionSupportsObjectType()  
     
    289293        $a = array('type' => 'object'); 
    290294 
    291         $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'VARCHAR2(16777215)'); 
    292     } 
     295        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CLOB'); 
     296    } 
     297    public function testGetNativeDefinitionSupportsLargerStrings() 
     298    { 
     299        $a = array('type' => 'string', 'length' => 4001); 
     300         
     301        $this->assertEqual($this->dataDict->getNativeDeclaration($a), 'CLOB'); 
     302    } 
     303     
    293304}