Skip to content

Commit

Permalink
Merge pull request #207: fix bool typecasting in SQLite
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Oct 22, 2024
2 parents 5f3fe4f + 4d14ff3 commit da3425b
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Driver/SQLite/Schema/SQLiteColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SQLiteColumn extends AbstractColumn
'enum' => 'enum',

//Logical types
'boolean' => 'integer',
'boolean' => ['type' => 'tinyint', 'size' => 1],

//Integer types (size can always be changed with size method), longInteger has method alias
//bigInteger
Expand Down Expand Up @@ -93,7 +93,7 @@ class SQLiteColumn extends AbstractColumn
protected array $reverseMapping = [
'primary' => [['type' => 'integer', 'primaryKey' => true]],
'enum' => ['enum'],
'boolean' => ['boolean'],
'boolean' => ['boolean', ['type' => 'tinyint', 'size' => 1]],
'integer' => ['int', 'integer', 'mediumint'],
'tinyInteger' => ['tinyint'],
'smallInteger' => ['smallint'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Cycle\Database\Tests\Functional\Driver\Common\Schema;

use Cycle\Database\Tests\Functional\Driver\Common\BaseTest;

abstract class BooleanColumnTest extends BaseTest
{
public function testBooleanSchema(): void
{
$schema = $this->schema('table');

$schema->boolean('column');
$schema->save();
$this->assertSameAsInDB($schema);
}

public function testBooleanAbstractType(): void
{
$schema = $this->schema('table');

$schema->boolean('column');
$schema->save();

$column = $this->fetchSchema($schema)->column('column');

$this->assertSame('boolean', $column->getAbstractType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Cycle\Database\Tests\Functional\Driver\MySQL\Schema;

// phpcs:ignore
use Cycle\Database\Tests\Functional\Driver\Common\Schema\BooleanColumnTest as CommonClass;

/**
* @group driver
* @group driver-mysql
*/
class BooleanColumnTest extends CommonClass
{
public const DRIVER = 'mysql';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Cycle\Database\Tests\Functional\Driver\Postgres\Schema;

// phpcs:ignore
use Cycle\Database\Tests\Functional\Driver\Common\Schema\BooleanColumnTest as CommonClass;

/**
* @group driver
* @group driver-postgres
*/
final class BooleanColumnTest extends CommonClass
{
public const DRIVER = 'postgres';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Cycle\Database\Tests\Functional\Driver\SQLServer\Schema;

// phpcs:ignore
use Cycle\Database\Tests\Functional\Driver\Common\Schema\BooleanColumnTest as CommonClass;

/**
* @group driver
* @group driver-sqlserver
*/
class BooleanColumnTest extends CommonClass
{
public const DRIVER = 'sqlserver';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Cycle\Database\Tests\Functional\Driver\SQLite\Schema;

// phpcs:ignore
use Cycle\Database\Tests\Functional\Driver\Common\Schema\BooleanColumnTest as CommonClass;

/**
* @group driver
* @group driver-sqlite
*/
class BooleanColumnTest extends CommonClass
{
public const DRIVER = 'sqlite';
}

0 comments on commit da3425b

Please sign in to comment.