# HG changeset patch # User Sylvain Thénault # Date 1427266658 -3600 # Node ID d14db30b90d65a6bdc9298a80e766d17c8f1c378 # Parent fb113f9fa7d8d95cb41aa83ee85d99f89e5fbccc [repository] don't attempt to delete computed relation, they have no table in the database. Closes #5162935 diff -r fb113f9fa7d8 -r d14db30b90d6 server/repository.py --- a/server/repository.py Mon Mar 23 14:28:48 2015 +0100 +++ b/server/repository.py Wed Mar 25 07:57:38 2015 +0100 @@ -1095,6 +1095,8 @@ with session.security_enabled(read=False, write=False): eid = entity.eid for rschema, _, role in entity.e_schema.relation_definitions(): + if rschema.rule: + continue # computed relation rtype = rschema.type if rtype in schema.VIRTUAL_RTYPES or rtype in pendingrtypes: continue @@ -1123,6 +1125,8 @@ with session.security_enabled(read=False, write=False): in_eids = ','.join([str(_e.eid) for _e in entities]) for rschema, _, role in entities[0].e_schema.relation_definitions(): + if rschema.rule: + continue # computed relation rtype = rschema.type if rtype in schema.VIRTUAL_RTYPES or rtype in pendingrtypes: continue diff -r fb113f9fa7d8 -r d14db30b90d6 server/test/data/schema.py --- a/server/test/data/schema.py Mon Mar 23 14:28:48 2015 +0100 +++ b/server/test/data/schema.py Wed Mar 25 07:57:38 2015 +0100 @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -from yams.buildobjs import (EntityType, RelationType, RelationDefinition, +from yams.buildobjs import (EntityType, RelationType, RelationDefinition, ComputedRelation, SubjectRelation, RichString, String, Int, Float, Boolean, Datetime, TZDatetime, Bytes) from yams.constraints import SizeConstraint @@ -274,3 +274,7 @@ object = 'CWUser' inlined = True cardinality = '?*' + + +class user_login(ComputedRelation): + rule = 'O login_user S' diff -r fb113f9fa7d8 -r d14db30b90d6 server/test/unittest_repository.py --- a/server/test/unittest_repository.py Mon Mar 23 14:28:48 2015 +0100 +++ b/server/test/unittest_repository.py Wed Mar 25 07:57:38 2015 +0100 @@ -499,6 +499,13 @@ cnx.commit() self.assertEqual(len(c.reverse_fiche), 1) + def test_delete_computed_relation_nonregr(self): + with self.admin_access.repo_cnx() as cnx: + c = cnx.create_entity('Personne', nom=u'Adam', login_user=cnx.user.eid) + cnx.commit() + c.cw_delete() + cnx.commit() + def test_cw_set_in_before_update(self): # local hook class DummyBeforeHook(Hook):