-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fix explicit DEFAULT value in insert query #519
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
This looks good, but please add tests:
- parse_test.go
- insert_queries.go
And don't forget to run ./format_repo.sh when you're done.
sql/parse/parse.go
Outdated
|
||
if e, ok := src.(*plan.Values); ok { | ||
var needCols []sql.Expression | ||
for i, s := range e.ExpressionTuples[0] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be more than 1 element in ExpressionTuples, need to account for that
e46e3aa
to
3d9065a
Compare
@zachmu Updated pull request with tests and handles multiple ExpressionTuples. However, as my method is just to turn explicit DEFAULT to implicit. So, it won't work insertion query test case like this: {
Name: "explicit DEFAULT with multiple values different order",
SetUpScript: []string{
"CREATE TABLE mytable(id int PRIMARY KEY, v2 int NOT NULL DEFAULT '2', v3 int NOT NULL DEFAULT '3')",
},
Assertions: []ScriptTestAssertion{
{
Query: "INSERT INTO mytable (id, v2, v3)values (1, DEFAULT, 0), (2, 0, DEFAULT)",
Expected: []sql.Row{
{sql.OkResult{RowsAffected: 2}},
},
},
{
Query: "SELECT * FROM mytable",
Expected: []sql.Row{
{1, 2, 0},
{2, 0, 3},
},
},
},
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the changes!
It seems that
go-mysql-server
is not compatible with insert query like:Whereas
DEFAULT
is just to specifydeleted
columns should use column default value explicitly.The issue could be demostrated using below code:
This pull request should avoid such issue by turning explicit
DEFAULT
in insert query to implicit.