Sebastian > i am currently testing my own adapter to conform to the shared adapter > spec: > > http://github.com/datamapper/dm-core/blob/master/lib/dm-core/spec/sha... > > It currently fails with two tests, because my adapter does return the > queried objects in > random order. Thus i would like to know if i really need to provide > the results in the order > as they have been initially created or if this is a "bug" of the > shared adapter spec? > > it 'should be able to search for object with a nil value using > required properties' do > Heffalump.all(:id.not => nil).should == [ @red, @two, @five ] > end > it 'should be able to search for objects not in an empty list (match > all)' do > Heffalump.all(:color.not => []).should == [ @red, @two, @five ] > end
By default the Query object will have the order set to an Array equivalent to the properties defined in the model. This ensures that results are returned in a deterministic order between all adapters. If results varied between adapters, then client code would have to be aware of the different behaviour of each adapter, which somewhat defeats the purpose of DM. There are helper methods inside the Query object that can sort the resources before returning them from the adapter. Look for the method Query#sort_records for more info. -- Dan -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
