Re: [Modeling-users] bug 841315: multiplicity constraints, [1,1]
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-11-13 10:14:00
|
Hi, thanks... Created bug 841315 for this: "Model associations do not set the multiplicity bounds" I have installed the patch, but there are some problems. First, the first installation test fails: % python ./run.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D FAIL: [PyModel] unqualified_relationships_with_inverse ---------------------------------------------------------------------- Traceback (most recent call last): File "test_PyModel.py", line 393, in =20 test_08_qualified_relationships_with_inverse self.check_model(model) File "test_PyModel.py", line 92, in check_model self.failIf(fkStore.isRequired()!=3DtoStore.multiplicityLowerBound())= File =20 "/BinaryCache/python/python-3.root~193/usr/lib/python2.2/unittest.py", =20= line 258, in failIf if expr: raise self.failureException, msg AssertionError ---------------------------------------------------------------------- Ran 107 tests in 7.906s FAILED (failures=3D1) 'Errors' indicate exceptions other than AssertionError. 'Failures' indicate AssertionError 0 errors, 1 failures Then, for my model, on validation I get a warning for each such relationship, e.g: Object: Relationship A.b ------------------------------- * Warning(s): - relationship is mandatory but source attribute A.fkBId is not =20 required And, if I try to run my test code, on the first import line for the =20 entity (A), I get a strange error: ImportError: No module named pympack.A Exception exceptions.TypeError: "'NoneType' object is not callable" in =20= <bound method EditingContext.__del__ of =20 <Modeling.EditingContext.EditingContext instance at 0x1c9b70>> ignored mario > Quick answer: you're not misunderstanding anything here, but the pb. = is > not w/ the validation code (which is tested enough ;), rather w/ the > pymodel itself: associations do not set the multiplicity bounds, you =20= > can > convince yourself with: > >>>> import AB >>>> from Modeling.ModelSet import defaultModelSet >>>> = defaultModelSet().entityNamed('A').relationshipNamed('b').multiplici=20 >>>> tyLowerBound() > 0 > > Try the attached patch, it should solve the pb. Please add a bug = report > if you find some time, so I won't forget to integrate this in cvs > tonight. > > -- S=E9bastien. > > > Index: PyModel.py > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/modeling/ProjectModeling/Modeling/PyModel.py,v > retrieving revision 1.6 > diff -u -r1.6 PyModel.py > --- PyModel.py 30 Aug 2003 12:55:05 -0000 1.6 > +++ PyModel.py 13 Nov 2003 09:30:13 -0000 > @@ -895,7 +895,8 @@ > > # Relationships > toOne_kw=3D{} ; toMany_kw=3D{} > - for k in =20 > ('delete','isClassProperty','joinSemantic','displayLabel','doc'): > + for k in =20 > ('delete','isClassProperty','joinSemantic','displayLabel','doc', > + 'multiplicity'): > toOne_kw[k]=3Dgetattr(self, k)[0] > toMany_kw[k]=3Dgetattr(self, k)[1] > toOne_kw['src']=3DsrcAtt.name ; toOne_kw['dst']=3DdstAtt.name > > Mario Ruggier <ma...@ru...> wrote: >> Hi, >> >> I have associations where a row of one entity should >> always be related to 1 and only 1 row of another entity, >> like so: >> >> model.entities =3D [ >> Entity('A', ...), >> Entity('B', ...), >> ] >> >> model.associations=3D[ >> # A is always related to a B >> Association('A','B', >> relations=3D['b','as'], >> multiplicity=3D[ [1,1], [0,None] ], >> delete=3D['nullify','deny'], >> keys=3D['fkBId','id'], >> ), >> ] >> >> However, if i create a row A and not relate it to any B, >> saveChanges on the EC is successful, and the "fkBId" >> value is NULL (running this with SQLite). I was expecting >> that the framework will will throw up on this. >> Am I misunderstanding something here? >> >> Cheers, mario > |