Exclusive collection deletes

7 views
Skip to first unread message

Esteban Maringolo

unread,
Nov 18, 2020, 11:02:21 AM11/18/20
to GLORP Mailing List
Hi,

I'm having an issue with elements added to a collection that is part
of an exclusive mapping that are always deleted.

I have a GwTournament that has a collection of aGwTournamentCategory,
but when I add a category to this collection, at the moment of
committing the unit of work the row is marked for deletion.

Getting into `UnitOfWork>>computeCollectionDeletesFor: aMapping
inObject: anObject` I notice that the memento and the object memento
are the same object, and so is the the value read using the mapping.

This causes all elements to be removed when the UOW is committed, I
don't know why this is so.

aDescriptor toManyMapping
attributeName: #categories;
referenceClass: GwTournamentCategory;
collectionType: SortedCollection;
orderBy: [ :each | (each getTable: 'GWTOURNAMENTCATEGORY') getField:
'position' ];
beExclusive;
join:
(Join
from: (table fieldNamed: 'id')
to: ((self tableNamed: 'GWTOURNAMENTCATEGORY') fieldNamed:
'tournament_id')).

If I remove the "beExclusive" then this doesn't happen anymore but it
causes the opposite situation: for some reason the elements are
removed from the collection, but never deleted from the DB, and new
elements are added each time.

Regards!

Esteban A. Maringolo

Esteban Maringolo

unread,
Nov 18, 2020, 11:29:15 AM11/18/20
to GLORP Mailing List
Hi,

Answering myself, I noticed that in Pharo's SortedCollection, the
elements are inside another collection, so a #removeAll replaces this
internal collection by another, empty, one. For some reason this might
mess with something, but replacing the collection to be an
OrderedCollection solved the issue.

Regards!

Esteban A. Maringolo

Alan Knight

unread,
Nov 18, 2020, 11:44:54 AM11/18/20
to glorp...@googlegroups.com
Ah, that makes sense. There's dialect-specific code to deal with different collection representations, but it probably never got done for Pharo SortedCollection.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glorp-group...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/CAJMgPC%2BU-B-vHuBMzEbx7Awf0X7swKd5YmkbT5_nCj3hJ5xR-w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages