
default_scope.update(:order => nil) and calling Model.last raises an exception.
Reported by Postmodern | September 11th, 2010 @ 01:28 AM | in 1.1
I tried to disable all ordering on a Model who's primary key is a String. I tried to do this by using default_scope.
class SchemaMigration
include DataMapper::Resource
storage_names[:default] = 'schema_migrations'
default_scope.update(:order => nil)
property :version, String, :key => true
end
When I called SchemaMigration.last, I got this exception:
NoMethodError: undefined method `map!' for nil:NilClass
from /home/hal/.rvm/gems/ruby-1.9.2-p0/gems/dm-core-1.0.2/lib/dm-core/query.rb:327:in `reverse!'
from /home/hal/.rvm/gems/ruby-1.9.2-p0/gems/dm-core-1.0.2/lib/dm-core/model.rb:410:in `last'
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) October 29th, 2010 @ 03:37 PM
- State changed from new to confirmed
- Milestone set to 1.1
- Assigned user cleared.
- Milestone order changed from 196221 to 0
Confirmed, reproducible standalone at http://pastie.org/1258851
-
Piotr Solnica (solnic) November 1st, 2010 @ 01:02 PM
Can we finally make default_scope a part of the public API? It's still semipublic and there are known issues (like that one or problems with STI)
-
Piotr Solnica (solnic) November 1st, 2010 @ 04:15 PM
- Assigned user set to Piotr Solnica (solnic)
-
Piotr Solnica (solnic) November 4th, 2010 @ 05:17 AM
- State changed from confirmed to not-applicable
So...since the default_scope is still not a public API this ticket is not-applicable. As a work-around you can simply do default_scope.update(:order => []) and it should work. Once we make default_scope public we will provide proper option validations.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »