#375 - SQL error while creating new ticket in MySQL Strict mode
Type Defect
Status Fixed
Milestone 3.3
Version 3.2.2
Component -
Priority Normal
Severity Normal
Owner Erwin
Assigned to -
Reported 10 years ago
Updated 10 years ago
Votes 0
Related tickets
Proposed time
Worked time

I recently modified my MySQL configuration to run in strict mode (sql-mode = "TRADITIONAL").

Since then, I noticed this was causing a MySQL error when sending a new ticket in Traq. The error was:

Field 'milestone_id' doesn't have a default value
INSERT INTO `tickets` (`ticket_id`, `summary`, `body`, `user_id`, `project_id`, `version_id`, `component_id`, `type_id`, `status_id`, `priority_id`, `severity_id`, `assigned_to_id`, `is_closed`, `tasks`, `extra`, `created_at`) VALUES('4', 'MySQL Strict test', 'Test', '1', '2', '0', '0', '1', '1', '3', '4', '0', '0', '[]', '{\"voted\":[],\"custom_fields\":[]}', '2013-09-25 23:26:20') 

The problem is that Traq does not insert any value in the milestone_id field, and it doesn't have a default value, which is not allowed in strict mode (a numeric field cannot be left empty, but can be set to null if nullable).

The problem can be fixed by setting a default value in the table field (0 or null) or insert a default value in SQL query.

The problem can be reproduced with Wamp 2.2, just editing the my.ini to add the following line:

sql-mode = "TRADITIONAL"

PHP version is 5.3.13 and MySQL version is 5.5.24.

Ticket History

Jack closed as Fixed 10 years and 6 months ago

I've updated the install.sql and upgrade file to add a default value.