From 5d39c18817b82b1b29e31f2c42f5f9bc5b9d893e Mon Sep 17 00:00:00 2001 From: Mark Bingham Date: Thu, 19 Mar 2026 12:44:14 -0500 Subject: [PATCH 1/4] Implement typeTinyint for SQLite grammar Add typeTinyint method to handle tinyint type in SQLite. --- src/Database/Schema/Grammars/SQLiteGrammar.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Database/Schema/Grammars/SQLiteGrammar.php b/src/Database/Schema/Grammars/SQLiteGrammar.php index 4839732b..d8b3c0f3 100755 --- a/src/Database/Schema/Grammars/SQLiteGrammar.php +++ b/src/Database/Schema/Grammars/SQLiteGrammar.php @@ -156,6 +156,21 @@ public function getDefaultValue($value) return parent::getDefaultValue($value); } + + /** + * Create the column definition for a tinyint type. + * + * SQLite's column introspection returns 'tinyint' as the type_name for boolean and tinyInteger + * columns. The base grammar only has typeTinyInteger, so we need this alias to avoid + * BadMethodCallException when compileChange rebuilds a table that contains boolean columns. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTinyint(Fluent $column) + { + return 'integer'; + } /** * Create the column definition for a varchar type. From 68ca6436cffafe5c4f47a165ad92ae07de804fc6 Mon Sep 17 00:00:00 2001 From: mrkbingham Date: Thu, 19 Mar 2026 15:53:15 -0500 Subject: [PATCH 2/4] whitespace --- src/Database/Schema/Grammars/SQLiteGrammar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Schema/Grammars/SQLiteGrammar.php b/src/Database/Schema/Grammars/SQLiteGrammar.php index d8b3c0f3..65d4ceb3 100755 --- a/src/Database/Schema/Grammars/SQLiteGrammar.php +++ b/src/Database/Schema/Grammars/SQLiteGrammar.php @@ -156,7 +156,7 @@ public function getDefaultValue($value) return parent::getDefaultValue($value); } - + /** * Create the column definition for a tinyint type. * From e9afac0831da6a9731945dcc26259b860d4fdfc9 Mon Sep 17 00:00:00 2001 From: mrkbingham Date: Thu, 19 Mar 2026 15:55:40 -0500 Subject: [PATCH 3/4] adds test --- .../Grammars/SQLiteSchemaGrammarTest.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php b/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php index 02d0252a..6debd7f9 100644 --- a/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php +++ b/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php @@ -2,11 +2,13 @@ namespace Winter\Storm\Tests\Database\Schema\Grammars; +use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\SQLiteBuilder; +use Illuminate\Database\SQLiteConnection; use Winter\Storm\Database\Schema\Grammars\SQLiteGrammar; use Winter\Storm\Tests\GrammarTestCase; -class SQLiteSchemaGrammarTest extends \Winter\Storm\Tests\GrammarTestCase +class SQLiteSchemaGrammarTest extends GrammarTestCase { public function setUp(): void { @@ -60,4 +62,25 @@ public function testNullableInitialModifierAddDefaultNotNullable() $statements = $this->runBlueprint($changedBlueprint); $this->assertStringContainsString("\"name\" varchar not null default 'admin'", $statements[0]); } + + public function testTypeTinyintTypeIsValid(): void + { + $pdo = new \PDO('sqlite::memory:'); + $pdo->exec('CREATE TABLE users (is_active tinyint not null, name varchar not null)'); + + $connection = new SQLiteConnection($pdo, ':memory:', ''); + $grammar = new SQLiteGrammar($connection); + $connection->setSchemaGrammar($grammar); + + $blueprint = new Blueprint($connection, 'users'); + $blueprint->string('name')->nullable()->change(); + + // Prior to the typeTinyint fix, this would throw: + // BadMethodCallException: Method SQLiteGrammar::typeTinyint does not exist + $statements = $blueprint->toSql(); + + // compileChange maps 'tinyint' (SQLite's introspected type_name) to 'integer'. + $this->assertNotEmpty($statements); + $this->assertStringContainsString('"is_active" integer', $statements[0]); + } } From 36da16c92064f1e6ff941fc128f41254c9d962a1 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 27 May 2026 15:02:50 -0600 Subject: [PATCH 4/4] Apply suggestion from @LukeTowers --- tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php b/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php index 6debd7f9..2426caa6 100644 --- a/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php +++ b/tests/Database/Schema/Grammars/SQLiteSchemaGrammarTest.php @@ -79,7 +79,7 @@ public function testTypeTinyintTypeIsValid(): void // BadMethodCallException: Method SQLiteGrammar::typeTinyint does not exist $statements = $blueprint->toSql(); - // compileChange maps 'tinyint' (SQLite's introspected type_name) to 'integer'. + // compileChange maps 'tinyint' (SQLite's introspected type_name) to 'integer' $this->assertNotEmpty($statements); $this->assertStringContainsString('"is_active" integer', $statements[0]); }