Skip to content

Commit c3a689e

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

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/system/Database/Live/InsertTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace CodeIgniter\Database\Live;
1515

1616
use CodeIgniter\Database\Exceptions\DatabaseException;
17+
use CodeIgniter\Database\Exceptions\DataException;
1718
use CodeIgniter\Database\Forge;
1819
use CodeIgniter\Database\RawSql;
1920
use CodeIgniter\Test\CIUnitTestCase;
@@ -275,4 +276,14 @@ public function testInsertBatchWithQueryAndRawSqlAndManualColumns(): void
275276

276277
$this->forge->dropTable('user2', true);
277278
}
279+
280+
public function testInsertWithTooLongCharactersThrowsError(): void
281+
{
282+
$this->expectException(DataException::class);
283+
284+
$this->db->table('misc')->insert([
285+
'key' => 'too_long',
286+
'value' => str_repeat('a', 401), // 'value' is VARCHAR(400), so this should throw an error
287+
]);
288+
}
278289
}

0 commit comments

Comments
 (0)