Menu

#128 insertion order for ordered role is not preserved

fixed
None
normal
major
always
OCL standard conformance
3.0.1
3.0.3
2013-03-09
2011-12-06
German VEGA
No

Suppose I have the following model ;

model Test

&nbps;&nbps;&nbps; class A
&nbps;&nbps;&nbps; end

&nbps;&nbps;&nbps; class B
&nbps;&nbps;&nbps; end

&nbps;&nbps;&nbps; composition contains
&nbps;&nbps;&nbps; between
&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; A[1..1] role a
&nbps;&nbps;&nbps;&nbps;&nbps;&nbps;&nbps; B[1..*] role bs ordered
&nbps;&nbps;&nbps; end

When I insert several links in the association, the insertion ordered is not preserved

!new A('A')
!new B('B1')
!new B('B2')
!insert (@A,@B1) into contains
!insert (@A,@B2) into contains

I would expect the following to be true
?@A.bs->first() = @B1

but the behavior is not consistent, sometimes it works some other doesn't.

see attached image for illustration

Discussion

  • German VEGA

    German VEGA - 2011-12-06
     
  • Fabian Buettner

    Fabian Buettner - 2011-12-08

    Hello,

    the support for 'ordered' is unfortunately broken in USE.
    This is a bug and has to be fixed. However, it looks that this might take a little while (as far as I can tell at the moment).

    The only workaround I can suggest right now is to replace the ordered association by a Sequence-typed attribute. So for the instantiation you would replace 'insert' by 'set'. However, multiplicity checking and inverse end navigation will be missing and would need to be replaced by additional constraints resp. a query operation modeling the the inverse navigation.

    Best regards
    Fabian

     
  • Lars Hamann

    Lars Hamann - 2013-03-09

    - Insertion order is kept
    - Adding at specific index is still not working (Feature request to SOIL)
    - The issue was fixed in 3.0.3 but not marked as resolved

     

Log in to post a comment.