Skip to content

MySQL JSON_TABLE not supported #3129

@sgielen

Description

@sgielen

Version

1.25.0

What happened?

A migrations file using the MySQL JSON_TABLE function cannot be parsed by sqlc. (Documentation for MySQL, MariaDB)

Relevant log output

# package 
migrations/2.sql:8:19: syntax error near "(p.emails, '$[*]' COLUMNS(email TEXT PATH '$')) AS pe;"

Database schema

-- migrations/1.sql
CREATE TABLE person (
  emails TEXT NOT NULL
);

-- migrations/2.sql
CREATE TABLE person_email (
  email TEXT NOT NULL
);

INSERT INTO person_email (`email`)
  SELECT pe.email
  FROM person AS p
  JOIN JSON_TABLE(p.emails, '$[*]' COLUMNS(email TEXT PATH '$')) AS pe;

SQL queries

-- name: GetEmails :many
SELECT email FROM person_email;

Configuration

version: "2"
sql:
- engine: "mysql"
  queries: "queries.sql"
  schema: "migrations"
  gen:
    go:
      out: "gendb"

Playground URL

https://play.sqlc.dev/p/0bed956ccb54908516d6a6f70813e4cf1182bb978b548689034de7813eb7efce

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions