Skip to content

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

Closed
@jackdelab

Description

@jackdelab

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions