Re: [Modeling-users] multiplicity constraints, [1,1]
Status: Abandoned
Brought to you by:
sbigaret
|
From: Sebastien B. <sbi...@us...> - 2003-11-13 09:33:34
|
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 can
convince yourself with:
>>> import AB
>>> from Modeling.ModelSet import defaultModelSet
>>> defaultModelSet().entityNamed('A').relationshipNamed('b').multiplicityL=
owerBound()
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 @@
=20
# Relationships
toOne_kw=3D{} ; toMany_kw=3D{}
- for k in ('delete','isClassProperty','joinSemantic','displayLabel','do=
c'):
+ for k in ('delete','isClassProperty','joinSemantic','displayLabel','do=
c',
+ '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,
>=20
> I have associations where a row of one entity should
> always be related to 1 and only 1 row of another entity,
> like so:
>=20
> model.entities =3D [
> Entity('A', ...),
> Entity('B', ...),
> ]
>=20
> 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'],
> ),
> ]
>=20
> 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?
>=20
> Cheers, mario
|