#1125 suggestion
JHStatewide

Associations not working properly with YAML adapter

Reported by JHStatewide | November 15th, 2009 @ 01:16 PM

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:

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) November 16th, 2009 @ 12:50 AM

    • State changed from “new” to “suggestion”
    • Tag changed from 0.10.1, associations, yaml to 0.10.1, associations, yaml

    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.

  • Piotr Solnica (solnic)

    Piotr Solnica (solnic) May 17th, 2011 @ 02:32 AM

    • Tag changed from 0.10.1, associations, yaml to 0.10.1, associations, dm-yaml-adapter, yaml
    • Milestone order changed from “0” to “0”

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages