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

Cannot parse fields or complex expressions in generated columns #169

Closed
andrewmcfaul opened this issue Nov 3, 2021 · 1 comment
Closed

Comments

@andrewmcfaul
Copy link

When comparing schemas with generated columns, the comparison has an error if a field is specified using backticks or if the expression includes artithmetic operators like addition, division etc. This is similar to #153 but it only dealt with simple string values in the generated column expression.

Input SQL

CREATE TABLE test_generated (
id int(11) NOT NULL AUTO_INCREMENT,
log_ins int(11) NOT NULL DEFAULT '0',
user_count int(11) NOT NULL DEFAULT '0',
log_ins_per_user float GENERATED ALWAYS AS (log_ins / user_count) VIRTUAL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Current output

found syntax error when parsing DDL "CREATE TABLE test_generated (
id int(11) NOT NULL AUTO_INCREMENT,
log_ins int(11) NOT NULL DEFAULT '0',
user_count int(11) NOT NULL DEFAULT '0',
log_ins_per_user float GENERATED ALWAYS AS (log_ins / user_count) VIRTUAL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8": syntax error at position 217 near 'log_ins'

Expected output

Any valid expression should be allowed, including fields specified with backticks, operators like +, -, *, /, (, ), <, >, =, >=, <= and common SQL functions like CONCAT() etc.

@k0kubun k0kubun closed this as completed in b999df1 Nov 4, 2021
@k0kubun
Copy link
Collaborator

k0kubun commented Nov 4, 2021

Fixed the reported case at v0.11.12. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants