-
Notifications
You must be signed in to change notification settings - Fork 700
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
Parsing of a stored procedure, issues with WHERE that has a nested function #743
Comments
Thanks for reporting! This seems to be related to #692 Could you provide a (preferably minimal) example of a complete procedure statement and the changes you've made to |
The entire procedure started with the following \r\n\r\nCREATE PROCEDURE [dbo].[PopulateDimension] \r\nAS\r\nBEGIN\r\n\t- The statement that was returned included tokens where the final token in that statement was a WHERE token. That WHERE token captured several downstream UPDATE procedures but also left a few other downstream UPDATE procedures out of that token. I troubleshooted by feeding in only the several section of sql that were bundled as one token and sql.parse worked as expected. I then walked back through the sql.parse function and realized the lexer was parsing as expected. I then continued to walk the process back to the _change_splitlevel where I noticed the comments regarding CREATE. Since my use case only requires starting from begin, I simply parsed out all text prior to BEGIN and sql.parse worked as expected. I realize this may not be helpful for updating the code base but I wanted to create a record so someone else who may be searching for a solution to why the parsing in bundling several functions and a possible method to work around. BTW...thanks for this package.
|
I was parsing a stored procedure and found a particular issue involving a WHERE which has a nested WHERE and was then returning several other statements after this statement within the WHERE statement. After tracking the sqlparse.parse(sql) logic back to _change_splitlevel in statement_splitter I discovered the CREATE at the beginning of the stored procedure was causing the issue. After I sliced out all text prior to BEGIN and used only the text from BEGIN forward then the parser worked as expected. There were several "UPDATE" statements that were returned with the WHERE statement prior to me removing the CREATE text to BEGIN.
WHERE X NOT IN (SELECT Y FROM Z WHERE M IS NOT NULL);
-- COMMENT
UPDATE LMNO
SET V = H,
The text was updated successfully, but these errors were encountered: