#856 ✓resolved
Sindre Aarsaether

Setting a value, is reset / overridden by original value on save

Reported by Sindre Aarsaether | May 18th, 2009 @ 12:22 PM


require 'rubygems'
require 'dm-core'
require 'dm-validations'

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

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

class Person
  include DataMapper::Resource
  
  property :id, Serial
  property :name, String, :length => 255
  property :comment, Text
end

Person.auto_migrate!
Person.create(:name => "John")

r = Person.first
r.name = "Anna"
puts r.save # true
puts r.name # John

http://gist.github.com/113621

Happens on next (dm-core/next + dm-more/next)

It has (somehow) to do with lazy-loaded fields. When setting comment to :lazy => false, the bug dissappears.

Comments and changes to this ticket

  • Sindre Aarsaether

    Sindre Aarsaether May 18th, 2009 @ 01:52 PM

    • Tag changed from 0.10.0, dm-validations, validations to 0.10.0, lazy, lazy_loading

    Seems that this is not related to validations as I first thought.

    dbussink found out that kicking a lazy field will override all changed properties in a resource!

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 18th, 2009 @ 02:07 PM

    • State changed from “unconfirmed” to “confirmed”

    yeah, I managed to track that down too and provide a fix. Unfortunately the fix also broke another spec and I need to discuss with the person who originally wrote it to see if it was the desired behavior or not.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 20th, 2009 @ 10:57 AM

    • Assigned user set to “Dan Kubb (dkubb)”
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 20th, 2009 @ 11:03 AM

    • State changed from “confirmed” to “resolved”

    I can confirm that this is fixed in dm-core/next.

    Marking this ticket as resolved. If this continues to be a problem for you, please let me know and I will re-open 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

Pages