datamapper / dm-yaml-adapter

A YAML Adapter for DataMapper
http://datamapper.org/
MIT License
18 stars 7 forks source link

Associations not working properly with YAML adapter #2

Open solnic opened 13 years ago

solnic commented 13 years ago

Anonymous associations don't seem to be working properly with the YAML adapter.

require 'rubygems' require 'dm-core' DataMapper.setup(:default, "yaml:db")

class Burger include DataMapper::Resource

    property :id, Serial
    property :name, String, :length => 1..65535
    has n, :toppings, :through => Resource, :model => "Condiment"
    has n, :extras, :through => Resource, :model => "Condiment"
    def to_s
            self.name
    end

end

class Condiment include DataMapper::Resource

    property :id, Serial
    property :name, String, :length => 1..65535
    def to_s
            self.name
    end

end

burger = Burger.create(:name => "Double Cheeseburger")

cheese = Condiment.create(:name => "Cheese")

burger.toppings << cheese burger.extras << Condiment.create(:name => 'Bacon') burger.save

puts "burger toppings: #{burger.toppings}" puts "burger extras: #{burger.extras}" burger.reload puts "burger toppings: #{burger.toppings}" puts "burger extras: #{burger.extras}"

josh@phenom:~/test$ ruby problem.rb burger toppings: Cheese burger extras: Bacon burger toppings: burger extras:


Created by JHStatewide - 2009-11-15 19:16:08 UTC

Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/1125

solnic commented 13 years ago

The YAML and In-Memory adapters (which share the same query logic) do not work with many to many relationships yet.

This is something I am deeply aware of, and am planning to resolve within the next month or so.

by Dan Kubb (dkubb)

pvdb commented 12 years ago

:+1: for getting this resolved in the next month or so :smirk:

emilesilvis commented 11 years ago

I assume (from experimentation and the comment above) that this issue has been resolved. Is this correct?