Changeset 898

Show
Ignore:
Timestamp:
09/11/07 16:39:14 (1 year ago)
Author:
mikey
Message:

made table type optional

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseMySQLQueryBuilder.php

    r655 r898  
    232232                $query .= ' DEFAULT NULL'; 
    233233            } else { 
    234                 if ($column->isNullable() == false) { 
     234                if ($column->isNullable() === false) { 
    235235                    $query .= ' NOT NULL'; 
    236236                } 
     
    242242             
    243243            if ($column->isPrimaryKey() == true) { 
    244                 if ($this->isNumericColumn($column->getType()) == true) { 
     244                if ($this->isNumericColumn($column->getType()) === true) { 
    245245                    $query .= ' AUTO_INCREMENT'; 
    246246                } 
     
    264264        } 
    265265         
    266         $query .= "\n) ENGINE = " . $tableDescription->getType(); 
    267         if ($tableDescription->hasCharacterSet() == true) { 
     266        $query .= "\n)"; 
     267        if ($tableDescription->hasType() === true) { 
     268            $query .= ' ENGINE = ' . $tableDescription->getType(); 
     269        } 
     270         
     271        if ($tableDescription->hasCharacterSet() === true) { 
    268272            $query .= ' CHARACTER SET ' . $tableDescription->getCharacterSet(); 
    269273        } 
    270274         
    271         if ($tableDescription->hasCollation() == true) { 
     275        if ($tableDescription->hasCollation() === true) { 
    272276            $query .= ' COLLATE ' . $tableDescription->getCollation(); 
    273277        } 
    274278         
    275         if ($tableDescription->hasComment() == true) { 
     279        if ($tableDescription->hasComment() === true) { 
    276280            $query .= " COMMENT = '" . $tableDescription->getComment() . "'"; 
    277281        } 
  • trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableDescription.php

    r482 r898  
    2929     * @var  string 
    3030     */ 
    31     protected $type             = ''
     31    protected $type
    3232    /** 
    3333     * character set of the table 
     
    9595    { 
    9696        $this->type = $type; 
     97    } 
     98 
     99    /** 
     100     * check whether the table has a type 
     101     * 
     102     * @return  bool 
     103     */ 
     104    public function hasType() 
     105    { 
     106        return (null != $this->type); 
    97107    } 
    98108 
  • trunk/src/test/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableDescriptionTestCase.php

    r482 r898  
    4646    public function testType() 
    4747    { 
    48         $this->assertEqual($this->tableDescription->getType(), ''); 
     48        $this->assertNull($this->tableDescription->getType()); 
     49        $this->assertFalse($this->tableDescription->hasType()); 
    4950        $this->tableDescription->setType('foo'); 
    5051        $this->assertEqual($this->tableDescription->getType(), 'foo'); 
     52        $this->assertTrue($this->tableDescription->hasType()); 
    5153    } 
    5254