Closed luan-cestari closed 9 years ago
In general, I don't think this is a good idea. All this class does is giving the ability to specify names in metadata instead of argument indexes, and in my opinion, we can live without it. Parsing the SQL query is not a good idea, especially if the parsed query is doing string manipulation. That said, there are some problems with the parser:
Also, pls rebase from master
I think I can fix the issues and this feature is nice to have, specially to simplify the user wor, but I agree that SQL manipulation can be dangerous (SQL-Injection)
Created some tests to increase the coverage and fold some cases that it would be wrong (they are a bit complex but they are valid).
@bserdar From the possible problems you mentioned, only the "parser fails if : is the last character" I didn`t get it . A SQL statement that ends with a : would be malformed. Could you give me an example the syntax is correct but would lead to an error please? Also, I updated the PR.
If the last character is a :, the parser fails with an "array index out of bounds" exception, instead of a malformed sql statement exception.
On Wed, Feb 4, 2015 at 5:55 AM, luan-cestari notifications@github.com wrote:
Created some tests to increase the coverage and fold some cases that it would be wrong (they are a bit complex but they are valid).
@bserdar https://github.com/bserdar From the possible problems you mentioned, only the "parser fails if : is the last character" I didn`t get it . A SQL statement that ends with a : would be malformed. Could you give me an example the syntax is correct but would lead to an error please? Also, I updated the PR.
— Reply to this email directly or view it on GitHub https://github.com/lightblue-platform/lightblue-rdbms/pull/107#issuecomment-72849627 .
You are right @bserdar . Pushed a fix for that. Let me know if you want me to handle that in a different way
I also think that after we finish we could push a PR for spacewalk which have the same flaws as we had
@luan-cestari open an issue if nothing else..
@jewzaam done, the issue is https://github.com/colloquium/spacewalk/issues/1
Your quote logic is wrong. You can't do what you're trying to do without a stack. It won't parse this:
' 123 "123"123 '
Why are you even working with double quotes?
Also, there is no way to deal with this:
select * from table where column like 'abc:%def%' escape ':'
These kind of edge cases are the reason why I am against parsing sql statements.
I just pushed new test scenarios following what you mentioned but I didn't find any issue. So you can check them out and see if it is fine that way or not.
I think we can also make the edge cass more clear, so we could define each edge case and make a specific test for it.
How about this:
select * from table where column like ' 123 \"123\"1 :xyz 23 '
I believe it will parse :xyz as a field.
@bserdar I just pushed a new test and it worked fine. Any other suggestions?
This PR aims to fix #75