-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Your Question
I'm encountering an issue with GORM where zero timestamps are being inserted into a MySQL database even when strict SQL mode is enabled, which shouldn't allow such values. Here's the details:
The database column is of type timestamp.
In my Go code, the corresponding field is of type time.Time.
The database has strict mode enabled (which should prevent inserting invalid timestamps like 0000-00-00 00:00:00).
However, when I insert a record using GORM without explicitly setting this time field (leaving it as the zero value of time.Time), the insertion succeeds, and the database ends up with 0000-00-00 00:00:00 for that column. This contradicts the strict mode configuration, which should reject such values.
I suspect GORM might be doing some special handling for timestamp fields that bypasses the database's strict mode checks. Has anyone encountered this issue?
Any insights or solutions would be greatly appreciated. Thank you!