
Datamapper 0.9.11 crashes when using "key" as property name
Reported by Ville Jutvik | May 6th, 2009 @ 11:20 AM | in 1.0.0
I've been using Datamapper (with great success) for the last 6 months, but today I ran into trouble. DM crashes when you create a property with the name "key", saves it, and then performs an update (the second .save()). The code below reproduces the problem. I can understand if a property with the name "key" clashes with DMs internal namespace, but Datamapper::Resource should throw an error upon class creation if that's the case.
I was using ruby 1.8.5, postgres 8.3, DM 0.9.11, debian etch
require "rubygems"
require "dm-core"
def dmSetup
DataMapper.setup(:default, {
:host => "localhost",
:adapter => "postgres",
:database => "lt",
:username => "oss",
:password => "SECRET"
})
DataMapper.auto_migrate!
end
class Setting
include DataMapper::Resource
property :id, Serial, :key => true
property :key, String
end
dmSetup
# Ok, setup is done. The code below will trigger the actual error
s = Setting.new
s.save
# Insertion done. Now, try to update (and watch the crash)
s.key = "hjasd"
s.save # Crash! (TypeError at dm-core/model.rb:394)
Comments and changes to this ticket
-
Dan Kubb (dkubb) June 16th, 2009 @ 03:41 AM
- Assigned user set to Dan Kubb (dkubb)
- State changed from unconfirmed to accepted
- Milestone set to 0.10.1
-
Dan Kubb (dkubb) October 4th, 2009 @ 09:33 PM
- Milestone changed from 0.10.1 to 0.10.2
[project:id#20609 not-tagged:"0.10.0" not-tagged:"0.10.1" milestone:id#51895 bulk edit command]
-
Dan Kubb (dkubb) February 1st, 2010 @ 04:33 PM
- Milestone changed from 0.10.2 to 1.0.0
-
-
-
Dan Kubb (dkubb) February 2nd, 2010 @ 02:47 AM
- State changed from accepted to confirmed
-
Dan Kubb (dkubb) February 2nd, 2010 @ 04:22 AM
- Milestone set to 1.0.0
- Tag changed from 0.9.11, dm-core, property, property_set to dm-core, property, property_set
- State changed from confirmed to accepted
- Assigned user set to Dan Kubb (dkubb)
This problem also affects people using DM 0.10.
What should happen is when a property or relationship is defined that matches a reversed method name in Model or Resource, the system should raise an exception.
-
Dan Kubb (dkubb) February 3rd, 2010 @ 03:22 AM
- State changed from accepted to resolved
(from [121d3377251de38d21a0262d8bf688ee3b4bda82]) Added spec to ensure Model#property raises an exception with a reserved name
[#844 state:resolved] http://github.com/datamapper/dm-core/commit/121d3377251de38d21a0262...
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.
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
Tags
Referenced by
-
1088 "can't convert String into Array" error in a very simple model I'm marking this a duplicate of #844 which is due to be f...
-
844 Datamapper 0.9.11 crashes when using "key" as property name [#844 state:resolved] http://github.com/datamapper/dm-co...