typhon-project / typhonql

Typhon Query Language
Eclipse Public License 2.0
4 stars 1 forks source link

[BUG] Retargeting relation fails in SQL/MongoDB #89

Closed pinoval closed 4 years ago

pinoval commented 4 years ago

Describe the bug

Given a 1-ary containment relation, one would expect that when updating the associated entity in the owner end, the former owned entity won't keep a relation to the owner end. This is not the case.

Test

This test exemplifies the situation astestUpdateRefSQLMongoFormerTo fails.

void testUpdateSingleRefSQLMongo(PolystoreInstance p) {
  p.runUpdate((Request)`update Biography b where b.@id == #bio1 set {user: #davy}`);
  rs = p.runQuery((Request)`from Biography b select b.@id, b.user where b.@id == #bio1`);
  p.assertResultEquals("testUpdateRefSQLMongo", rs, <["b.@id", "b.user"], [[ U("bio1"), U("davy")]]>);
  rs = p.runQuery((Request)`from User u select u.@id, u.biography where u.@id == #davy`);
  p.assertResultEquals("testUpdateRefSQLMongoTo", rs, <["u.@id", "u.biography"], [[ U("davy"), U("bio1")]]>);
  rs = p.runQuery((Request)`from User u select u.@id, u.biography where u.@id == #pablo`);
  p.assertResultEquals("testUpdateRefSQLMongoFormerTo", rs, <["u.@id", "u.biography"], [[ U("pablo"), {}]]>);
}

To reproduce

Models are at https://github.com/typhon-project/typhonql/tree/dev/typhonql/src/lang/typhonql/test/resources/user-review-product.

Test has been added to test suite on commit https://github.com/typhon-project/typhonql/commit/3fa8a01f7c6d6aa635f1da8b54a7d3cdb981ae18

tvdstorm commented 4 years ago

Fixed in 6929cfe