Bug #7239

Cached value of a Variable referencing an asserted property is not updated when a literal is added

Added by Reino Ruusu 10 months ago. Updated about 1 month ago.

Status:NewStart date:
Priority:4Due date:
Assignee:Antti Villberg% Done:


Category:VariableSpent time:-
Target version:-
Release notes:
Story points-
Velocity based estimate-



A Variable that has a value that is defined by a default value from an assertion in the property relation, such as http://www.simantics.org/Diagram-2.2/Element/profileMonitorOffset, retains its cached value, when the database is updated to include literal value for the property.

This may result in various displays of outdated values, as well as loss of data, when values are updated using repeated calls to updates of field or elements values in literals with structured data types.

What happened & Steps to reproduce

The error can be reproduced by calling the following function on a diagram element that does not have a defined profileMonitorOffset value:

> setProfileMonitorOffset r x y = do
   var = resourceVariable r
   v = property var "profileMonitorOffset" 
   setPropertyValue v "n-x" x
   setPropertyValue v "n-y" y

> setProfileMonitorOffset (getElement currentModel "PIP02") 100 100

Expected results & Actual results

The expected result of calling the above function is that the profileMonitorOffset property has acquired the value { x = 100.0, y = 100.0 }. Instead, the generated value is { x = 0.0, y = 100.0 }.

When the same function is called for an element that already has a defined property value, both the x and y fields of the value are properly updated.

Workaround & How to fix this

This problem can be mitigated by requesting a new Variable instance between the calls to subliteral value udpates:

setProfileMonitorOffset r x y = do
   var = resourceVariable r
   v = property var "profileMonitorOffset" 
   setPropertyValue v "n-x" x
   v2 = property var "profileMonitorOffset" 
   setPropertyValue v2 "n-y" y

The cause of this behaviour is apparent in the return value of the first statement of org.simantics.db.layer0.variable.SubliteralPropertyVariable.setValue(WriteGraph, Object, Binding), which returns the old asserted value { x = 0.0, y = 0.0 }, instead of the actual property value { x = 100.0, y = 0.0 } during the second setPropertyValue call.


#1 Updated by Antti Villberg 10 months ago

  • Target version changed from 2017-18 to 2017-22

#2 Updated by Tuukka Lehtonen 9 months ago

  • Target version changed from 2017-22 to 2017-24

#3 Updated by Tuukka Lehtonen 8 months ago

  • Due date deleted (2017-05-22)
  • Target version deleted (2017-24)
  • Start date deleted (2017-05-22)
  • Release set to 56

#4 Updated by Tuukka Lehtonen about 1 month ago

  • Release deleted (56)

Also available in: Atom PDF