Skip to content

Commit c8e89d9

Browse files
Added test case proving bug with boolean columns
1 parent 7ad2df1 commit c8e89d9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/Database/Functional/Driver/MySQL/Connection/CustomOptionsTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ public function testNamedArgumentsToConfigureInteger(): void
9494
$this->assertTrue($foo->isNullable());
9595
}
9696

97+
public function testNamedArgumentsToConfigureBoolean(): void
98+
{
99+
$schema = $this->schema('foo');
100+
$schema->boolean('bar')->defaultValue(false)->unsigned(true)->size(1);
101+
$schema->boolean('baz', nullable: true, unsigned: true, size: 1);
102+
$schema->save();
103+
104+
$this->assertInstanceOf(MySQLColumn::class, $bar = $this->fetchSchema($schema)->column('bar'));
105+
$this->assertInstanceOf(MySQLColumn::class, $baz = $this->fetchSchema($schema)->column('baz'));
106+
107+
\assert($bar instanceof MySQLColumn);
108+
\assert($baz instanceof MySQLColumn);
109+
$this->assertFalse($bar->isZerofill());
110+
$this->assertFalse($baz->isZerofill());
111+
$this->assertTrue($bar->isUnsigned());
112+
$this->assertTrue($baz->isUnsigned());
113+
114+
// Below assertion fails. We expect boolean to have a default size of 1 however we receive 4,
115+
// even when explicitly declaring the column size. Likely due to MySQLColumn::createInstance
116+
// not knowing the `userType` at this point, or that the default size should be 1. Instead, the
117+
// size is resolved as 4, default value when resolving a tinyint (DBMS specific column type).
118+
$this->assertSame(1, $bar->getSize());
119+
$this->assertSame(1, $baz->getSize());
120+
$this->assertFalse($bar->isNullable());
121+
$this->assertTrue($baz->isNullable());
122+
}
123+
97124
/**
98125
* The `text` have no the `unsigned` attribute. It will be stored in the additional attributes.
99126
*/

0 commit comments

Comments
 (0)