Strange exception of RDBMS API on cardinality violation on create
When on an entity type of the schema, cardinality
is defined with +
(at least one), and that the constraint is violated, we would except an exception that says that the cardinality is violated. Instead of this, it says that the relation of one is not filled !
Example
Schema
class Group(EntityType):
units = SubjectRelation('GroupItem, cardinality='+?')
Automatic test
def test_group_unit_multiple_create(self):
with self.admin_access.cnx() as cnx:
self.create_group(cnx, units=(self.item1_eid,))
cnx.commit()
self.create_group(cnx, units=(self.item1_eid,))
cnx.commit() # the exception comes from here
Result
yams._exceptions.ValidationError: 9070 (units-subject): at least one relation units is required on Group (9070)
Stack trace
../../.virtualenvs/nemo/lib/python3.7/site-packages/cubicweb/server/session.py:157: in check_open
return func(cnx, *args, **kwargs)
../../.virtualenvs/nemo/lib/python3.7/site-packages/cubicweb/server/session.py:735: in commit
operation.handle_event("precommit_event")
../../.virtualenvs/nemo/lib/python3.7/site-packages/cubicweb/server/hook.py:807: in handle_event
getattr(self, event)()
Versions used
- CubicWeb 3.32.7
- RQL 0.37.0
- YAMS 0.45.3