Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for MySQL POINT Spatial Data Type in Schema Parsing #3868

Open
sky93 opened this issue Mar 4, 2025 · 3 comments
Open

Support for MySQL POINT Spatial Data Type in Schema Parsing #3868

sky93 opened this issue Mar 4, 2025 · 3 comments
Labels
📚 mysql bug Something isn't working upstream Issue is caused by a dependency 🔧 golang

Comments

@sky93
Copy link

sky93 commented Mar 4, 2025

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

  1. 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;
  2. Configure sqlc.yaml for MySQL:
    version: "2"
    sql:
      - schema: "schema.sql"
        queries: "queries.sql"
        engine: "mysql"
        gen:
          go:
            package: "db"
            out: "db"
  3. Run sqlc generate.

Expected Behavior

  • sqlc should parse the POINT 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 like github.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 with sqlc 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

@sky93 sky93 added the bug Something isn't working label Mar 4, 2025
@kyleconroy kyleconroy added the upstream Issue is caused by a dependency label Mar 24, 2025
@kyleconroy
Copy link
Collaborator

This is currently blocked on support in our MySQL parser. You can track the issue here pingcap/tidb#29370

@dveeden
Copy link

dveeden commented Mar 26, 2025

@kyleconroy Looks like #3741 is the same kind of issue, right?

@kyleconroy
Copy link
Collaborator

Yep, can close that one out as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 mysql bug Something isn't working upstream Issue is caused by a dependency 🔧 golang
Projects
None yet
Development

No branches or pull requests

3 participants