Skip to content

Add text column with default empty string value causes syntax error #3859

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
andylin-0 opened this issue Feb 24, 2025 · 0 comments · Fixed by #3893
Closed

Add text column with default empty string value causes syntax error #3859

andylin-0 opened this issue Feb 24, 2025 · 0 comments · Fixed by #3893
Labels
📚 mysql bug Something isn't working

Comments

@andylin-0
Copy link

andylin-0 commented Feb 24, 2025

Version

1.27.0

What happened?

Parsing DB migration file with setting the default value of a column to ('') causes a syntax error.

It works without enclosing the single-quotes in parentheses, but this value does not work with the goose migration tool

Relevant log output

sqlc generate failed.
# package 
schema.sql:7:69: syntax error near "'');" "

Database schema

CREATE TABLE authors (
  id   INT PRIMARY KEY,
  name text      NOT NULL,
  bio  text NOT NULL
);

SQL queries

ALTER TABLE authors ADD COLUMN explanation text NOT NULL DEFAULT ('');

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "mysql",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/3532b091fbc236e2c56c2eeb6a06ecc34ba3eb8deb833725b4b84f917c289bf5

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant