
exclusive ranges should respected
Reported by Alex Arnell | September 11th, 2008 @ 03:15 PM
ActiveRecord had this problem too. When you specify a range, it
would blindly use some kind of `property` BETWEEN ? and
?
query.
DataMapper should be able to tell the difference between inclusive and exclusive ranges.
require 'rubygems'
require 'dm-core'
# An in-memory Sqlite3 connection:
DataMapper.setup(:default, 'sqlite3::memory:')
class Category
include DataMapper::Resource
property :id, Integer, :serial => true
property :name, String
end
DataMapper.auto_migrate!
(1..10).each do |i|
Category.create(:id => i, :name => "category #{i}")
end
retval = Category.all(:id => 2..5)
puts 'size:', retval.size #=> should be 4
puts 'ids', retval.map { |c| c.id }.inspect #> should be [2, 3, 4, 5]
retval = Category.all(:id => 2...5)
puts 'size:', retval.size #=> should be 3
puts 'ids', retval.map { |c| c.id }.inspect #> should be [2, 3, 4]
I have attached a patch adjusting the specs to assert this behavior. I would fix the issue myself, but I'm not sure where the query conditions are transformed. I tracked it a little and from what I can tell it happens at the adapter level.
Comments and changes to this ticket
-
Dan Kubb (dkubb) January 7th, 2009 @ 04:23 PM
- State changed from new to unconfirmed
- Assigned user cleared.
More information available in #709
-
Dan Kubb (dkubb) January 7th, 2009 @ 04:23 PM
- State changed from unconfirmed to accepted
- Assigned user set to Dan Kubb (dkubb)
-
Dan Kubb (dkubb) January 7th, 2009 @ 10:04 PM
- State changed from accepted to resolved
This is resolved in:
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 »