Skip to content

Expressions in DEFAULT clause work for postgresql driver, but not mysql driver #1754

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

Closed
jackdelab opened this issue Jul 21, 2022 · 1 comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@jackdelab
Copy link

Version

1.14.0

What happened?

Running sqlc generate with the "mysql" driver against a DDL with expressions in a column DEFAULT clause fails with an SQL syntax error message.

Changing the "engine" from "mysql" to "postgresql" in the playground link below results in successful code generation.

Relevant log output

sqlc generate failed.
# package db
query.sql:5:43: syntax error near "BIO_FUNC()"

Database schema

-- Example queries for sqlc
CREATE TABLE authors (
  id   INT PRIMARY KEY,
  name text      NOT NULL,
  bio  text      NOT NULL DEFAULT BIO_FUNC()
);

SQL queries

No response

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "mysql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/abfc94a7837eec5ceee75e58e7db6dcd6654f4055bbf241bb72ef2306deacd44

What operating system are you using?

No response

What database engines are you using?

MySQL

What type of code are you generating?

Go

@jackdelab jackdelab added bug Something isn't working triage New issues that hasn't been reviewed labels Jul 21, 2022
akutschera added a commit to akutschera/sqlc that referenced this issue Jul 25, 2022
akutschera added a commit to akutschera/sqlc that referenced this issue Jul 25, 2022
kyleconroy pushed a commit that referenced this issue Jul 27, 2022
* (chore): Upgrade tidb_parser to new repository

fixes: #1795
Refs: #1197 #1754

* test(MySQL): Add test for default column values

Refs: #1197 #1754
@kyleconroy
Copy link
Collaborator

We've upgraded to the latest version of the MySQL parser which should fix this issue.

jlisthood pushed a commit to jlisthood/sqlc that referenced this issue Apr 28, 2023
* (chore): Upgrade tidb_parser to new repository

fixes: sqlc-dev#1795
Refs: sqlc-dev#1197 sqlc-dev#1754

* test(MySQL): Add test for default column values

Refs: sqlc-dev#1197 sqlc-dev#1754
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

2 participants