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

MySQL 8 expressions as default values cause syntax parsing error #1197

Closed
sourcec0de opened this issue Sep 18, 2021 · 2 comments
Closed

MySQL 8 expressions as default values cause syntax parsing error #1197

sourcec0de opened this issue Sep 18, 2021 · 2 comments
Labels
📚 mysql bug Something isn't working upstream Issue is caused by a dependency

Comments

@sourcec0de
Copy link

sourcec0de commented Sep 18, 2021

Version

1.10.0

What happened?

Hey all, thanks for this awesome library! Ran into some issues using expressions as default values in MySQL 8.
https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html

I assume this may just be a feature missing from the upstream https://github.com/pingcap/parser library.
Figured I would raise this here to see if anyone is aware of a workaround.

Thanks again for all the hard work.

Relevant log output

# package auth
schema.sql:3:29: syntax error near "(UUID()) NOT NULL PRIMARY KEY"

Database schema

CREATE TABLE IF NOT EXISTS organizations
(
    id VARCHAR(36) DEFAULT (UUID()) NOT NULL PRIMARY KEY
);

SQL queries

-- name: GetOrganization :one
SELECT * FROM organizations
WHERE id = ? LIMIT 1;

Configuration

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

Playground URL

https://play.sqlc.dev/p/8b99ca6623d728b89b335001bed9e38464a88572dbe2620456d1c3e37dcf5c67

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

@sourcec0de sourcec0de added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 18, 2021
@kyleconroy kyleconroy added 📚 mysql upstream Issue is caused by a dependency and removed triage New issues that hasn't been reviewed labels Sep 20, 2021
@kyleconroy
Copy link
Collaborator

This indeed appears to be an issue with the pingcap MySQL parser. I've opened an issue (pingcap/parser#1347) for this problem.

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
📚 mysql bug Something isn't working upstream Issue is caused by a dependency
Projects
None yet
Development

No branches or pull requests

2 participants