I wrote a working grammar to replace dbunit in scala called ScalaDBTest. The whole program works - just 2 days to write. I have a lot of polishing.
In any case, the grammar that I use for DSL to enter data into the database is malleable, and I would like some feedback from it.
The basic syntax looks like this. It is pretty simple:
country:
- country_id: 1, name: "Canada"
- country_id: 2, name: "United States"
This is certainly better than XML or SQL insert statements.
I discussed the use of ":" or "=". The former looks better, but the latter seems automatic to me.
There is also a concept in which you can βlabelβ a record. In a sense, the above syntax was anonymous. Shortcuts will be an interesting feature because you can use them in various ways.
country:
record: Canada -> country_id: 1, name: $label
record: UnitedStates -> country_id: 2, name: $label.uncamel
I do not like this syntax. These are a few two words. Using "-" does not look right, but if I use the actual command word, for example, "record", I need to put "->" to separate them, otherwise it looks very bad (this is not necessary for technical reasons).
$ label will simply repeat the label, so you can use the label at the minimum minimum to reuse the string. $ label.uncamel will add spaces where it looks like a camel case.
- API- . , , "", "", .
, :
province:
? country_id: 1, nice_weather: true
- province_id: 1, name: "British Columbia"
- province_id: 2, name: "Manitoba", nice_weather: false
- province_id: 3, name: "New York", country_id: 2
- . 3- 4 . 2 , . -. / .
, , , . .
:
article:
? date_create: $now
- article_id: 1, title: "The Fed Sucks"
- article_id: 2, title: null
, - , , dbUnit. DbUnit , (, "[NULL]" ) .
, , . , $now sql- /. , .
, , . - , , , .