kevoree-modeling-framework icon indicating copy to clipboard operation
kevoree-modeling-framework copied to clipboard

Unicity with @id is not guarantied

Open maxleiko opened this issue 10 years ago • 1 comments

When you have this model:

class my.Foo {
  members: my.Bar[0,*]
}

class my.Bar {
  @id
  name: String
}

You expect my.Foo.members to act like a "Set" as it will only allow one and only one instance of my.Bar with the id "unik" for instance.

But that's not the case currently:

        Foo f = view.createFoo();
        f.addMembers(view.createBar().setName("unik"));
        f.addMembers(view.createBar().setName("unik"));
        view.json().save(f, (model, e) -> System.out.println(model));

Outputs:

[
{
    "@meta" : "my.Foo",
    "@uuid" : "1",
    "inputs": ["2","3"],
}
,{
    "@meta" : "my.Bar",
    "@uuid" : "2",
    "@parent" : "1",
    "@ref" : "my.Foo@members",
    "@inbounds" : ["[email protected]@members"],
    "name":"unik",
}
,{
    "@meta" : "my.Bar",
    "@uuid" : "3",
    "@parent" : "1",
    "@ref" : "my.Foo@members",
    "@inbounds" : ["[email protected]@members"],
    "name":"unik",
}
]

maxleiko avatar Jan 15 '15 16:01 maxleiko

True, the @id in the add and in the compare is still not managed in KMFv4, will be extended soon

dukeboard avatar Jan 15 '15 16:01 dukeboard