diff --git a/extensions/sphinx/Schema.php b/extensions/sphinx/Schema.php index ca05e38..5afb445 100644 --- a/extensions/sphinx/Schema.php +++ b/extensions/sphinx/Schema.php @@ -19,6 +19,23 @@ use yii\db\TableSchema; class Schema extends \yii\db\mysql\Schema { /** + * @var array mapping from physical column types (keys) to abstract column types (values) + */ + public $typeMap = [ + 'field' => self::TYPE_STRING, + 'string' => self::TYPE_STRING, + 'ordinal' => self::TYPE_STRING, + 'integer' => self::TYPE_INTEGER, + 'int' => self::TYPE_INTEGER, + 'uint' => self::TYPE_INTEGER, + 'bigint' => self::TYPE_BIGINT, + 'timestamp' => self::TYPE_TIMESTAMP, + 'bool' => self::TYPE_BOOLEAN, + 'float' => self::TYPE_FLOAT, + 'mva' => self::TYPE_STRING, + ]; + + /** * Creates a query builder for the database. * This method may be overridden by child classes to create a DBMS-specific query builder. * @return QueryBuilder query builder instance diff --git a/tests/unit/extensions/sphinx/CommandTest.php b/tests/unit/extensions/sphinx/CommandTest.php index 47fb5b9..639dea2 100644 --- a/tests/unit/extensions/sphinx/CommandTest.php +++ b/tests/unit/extensions/sphinx/CommandTest.php @@ -3,6 +3,7 @@ namespace yiiunit\extensions\sphinx; use yii\db\DataReader; +use yii\db\Expression; /** * @group sphinx @@ -128,12 +129,34 @@ class CommandTest extends SphinxTestCase $command = $db->createCommand()->update( 'yii2_test_rt_index', [ - 'title' => 'Test title', - 'content' => 'Test content', 'type_id' => $newTypeId, ], 'id = 1' ); $this->assertEquals(1, $command->execute(), 'Unable to execute update!'); + + list($row) = $db->createCommand('SELECT * FROM yii2_test_rt_index')->queryAll(); + $this->assertEquals($newTypeId, $row['type_id'], 'Unable to update attribute value!'); + } + + /** + * @depends testInsert + */ + public function testDelete() + { + $db = $this->getConnection(); + + $db->createCommand()->insert('yii2_test_rt_index', [ + 'title' => 'Test title', + 'content' => 'Test content', + 'type_id' => 2, + 'id' => 1, + ])->execute(); + + $command = $db->createCommand()->delete('yii2_test_rt_index', 'id = 1'); + $this->assertEquals(1, $command->execute(), 'Unable to execute delete!'); + + $rows = $db->createCommand('SELECT * FROM yii2_test_rt_index')->queryAll(); + $this->assertEquals(0, count($rows), 'Unable to delete record!'); } } \ No newline at end of file