You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sqlc generate fails on MySQL DDL using DEFAULT (UTC_TIMESTAMP()) / ON UPDATE (UTC_TIMESTAMP()) #4178
Hello!
First of all, thanks for the great work on sqlc. We rely on it heavily and it has been a huge boost to our project.
We’ve encountered an issue when generating Go code from our MySQL schema.
It appears that sqlc generate fails when encountering expression defaults such as DEFAULT (UTC_TIMESTAMP()) or ON UPDATE (UTC_TIMESTAMP()).
Environment
sqlc version: 1.30.0 (also reproduces on latest)
Database: MySQL 8.0+ (also MySQL 9.x / Aurora MySQL compatible)
MySQL accepts this syntax (valid since 8.0.13 ?), but sqlc’s MySQL parser rejects it.
Expected
sqlc generate should parse these valid MySQL expressions in DEFAULT and ON UPDATE.
Actual
syntax error near "UTC_TIMESTAMP())"
Minimal Repro
Create a migration file, e.g.,:
CREATETABLEmytable (
id BIGINT UNSIGNED NOT NULL,
created_at TIMESTAMPNOT NULL DEFAULT (UTC_TIMESTAMP())
);
Run sqlc generate
Why this matters
UTC_TIMESTAMP() guarantees UTC regardless of session time_zone
Production MySQL setups may rely on this pattern (at least I wanted to hence the report)
Possible workaround: Removing defaults is not acceptable, and forcing ALTER later just to satisfy sqlc is undesirable
Suggestion
A) Extend MySQL parser support for DEFAULT () and ON UPDATE ()
B) Even allowing sqlc to ignore expression-defaults in DDL would be acceptable, since default/trigger logic doesn’t affect type generation
Thanks!
M
Relevant log output
syntax error near "UTC_TIMESTAMP()),"
Database schema
CREATETABLEmytable (
id BIGINT UNSIGNED NOT NULL,
created_at TIMESTAMPNOT NULL DEFAULT (UTC_TIMESTAMP()),
);
Activity