#858 ✓resolved
Sindre Aarsaether

Accessing has 1-relationship results in stacklevel too deep

Reported by Sindre Aarsaether | May 22nd, 2009 @ 09:30 AM

Example:


require 'rubygems'
require 'dm-core'

DataMapper.setup(:default,
  :adapter => 'mysql',
  :host => 'localhost', 
  :username => 'root',
  :database => 'dm_core_test',
  :encoding => 'utf8'
)

DataObjects::Mysql.logger = DataObjects::Logger.new(STDOUT, :debug)

class User
  include DataMapper::Resource

  property :id, Serial
  property :login, String #, :writer => :private
  property :name, String, :length => 255

  has 1, :account, :active => true
end

class Account
  include DataMapper::Resource
  property :id, Serial
  property :active, Boolean
  
  belongs_to :user
end


User.auto_migrate!
Account.auto_migrate!

u = User.create(:name => "somebee")
u2 = User.create(:name => "somebee2")
u3 = User.create(:name => "somebee3")

Account.create(:user => u)
Account.create(:user => u, :active => true)

puts User.all.first.account
# => stack level too deep

Comments and changes to this ticket

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 »

People watching this ticket

Attachments

Referenced by

Pages