-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
[sqlparse] fix sqlparse bug #5703
Conversation
a5690f9
to
aaf5899
Compare
aaf5899
to
eecb864
Compare
Codecov Report
@@ Coverage Diff @@
## master #5703 +/- ##
==========================================
+ Coverage 63.45% 63.45% +<.01%
==========================================
Files 361 361
Lines 22972 22973 +1
Branches 2557 2557
==========================================
+ Hits 14576 14577 +1
Misses 8381 8381
Partials 15 15
Continue to review full report at Codecov.
|
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.
Should this logic belong in a function other than __extract_from_token
?
@@ -128,7 +129,8 @@ def __extract_from_token(self, token): | |||
continue | |||
|
|||
if item.ttype in Keyword: | |||
if self.__is_result_operation(item.value): | |||
if (self.__is_result_operation(item.value) or | |||
item.value.upper() == ON_KEYWORD): |
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.
It seems like line #134 is (and was) obsolete and that this check simply ensures one doesn't break. Would it make more sense if one simply removed the break
logic? According to line #136 (# FROM clause is over
) one would speculate that this portion of the code simply processes a FROM
clause rather than a JOIN
clause.
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 tested using continue instead of the break statement and it broke in some cases because it included the group by column in the table names.
@@ -310,3 +310,23 @@ def test_explain(self): | |||
self.assertEquals(True, sql.is_explain()) | |||
self.assertEquals(False, sql.is_select()) | |||
self.assertEquals(True, sql.is_readonly()) | |||
|
|||
def test_complex_extract_tables(self): |
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.
can we add another test that does not use ON
? Something like
SELECT *
FROM table_a AS a, table_b AS b
WHERE a.id = b.id
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.
Done
139a647
to
093a81e
Compare
@timifasubaa pending the |
093a81e
to
fcc1c17
Compare
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
[sqlparse] fix sqlparse bug (apache#5703)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case (cherry picked from commit 5c49514)
* fix sqlparse bug * add one more test case
superset's sql_parse implementation fails when there are more than two tables in a join.
This causes problems when we use this method to extract tables to determine if a user can access all the tables in a sqllab query.
This PR addresses the issue by preventing it from stopping early. I also added a test.
@john-bodley @mistercrunch