Skip to content

Commit

Permalink
fix: #19
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jun 13, 2022
1 parent dc5ee09 commit f076f83
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
PORT: ${{ job.services.mariadb.ports[3306] }}
run: composer test -- --coverage-clover clover.xml --coverage-text
- name: Push code coverage
if: matrix.php == '8.1' && github.event_name == 'push'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: $(composer global config bin-dir --absolute)/php-coveralls -x clover.xml --json_path=upload.json -v
Expand Down
2 changes: 1 addition & 1 deletion src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function findColumns($table)
$this->currentTable = $table->fullName;
try {
// Preload JSON columns by checking SQL.
$this->jsonColumns[$table->name] = array_merge($this->columnOverrides[$table->fullName] ?? [], $this->getJsonColumns($table));
$this->jsonColumns[$this->currentTable] = array_merge($this->columnOverrides[$table->fullName] ?? [], $this->getJsonColumns($table));
return parent::findColumns($table);
} catch (Exception $e) {
$previous = $e->getPrevious();
Expand Down
11 changes: 11 additions & 0 deletions tests/mariadb/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use yii\db\JsonExpression;
use yii\db\mysql\ColumnSchema;
use yii\db\TableSchema;
use yiiunit\data\ar\Storage;
use yiiunit\framework\db\AnyCaseValue;

Expand All @@ -34,6 +35,16 @@ public function testGetJsonColumns()
$this->assertSame(['data', 'defaultValue1', 'defaultValue2', 'defaultValue3', 'defaultValue4', 'defaultValue5'], $jsonColumns);
}

public function testGetJsonColumnsFullTableName(): void
{
/** @var Schema $schema */
$schema = $this->getConnection()->getSchema();
$tableSchema = $this->getConnection()->getTableSchema("yiitest." . Storage::tableName());
$this->assertInstanceOf(TableSchema::class, $tableSchema);
$jsonColumns = $schema->getJsonColumns($tableSchema);
$this->assertSame(['data', 'defaultValue1', 'defaultValue2', 'defaultValue3', 'defaultValue4', 'defaultValue5'], $jsonColumns);
}

public function testCreateColumnSchemaBuilder()
{
$this->assertInstanceOf(ColumnSchemaBuilder::class, $this->getConnection()->schema->createColumnSchemaBuilder(Schema::TYPE_PK));
Expand Down

0 comments on commit f076f83

Please sign in to comment.