Bug in MagmaCollectionReader size ?

Chris Muller asqueaker at gmail.com
Tue Aug 21 04:22:44 UTC 2007


Hi Florian,

Man oh man, you reported this just in time.  I had just posted gamma1
thinking it was totally clean and then you go and dig up this corner
case, thank you!

The case occurs when the non-persistent addition is the highest key
and accessed from a sorted reader.  I have just posted r40Gamma2 which
fixes this.

The code you provided me helped a lot, but it still was a game of
interpretation.  Please, in the future, the easiest way for us to have
clarity is with a mutual script we can both run verbatim.  Here is
what I came up with based on your description:

| s reader path|
path := 'c:\temp\florianBug1'.
MagmaRepositoryController create: path root: (MagmaCollection new
	addIndex: (MaIntegerIndex attribute: #key) ;
	yourself).
s := MagmaSession openLocal: path.
s connectAs: 'test'.
s inspect.
s begin.
{1. 2} do: [ : n | s root add: n->n printString ].
s commitAndBegin.
reader := s root read: #key descending: false.
s root add: 3->'three'.
self assert: reader size = reader collection asArray size

This was not hard to write at all, and so I would like to request
everyone please, if possible, submit bug reports in terms of a
reproducible script isolated only within the context of Magma that we
can all work directly from.  I realize this may not always be possible
but, when it is, it is easier.  Juan had even gone further and sent me
a Monticello package with classes.  This provided a very common basis
for our communication.  Thanks for your understanding.

Regards,
  Chris

On 8/20/07, Florian Minjat <florian.minjat at gmail.com> wrote:
> Hi,
>    I was toying around with the last beta version of magma in order to
> have all my tests green.
>    And I think I found a bug in MagmaCollectionReader : if you add an
> element in a MagmaCollection without commit, sending the size message
> to the collection will count this non-committed element. But if you
> send the size message to a MagmaCollectionReader, it will not.
>    Or it's a feature ?
>
>    Here is the code of the test :
>
>         session begin
>         session root news add: un.
>         session root news add: deux.
>         session commitAndBegin.
>
>         coll := (session root news read: #id descending: false).
>         self assert: (coll size = coll collection asArray size). '=>
> assertion ok'
>
>         "add without commit"
>         session root add: trois inCollection: #news.
>
>         coll := (session root news read: #id descending: false).
>         self assert: (coll size = coll collection asArray size). '=>
> assertion fails'
>
> Florian
> _______________________________________________
> Magma mailing list
> Magma at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
>


More information about the Magma mailing list