From d7767dc889e728420afe311049ce63d29c0e5db5 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 27 Feb 2026 20:43:12 +0800 Subject: [PATCH] test: add test that DBs throw error on too long inputs --- tests/system/Database/Live/InsertTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 + ]); + } }