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
Since MariaDB 10.7 there is a native UUID data type. Using this data type in the schema definition gives an error when generating code:
sqlc generate failed.
# package db
query.sql:2:9: syntax error near "uuid primary key,"
Workaround
When I change the datatype in the schema.sql from uuid to binary and add an override in the sqlc.yaml the generation works as expected.
updated schema.sql:
create table user (
id binary default uuid() not null primary key,
name varchar(50) not null,
email varchar(255) not null,
password_hash varchar(60) not null,
created_datetime timestamp not null default current_timestamp(),
updated_datetime timestamp not null default current_timestamp() on update current_timestamp()
);
sqlc is trying to add the import github.com/google/uuid on the generated file querier_sqlc.go but this file does not use it directly - it just define the Querier interface and the go vet goes crazy.
we will try to write a minimal example that trigger this issue
@peczenyj the Querier imports issue was resolved in #2709.
Regarding sqlc support for MariaDB's custom UUID type, I don't think we can add that without introducing a new engine. There may be a point at which there are enough differences between MySQL and MariaDB where we want to introduce a new engine type, and maybe that point is already here. I'm not an expert so can't really say, but this is probably a conversation better handled in a GitHub discussion.
Version
1.21.0
What happened?
Since MariaDB 10.7 there is a native UUID data type. Using this data type in the schema definition gives an error when generating code:
Workaround
When I change the datatype in the schema.sql from uuid to binary and add an override in the sqlc.yaml the generation works as expected.
updated schema.sql:
updated sqlc.yaml:
However, changing the data type in the schema.sql is not desired because it does not reflect reality.
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/e7301e06df354e56281efe68b535030621c6432705b11e54f542b1e322241858
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: