SQLGeneration icon indicating copy to clipboard operation
SQLGeneration copied to clipboard

Parsing multiple statements

Open dazinator opened this issue 11 years ago • 4 comments

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:

UPDATE customer SET firstname = 'Dave' WHERE id = 1;
UPDATE customer SET firstname = 'Jo' WHERE id = 2;
DELETE FROM customer WERE id = 3

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?

dazinator avatar Jul 03 '14 10:07 dazinator

I'm going to create a fork and investigate!

dazinator avatar Jul 06 '14 14:07 dazinator

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? I have put more detailed comments against the above check in.

dazinator avatar Jul 06 '14 17:07 dazinator

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.

dazinator avatar Jul 06 '14 19:07 dazinator

Have submitted PR for this.

dazinator avatar Jul 06 '14 21:07 dazinator