diff --git a/tests/system/Database/Live/InsertTest.php b/tests/system/Database/Live/InsertTest.php index 1483d660c174..9527c14fa189 100644 --- a/tests/system/Database/Live/InsertTest.php +++ b/tests/system/Database/Live/InsertTest.php @@ -275,4 +275,18 @@ public function testInsertBatchWithQueryAndRawSqlAndManualColumns(): void $this->forge->dropTable('user2', true); } + + public function testInsertWithTooLongCharactersThrowsError(): void + { + if ($this->db->DBDriver === 'SQLite3') { + $this->markTestSkipped('SQLite does not enforce VARCHAR length constraints.'); + } + + $this->expectException(DatabaseException::class); + + $this->db->table('misc')->insert([ + 'key' => 'too_long', + 'value' => str_repeat('a', 401), // 'value' is VARCHAR(400), so this should throw an error + ]); + } }