jehugaleahsa / SQLGeneration

Provides core classes for generating SQL at runtime.
The Unlicense
22 stars 10 forks source link

Parsing multiple statements #14

Open dazinator opened 10 years ago

dazinator commented 10 years ago

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 commented 10 years ago

I'm going to create a fork and investigate!

dazinator commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

Have submitted PR for this.