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

mysqldef: json column default: syntax error near '{}' #468

Open
zztkm opened this issue Nov 24, 2023 · 4 comments
Open

mysqldef: json column default: syntax error near '{}' #468

zztkm opened this issue Nov 24, 2023 · 4 comments
Labels
mysqldef Bugs or feature requests related to MySQL

Comments

@zztkm
Copy link

zztkm commented Nov 24, 2023

Platform

  • OS: macOS
  • RDBMS: MySQL
  • Version: maybe v0.16.12

--export output

CREATE TABLE `hello_json_utf8mb4` (
  `id` int NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

Input SQL

CREATE TABLE `hello_json_utf8mb4` (
  `id` int NOT NULL AUTO_INCREMENT,
  `json_col` json NOT NULL DEFAULT (_utf8mb4'{}'),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

Current output

found syntax error when parsing DDL "CREATE TABLE `hello_json_utf8mb4` (
  `id` int NOT NULL AUTO_INCREMENT,
  `json_col` json NOT NULL DEFAULT (_utf8mb4'{}'),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin": syntax error at position 121 near '{}'

Expected output

Run: 'ALTER TABLE user ADD COLUMN json_col json NOT NULL ~  ;'
@zztkm zztkm changed the title mysqldef: syntax error mysqldef: json column default: syntax error near '{}' Nov 24, 2023
@zztkm
Copy link
Author

zztkm commented Nov 24, 2023

If you know the revision policy and can tell me about it, i would be willing to submit a PR.

@k0kubun
Copy link
Collaborator

k0kubun commented Nov 25, 2023

Sorry, I don't understand what is "the revision policy".

This is probably a bug in the parser. The lexer (parser/token.go) and/or the parser (parser/parser.y) would need to be modified. If you can open a PR, that would be pretty much appreciated.

@zztkm
Copy link
Author

zztkm commented Nov 27, 2023

Sorry, I don't understand what is "the revision policy".

Sorry, my English was not correct...

I wanted to ask you what I should do to fix the syntax error.

I will use the following post to work on a fix!
https://qiita.com/k0kubun/items/1b641dfd186fe46feb65

@k0kubun k0kubun added the mysqldef Bugs or feature requests related to MySQL label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mysqldef Bugs or feature requests related to MySQL
Projects
None yet
Development

No branches or pull requests

2 participants