whoahbot/dm-redis-adapter — Issue #26: Inheritance
Author: sfeu
Created: 2012-01-31 23:58:40+00:00
State: open

Hey,

i played around with the redis adapter, because i am thinking about changing from a tuplespace (rinda) to redis. But i have trouble with inheritance for queries - like described here: http://datamapper.org/docs/misc.html

So far as i understood the adapter code - I think that the redis adapter does not consider the InclusionComparison correctly in the perform_query function.

Can anyone help me to fix this for the redis adapter?

Attached the spec that shows the problem - it actually only returns Woman (First test) and Mother (second test) but not all of them, which i espected to happed for the first test.

require File.expand_path("../spec_helper", __FILE__)

describe DataMapper::Adapters::RedisAdapter do
before(:all) do
@adapter = DataMapper.setup(:default, {
:adapter => "redis",
:db => 15
})
@repository = DataMapper.repository(@adapter.name)
@redis = Redis.new(:db => 15)
end
describe 'Inheritance' do

before :all do

class Person
include DataMapper::Resource

property :name, String
property :job, String, :length => 1..255
property :type, Discriminator
property :id, Serial
end

class Male < Person; end
class Father < Male; end
class Son < Male; end

class Woman < Person; end
class Mother < Woman; end
class Daughter < Woman; end
DataMapper.finalize
end

it 'should select all women, mothers, and daughters' do
w = Woman.create(:name => "woman")
m = Mother.create(:name => "mother")
d = Daughter.create(:name => "daughter")

p Woman.all
Woman.all.should==[w,m,d]

end

it 'should select all mothers and daughters' do
w = Woman.create(:name => "woman")
m = Mother.create(:name => "mother")
d = Daughter.create(:name => "daughter")

p Mother.all
Mother.all.should==[m,d]
end

end
after(:each) do
@redis.flushdb
end
end