Skip to content

Commit d7767dc

Browse files
committed
test: add test that DBs throw error on too long inputs
1 parent eb6ac9f commit d7767dc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/system/Database/Live/InsertTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,18 @@ public function testInsertBatchWithQueryAndRawSqlAndManualColumns(): void
275275

276276
$this->forge->dropTable('user2', true);
277277
}
278+
279+
public function testInsertWithTooLongCharactersThrowsError(): void
280+
{
281+
if ($this->db->DBDriver === 'SQLite3') {
282+
$this->markTestSkipped('SQLite does not enforce VARCHAR length constraints.');
283+
}
284+
285+
$this->expectException(DatabaseException::class);
286+
287+
$this->db->table('misc')->insert([
288+
'key' => 'too_long',
289+
'value' => str_repeat('a', 401), // 'value' is VARCHAR(400), so this should throw an error
290+
]);
291+
}
278292
}

0 commit comments

Comments
 (0)