-
Notifications
You must be signed in to change notification settings - Fork 10
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 multiple statements #14
Comments
I'm going to create a fork and investigate! |
1. Created a unit test 'TestBatch_MultipleInserts' that tests whether we can parse sql text that has 2 seperate insert statements in, using semi colon as the line termnator. 2. Extended the SqlTokenRegistry class with support for LineTerminator. 3. Extended the SqlGrammar class, the defineStart() method was changed so that it expects an optional LineTerminator after every statement. I'm now stuck.. I think I want the Parser Class to return a MatchResult that includes all the Statements, however at the moment it just returns the individual InsertStatement - although it does correctly detect the LineTerminator token..
I have had a go at this in my fork. I managed to extend the Grammar, and Line Terminator tokens are now correctly detected. However, I am stuck on the Parser class. Any chance of a pointer in this area? |
Ahh nevermind - I have just made a break through on this. I can now see the way forward. Hopefully i should be able to submit a pull request to you pretty soon. |
… contains many different sql commands with terminators in the same batch as opposed to just a single command. jehugaleahsa#14
Have submitted PR for this. |
1. Created a unit test 'TestBatch_MultipleInserts' that tests whether we can parse sql text that has 2 seperate insert statements in, using semi colon as the line termnator. 2. Extended the SqlTokenRegistry class with support for LineTerminator. 3. Extended the SqlGrammar class, the defineStart() method was changed so that it expects an optional LineTerminator after every statement. I'm now stuck.. I think I want the Parser Class to return a MatchResult that includes all the Statements, however at the moment it just returns the individual InsertStatement - although it does correctly detect the LineTerminator token..
… contains many different sql commands with terminators in the same batch as opposed to just a single command. jehugaleahsa#14
Hey - long time no speak :)
I was wondering if you have any thoughts around how to parse a SQL string that has multiple inidividual statements? For example - I would like to be able to parse:
At the moment, the parser is expecting a single UPDATE, INSERT, SELECT statement etc and so if you try to parse this string, it falls over.
I am suspecting that me doing a string split on a semi colon prior to parsing may not be ideal?
The text was updated successfully, but these errors were encountered: