MySQL STRICT_TRANS_TABLES mode and truncated text values

I just upgraded Apache, PHP and MySQL to their current versions on my development system. After that a unit test of one of my PHP classes failed on inserting a row in a MySQL table. The test inserts text with a greater length than the maximum column length of a VARCHAR column.

This test fails because the new server runs with STRICT_TRANS_TABLES mode. It means that a inserted value must be equal to the stored value or the statement fails. Without the mode setting the inserted value is truncated to the column’s maximum length.

Published on 20 april 2008.

Leave a response

This is where you can leave your response. All fields are required but the e-mail address will not be published.