Browse Source

add oracle support (need tested)

tags/2.0.8
Matvey Vasenin 9 years ago
parent
commit
a8ec3ebe14
  1. 23
      framework/db/oci/QueryBuilder.php
  2. 27
      tests/framework/db/oci/OracleQueryBuilderTest.php

23
framework/db/oci/QueryBuilder.php

@ -257,4 +257,27 @@ EOD;
return 'INSERT ALL ' . $tableAndColumns . implode($tableAndColumns, $values) . ' SELECT 1 FROM SYS.DUAL';
}
/**
* Builds a SQL command for adding comment to column
*
* @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
* @param string $column the name of the column to be commented. The column name will be properly quoted by the method.
* @return $this the command object itself
*/
public function dropCommentFromColumn($table, $column)
{
return 'COMMENT ON COLUMN ' . $this->db->quoteTableName($table) . '.' . $this->db->quoteColumnName($column) . " IS ' '";
}
/**
* Builds a SQL command for adding comment to table
*
* @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
* @return $this the command object itself
*/
public function dropCommentFromTable($table)
{
return 'COMMENT ON TABLE ' . $this->db->quoteTableName($table) . " IS ' '";
}
}

27
tests/framework/db/oci/OracleQueryBuilderTest.php

@ -82,6 +82,33 @@ class OracleQueryBuilderTest extends QueryBuilderTest
[Schema::TYPE_MONEY . ' CHECK (value > 0.0)', $this->money()->check('value > 0.0'), 'NUMBER(19,4) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . '(16,2) CHECK (value > 0.0)', $this->money(16, 2)->check('value > 0.0'), 'NUMBER(16,2) CHECK (value > 0.0)'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull(), 'NUMBER(19,4) NOT NULL'],
[Schema::TYPE_MONEY . ' NOT NULL', $this->money()->notNull()->comment('this is money column'), 'NUMBER(19,4) NOT NULL'],
];
}
public function testCommentColumn()
{
$qb = $this->getQueryBuilder();
$expected = "COMMENT ON COLUMN \"comment\".\"text\" IS 'This is my column.'";
$sql = $qb->addCommentOnColumn('comment', 'text', 'This is my column.');
$this->assertEquals($expected, $sql);
$expected = "COMMENT ON COLUMN \"comment\".\"text\" IS ' '";
$sql = $qb->dropCommentFromColumn('comment', 'text');
$this->assertEquals($expected, $sql);
}
public function testCommentTable()
{
$qb = $this->getQueryBuilder();
$expected = "COMMENT ON TABLE \"comment\" IS 'This is my table.'";
$sql = $qb->addCommentOnTable('comment', 'This is my table.');
$this->assertEquals($expected, $sql);
$expected = "COMMENT ON TABLE \"comment\" IS ' '";
$sql = $qb->dropCommentFromTable('comment');
$this->assertEquals($expected, $sql);
}
}

Loading…
Cancel
Save