In my quest to write tests to control Magma behaviour, I have found the following problem:
With a magma collection of users object defined as follow:
| users | users := MagmaCollection new. users addIndex: (MaIntegerIndex attribute: #id); addIndex: (MaKeywordIndex attribute: #functions); addIndex: (MaSearchStringIndex attribute: #schoolYear). ^ users
I have problem with the #functions key. functions is instanciated as an empty OrderedCollection. I can update function with #function: message
functions: aCollection (self class functions includesAllOf: aCollection) ifTrue: [IFIDbSession commit: [IFIDbSession noteOldKeyFor: self. functions := aCollection]]
In my test, I can do:
adult functions: #(#teacher). self should: adult functions = #(#teacher).
but the next one got the error (see SqueakLog enclosed)
adult functions: #(#teacher #admin). self should: adult functions = #(#teacher #admin).
If I change the previous test code to: adult functions: #(#director #admin ). self should: adult functions = #(#director #admin ).
It is fine.
It seems the problem appear when two successive changes to functions has common value, here #teacher was in both #(#teacher) and #(#teacher #admin)
Please help!
Replying to myself aswell, casting to 'OrderedCollection' helps a lot.
Hilaire
Le jeudi 07 février 2008 à 15:00 +0100, Hilaire Fernandes a écrit :
In my quest to write tests to control Magma behaviour, I have found the following problem:
With a magma collection of users object defined as follow:
| users | users := MagmaCollection new. users addIndex: (MaIntegerIndex attribute: #id); addIndex: (MaKeywordIndex attribute: #functions); addIndex: (MaSearchStringIndex attribute: #schoolYear). ^ users
I have problem with the #functions key. functions is instanciated as an empty OrderedCollection. I can update function with #function: message
functions: aCollection (self class functions includesAllOf: aCollection) ifTrue: [IFIDbSession commit: [IFIDbSession noteOldKeyFor: self. functions := aCollection]]
In my test, I can do:
adult functions: #(#teacher). self should: adult functions = #(#teacher).
but the next one got the error (see SqueakLog enclosed)
adult functions: #(#teacher #admin). self should: adult functions = #(#teacher #admin).
If I change the previous test code to: adult functions: #(#director #admin ). self should: adult functions = #(#director #admin ).
It is fine.
It seems the problem appear when two successive changes to functions has common value, here #teacher was in both #(#teacher) and #(#teacher #admin)
Please help!
Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
Hilaire, thanks for the report. However, I can't make a determination whether you've identified a bug or not since I can't see what you have for your #functions getter. And there's a lot of other code I don't have the benefit of seeing, so can only pretty much just speculate about the possibilities..
It sounds like you've narrowed the problem down to a reproducible test-case script.
If you can show me how to reproduce the problem, perhaps with a workspace script that adds instances of Association indexed on #key and/or #value, I'd be happy to work on it.
Thanks, Chris
On Feb 7, 2008 9:00 AM, Hilaire Fernandes hilaire@ofset.org wrote:
In my quest to write tests to control Magma behaviour, I have found the following problem:
With a magma collection of users object defined as follow:
| users | users := MagmaCollection new. users addIndex: (MaIntegerIndex attribute: #id); addIndex: (MaKeywordIndex attribute: #functions); addIndex: (MaSearchStringIndex attribute: #schoolYear). ^ users
I have problem with the #functions key. functions is instanciated as an empty OrderedCollection. I can update function with #function: message
functions: aCollection (self class functions includesAllOf: aCollection) ifTrue: [IFIDbSession commit: [IFIDbSession noteOldKeyFor: self. functions := aCollection]]
In my test, I can do:
adult functions: #(#teacher). self should: adult functions = #(#teacher).
but the next one got the error (see SqueakLog enclosed)
adult functions: #(#teacher #admin). self should: adult functions = #(#teacher #admin).
If I change the previous test code to: adult functions: #(#director #admin ). self should: adult functions = #(#director #admin ).
It is fine.
It seems the problem appear when two successive changes to functions has common value, here #teacher was in both #(#teacher) and #(#teacher #admin)
Please help!
Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
magma@lists.squeakfoundation.org