Open
Description
Version
1.28.0
What happened?
Description
When using sqlc
with a MySQL schema that includes a POINT
column (a spatial data type), the sqlc generate
command fails with a syntax error. The POINT
type is a valid MySQL data type for storing geometric coordinates, but it appears sqlc
does not recognize or parse it correctly during schema validation, leading to a generation failure.
Steps to Reproduce
- Create a
schema.sql
file with the following content:CREATE TABLE `users_addresses` ( `id` int UNSIGNED NOT NULL, `user_id` int UNSIGNED NOT NULL, `address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, `postal_code` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, `location` point NOT NULL, `created_at` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
- Configure
sqlc.yaml
for MySQL:version: "2" sql: - schema: "schema.sql" queries: "queries.sql" engine: "mysql" gen: go: package: "db" out: "db"
- Run
sqlc generate
.
Expected Behavior
sqlc
should parse thePOINT
data type as a valid MySQL type and generate Go code, ideally mapping it to a reasonable default type (e.g.,[]byte
for WKB format) or allowing custom type overrides for spatial libraries likegithub.com/twpayne/go-geom
.
Actual Behavior
- The command fails with the following error:
sqlc generate # package schema.sql:6:52: syntax error near "point NOT NULL,"
Environment
- sqlc Version: [e.g.,
v1.26.0
— replace with your version; check withsqlc version
] - Database: MySQL (e.g., 8.0.32)
- OS: [e.g., Ubuntu 22.04, macOS 14, etc.]
- Go Version: [e.g.,
go1.21.6
]
Relevant log output
schema.sql:6:52: syntax error near "point NOT NULL,"
Database schema
CREATE TABLE `users_addresses` (
`id` int UNSIGNED NOT NULL,
`user_id` int UNSIGNED NOT NULL,
`address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`postal_code` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`location` point NOT NULL,
`created_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
SQL queries
Configuration
{
"version": "2",
"sql": [{
"schema": "schema.sql",
"queries": "query.sql",
"engine": "mysql",
"gen": {
"go": {
"out": "db_test"
}
}
}]
}
Playground URL
https://play.sqlc.dev/p/105f1e1d837c27b36207923cf8c947d4f6041dfcf90a76cef590bcca3bacd2ac
What operating system are you using?
macOS
What database engines are you using?
MySQL
What type of code are you generating?
Go