Created
February 19, 2014 16:05
-
-
Save johnrengelman/9095118 to your computer and use it in GitHub Desktop.
Groovy SQL DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select('foo') { | |
eq('id', 1) | |
projections { | |
property('bar') | |
} | |
} | |
result: 'SELECT bar FROM foo WHERE id = 1;' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The idea here is for a tool that can randomize information in any DB. So the user provides a config file:
This would basically create a random String value for
name
and update thefoo
table a new random value for each row.Additionally, I want to add a raw SQL section using a concise DSL.
The idea here would be that the postProcessing block would contain a SQL string that says
UPDATE foo SET last_name = name
and that would get executed after the fact.Since this tool doesn't know the database it will be running against, I can't generate the classes for the tables/columns for something like jOOQ (AFAIK, it doesn't provide an API for interacting through strings, kind of defeats the type safety).