-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Added a new SQL parser for migrations. #215
Conversation
…ents and comment blocks. SQL statements can span multiple lines but must be delimited with a semicolon. This allows for improved readability of SQL scripts. The old parser expects one statement per line which may or may not end with a semicolon. This means the new parser can also process scripts written for the old parser if those scripts end each line with a semicolon. For backwards compatibility reasons this parser isn't used unless the manifest contains a meta-data entry "AA_SQL_PARSER" with the value "delimited". If this value isn't specified or is set to "legacy" the old parser implementation is used.
Much more readable formatting. Can you write a simple test for this SQL parser and ensures the old one is used by default? |
Sure, I'll look into writing tests for this and my other pull request. The old parser should be default already but I'll try to cover that with a test as well. |
…de strings and comments are ignored.
All right, that's all the tests I can think of. Tell me if you still find anything missing. |
@markuspfeiffer, this is excellent work. Just waiting for @SeanPONeil to merge this in. I'll take a look at the other commits as well. |
Nice commit. |
Added a new SQL parser for migrations.
Hi, should this commit support a script with some insert text that happens to contain a comma character ? |
Yes, it should. Take a look at the test cases, they cover this case and a lot more. If you get errors with your script make sure you have the following line in your manifest:
Without this line the old parser is used which doesn't support multi-line scripts, comments, etc. |
This pull request adds a new option for the SQL script parser used during database migration.
This parser supports both SQL style line comments and comment blocks. SQL statements can span multiple lines but must be delimited with a semicolon. This allows for improved readability of SQL scripts.
The old parser expects one statement per line which may or may not end with a semicolon. This means the new parser can also process scripts written for the old parser if those scripts end each line with a semicolon.
For backwards compatibility reasons this parser isn't used unless the manifest contains a meta-data entry
AA_SQL_PARSER
with the valuedelimited
. If this value isn't specified or is set tolegacy
the old parser implementation is used.Example:
Add the following entry to the AndroidManifest.xml:
It is now perfectly legal to write a migration script (e.g. 2.sql) that looks like this:
The same script, using the "legacy" parser, must look like this:
Sure, its more compact but far less readable. Imagine doing the same with a table containing 20 or more columns... :)