add sqllite dummy

This commit is contained in:
Matvey Vasenin
2015-08-17 14:44:53 +03:00
parent c0c380e730
commit afda00d434
5 changed files with 125 additions and 1 deletions

View File

@@ -110,7 +110,7 @@ class ColumnSchemaBuilder extends Object
/** /**
* Specify the comment for the column. * Specify the comment for the column.
* @param $comment the comment * @param string $comment the comment
* @return $this * @return $this
*/ */
public function comment($comment) public function comment($comment)

View File

@@ -0,0 +1,40 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\db\sqlite;
use yii\base\NotSupportedException;
use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
/**
* ColumnSchemaBuilder is the schema builder for Postgres databases.
*
* @author Vasenin Matvey <vaseninm@gmail.com>
* @since 2.0.6
*/
class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
{
/**
* Specify the comment for the column.
* @param string $comment the comment
* @return $this
* @throws NotSupportedException this is not supported by SQLite
*/
public function comment($comment)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
/**
* @inheritdoc
*/
protected function buildCommentString()
{
return '';
}
}

View File

@@ -275,6 +275,58 @@ class QueryBuilder extends \yii\db\QueryBuilder
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.'); throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
} }
/**
* 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.
* @param string $comment the text of the comment to be added. The comment will be properly quoted by the method.
* @return $this the command object itself
* @throws NotSupportedException this is not supported by SQLite
*/
public function addCommentOnColumn($table, $column, $comment)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
/**
* 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.
* @param string $comment the text of the comment to be added. The comment will be properly quoted by the method.
* @return $this the command object itself
* @throws NotSupportedException this is not supported by SQLite
*/
public function addCommentOnTable($table, $comment)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
/**
* 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
* @throws NotSupportedException this is not supported by SQLite
*/
public function dropCommentFromColumn($table, $column)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
/**
* 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
* @throws NotSupportedException this is not supported by SQLite
*/
public function dropCommentFromTable($table)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
/** /**
* @inheritdoc * @inheritdoc
*/ */

View File

@@ -91,6 +91,14 @@ class Schema extends \yii\db\Schema
return new QueryBuilder($this->db); return new QueryBuilder($this->db);
} }
/**
* @inheritdoc
*/
public function createColumnSchemaBuilder($type, $length = null)
{
return new ColumnSchemaBuilder($type, $length);
}
/** /**
* Returns all table names in the database. * Returns all table names in the database.
* @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.

View File

@@ -87,6 +87,30 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
parent::testAddDropPrimaryKey(); parent::testAddDropPrimaryKey();
} }
public function testCommentOnColumnSchemaBuilder()
{
$this->setExpectedException('yii\base\NotSupportedException');
$this->string()->comment('comment');
}
public function testCommentColumn()
{
$qb = $this->getQueryBuilder();
$this->setExpectedException('yii\base\NotSupportedException');
$qb->addCommentOnColumn('comment', 'text', 'This is my column.');
$qb->dropCommentFromColumn('comment', 'text');
}
public function testCommentTable()
{
$qb = $this->getQueryBuilder();
$this->setExpectedException('yii\base\NotSupportedException');
$qb->addCommentOnTable('comment', 'This is my table.');
$qb->dropCommentFromTable('comment');
}
public function testBatchInsert() public function testBatchInsert()
{ {
$db = $this->getConnection(); $db = $this->getConnection();