epsilon
epsilon copied to clipboard
Making Flexmi YAML flavour more natural
I tried writing some Flexmi files in YAML format today, using this custom metamodel:
I tried writing this bit:
?nsuri: https://eclipse.org/hawk/sqlite/queries
queryset:
name: NonTimeawareQueries
queries:
- name: "nodeIDsByLabel"
sql: "SELECT rowid FROM nodes WHERE label = ?;"
parameters:
- name: label
type: String
- name: "nodeCountByLabelStatement"
sql: "SELECT COUNT(1) FROM nodes WHERE label = ?;"
parameters:
- name: label
type: String
I expected to see one QuerySet with its proper name and two queries, each with their own name and parameters. This is in line with typical use of YAML, which supports three types of nodes: maps (essentially, objects), sequences (lists), and scalar values. I had expected to see maps turned into objects, sequences turned into ELists, and scalar values to be used to set attributes / references.
Unfortunately, I got something rather odd instead:
I had one Query with two parameters, for some reason.
I had to change the YAML file to this, which is cumbersome to type with all the -
s, and it's also not natural YAML:
?nsuri: https://eclipse.org/hawk/sqlite/queries
queryset:
- name: NonTimeawareQueries
- query:
- name: "nodeIDsByLabel"
- sql: "SELECT rowid FROM nodes WHERE label = ?;"
- parameters:
- name: label
- type: String
- query:
- name: "nodeCountByLabelStatement"
- sql: "SELECT COUNT(1) FROM nodes WHERE label = ?;"
- parameters:
- name: label
- type: String
That produced the expected outline:
From a semantic point of view, it doesn't make sense to have queryset
need to contain a list with its first element being a map whose key is name
just to set the name of that queryset. Same goes for specifying its child objects.