#844 ✓resolved
Ville Jutvik

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"


class Setting
  include DataMapper::Resource

  property :id,           Serial, :key => true

  property :key,          String


# Ok, setup is done. The code below will trigger the actual error                                               
s = Setting.new

# 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

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

Referenced by