[Pharo-project] SandstoneDb + SortedCollections
I am trying to use SandstoneDb to save an Object that contains a SortedCollection, but it fails with the error: "This message is not appropriate for this object". Here is an example code. SDActiveRecord subclass: #User instanceVariableNames: 'sorted name' classVariableNames: '' poolDictionaries: '' category: 'Sandbox' User>>initialize super initialize. sorted := SortedCollection new. name := 'asd' and of course accessors for both of my variables. I type this into a workspace: (User new name: 'david') save. User find: [:u | u name = 'david'] And it works correctly, but this errors with: "This message is not appropriate for this object" | u | u := User new. u name: 'david'. u sorted add: 1. u save What can I do to fix this? David Zmick /dz0004455\
On 12/21/2010 08:51 PM, David Zmick wrote:
I am trying to use SandstoneDb to save an Object that contains a SortedCollection, but it fails with the error: "This message is not appropriate for this object".
Sorted collections contain sort blocks, which aren't serializable with SmartRefStreams, which SandstoneDb is based on.
What can I do to fix this?
You can't. What you can do is store an OrderedCollection and sort them on the fly in your accessor method. -- Ramon Leon http://onsmalltalk.com
On 12/21/2010 08:51 PM, David Zmick wrote:
What can I do to fix this?
Another option might be to use a sort block that isn't a block, but an ordinary object that responds as a sort block would, allowing the collection to be serialized successfully. -- Ramon Leon http://onsmalltalk.com
On Tue, Dec 21, 2010 at 10:31 PM, Ramon Leon <ramon.leon@allresnet.com>wrote:
On 12/21/2010 08:51 PM, David Zmick wrote:
What can I do to fix this?
Another option might be to use a sort block that isn't a block, but an ordinary object that responds as a sort block would, allowing the collection to be serialized successfully.
Another option would be to fix the limitation. There's nothing conceptually preventing serializing a block. It's just an object after all. You have some choices - how do you serialize the home context (you need to serialize every context along the static chain out to the home context)? It should be serialized with a nil sender. - bringing the block back in do you try and hook up the method to the corresponding method in image or leave it anonymous; leave it anonymous. 2¢ Eliot
-- Ramon Leon http://onsmalltalk.com
Alright, thank you! I will just sort in my accessor, that seems to be working pretty well. Thank you for your responses! David Zmick /dz0004455\ On Wed, Dec 22, 2010 at 11:20 AM, Eliot Miranda <eliot.miranda@gmail.com>wrote:
On Tue, Dec 21, 2010 at 10:31 PM, Ramon Leon <ramon.leon@allresnet.com>wrote:
On 12/21/2010 08:51 PM, David Zmick wrote:
What can I do to fix this?
Another option might be to use a sort block that isn't a block, but an ordinary object that responds as a sort block would, allowing the collection to be serialized successfully.
Another option would be to fix the limitation. There's nothing conceptually preventing serializing a block. It's just an object after all. You have some choices - how do you serialize the home context (you need to serialize every context along the static chain out to the home context)? It should be serialized with a nil sender.
- bringing the block back in do you try and hook up the method to the corresponding method in image or leave it anonymous; leave it anonymous.
2¢ Eliot
-- Ramon Leon http://onsmalltalk.com
participants (3)
-
David Zmick -
Eliot Miranda -
Ramon Leon