Skip to content
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

Making Flexmi YAML flavour more natural #21

Open
agarciadom opened this issue Dec 5, 2022 · 2 comments
Open

Making Flexmi YAML flavour more natural #21

agarciadom opened this issue Dec 5, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@agarciadom
Copy link
Contributor

agarciadom commented Dec 5, 2022

I tried writing some Flexmi files in YAML format today, using this custom metamodel:

queryset-metamodel.zip

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:

image

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:

image

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.

@agarciadom
Copy link
Contributor Author

To clarify, what I mean is that it's much more natural YAML to do:

queryset:
  name: foo

Than to do this:

queryset:
  - name: foo

The first option says "name is a property of the queryset, which is equal to 'foo'".

The second option says "queryset contains an element whose name is 'foo'".

@agarciadom
Copy link
Contributor Author

agarciadom commented Dec 5, 2022

For comparison, I changed this to Flexmi XML just now:

<?nsuri https://eclipse.org/hawk/sqlite/queries?>
<queryset name="NonTimeawareQueries">
  <query name="nodeIDsByLabel" sql="SELECT rowid FROM nodes WHERE label = ?;">
    <param name="label" type="String"/>
  </query>
  <query name="nodeCountByLabelStatement" sql="SELECT COUNT(1) FROM nodes WHERE label = ?;">
    <param name="label" type="String"/>
  </query>
 </queryset>

From a semantic point of view, this matches my first attempt with YAML more closely than the second version I had to write to get it to work.

That produces the expected result:

image

@kolovos kolovos added the enhancement New feature or request label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants