-
Notifications
You must be signed in to change notification settings - Fork 110
Fix integer literals parsing #840
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.
I think we should let the table implementations handle this. When the literals are parsed, they are converted to the minimum type of int possible, then the table is in charge of converting it.
If we really want to make this transparent for table implementations, then I'd go for doing column.Type.Convert(theLiteralValue) inside the InsertInto execution method, but I would not add a new rule in the analyzer for this specific case.
WDYT @src-d/data-processing?
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.
I think that the conversion should be done by us. If we convert string literals to proper dates, we should do the same here. I'd argue that int8 is as different from uint64 as a date is different from a string.
But maybe it makes sense to do it inside InsertInto, not as a new rule. I'll wait for the rest of opinions.
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.
Solved in 653fdde.
37761f9 to
3034d2d
Compare
I'm just noticing that I did not run gofmt over the new files. I'll fix the formatting in the next commit.
ce3bd83 to
6d4af9b
Compare
As per @erizocosmico's comment (check #840 (comment)), I've completely removed the integer conversion rule and moved its logic to Insert.Execute function. Much less code, which is always better.
I've added it as a new commit (653fdde) for if someone still prefers the other alternative, but I can rebase it before merging.
The latest four commits add missing cases to tests of modified functions. I think that CodeCoverage should be happy now.
Can you rebase? there are some conflicts now
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
- The integer literals in INSERT expressions are now converted to the type of their corresponding column in the schema. - sql.IsInteger has been fixed so that it recognizes smaller types. Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
f468c84 to
fe3a84c
Compare
Rebased. Codecov is still complaining, though. I'll take a look.
We can live with a -0.05%, don't worry 😄
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.
Well done!
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
The tests now expect the correct types specified in the tables schema Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
fe3a84c to
c0899fb
Compare
Force pushed without changes in go.mod. Thanks for the catch, @carlosms!
I think it should be ready to merge now.
Uh oh!
There was an error while loading. Please reload this page.
This PR fixes #834 with some changes:
convertIntso it returns the smallest representation allowed. See acb2bc0.(削除) Add a rule to convert integer literals to the specified types in the schema in INSERT nodes. See 2eb11bb. (削除ここまで)After discussion with @erizocosmico (check Fix integer literals parsing #840 (comment) ), I've completely removed the integer conversion rule and moved its logic to Insert.Execute function. Much less code, which is always better. See instead 653fdde#diff-7e21a9fc108efea330a88d73d2a81023.getInt64Literalfunction was modified so it converts any integer to int64. See 10d13fc.sqltypes.ValueinnumberT.SQLfunction, as it failed when 8 and 16 bits signed and unsigned integers values were passed, resulting in empty rows when doing, for example,SELECT 1. See ffae1d2Maybe the most comfortable way to review this is:
convertIntin acb2bc0 (if you know a way of making that code a bit more beautiful, I'd be glad to hear it)(削除) the new rule for integer conversion 2eb11bb and its test 22600f9 (削除ここまで)the modifiedInsert.Executefunction: 653fdde#diff-7e21a9fc108efea330a88d73d2a81023This one is my first big contribution to go-mysql-server, so please review and test thoroughly. Comments and suggestions are more than welcome.