#1523 new
Johannes

dm-validations bugs with boolean properties

Reported by Johannes | May 16th, 2012 @ 08:36 AM

Hello,
I might found a bug concerning dm-validations and boolean properties.

My system:

  • Mac OS Lion
  • rvm 1.13.4 (stable) by Wayne E. Seguin wayneeseguin@gmail.com, Michal Papis mpapis@gmail.com [https://rvm.io/]
  • ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
  • jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04) [darwin-x86_64-java]
  • sqlite3 3.7.11 2012-03-20 11:35:50 00bb9c9ce4f465e6ac321ced2a9d0062dc364669

Running the attached code produces this error:

$ ruby tester.rb 
 ~ (0.000082) SELECT sqlite_version(*)
 ~ (0.000117) DROP TABLE IF EXISTS "cs"
 ~ (0.000018) PRAGMA table_info("cs")
 ~ (0.000266) CREATE TABLE "cs" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL, "valid" BOOLEAN DEFAULT 't')
 ~ (0.000035) SELECT "id", "name", "valid" FROM "cs" WHERE ("name" = 'test' AND "valid" = 't') ORDER BY "id" LIMIT 1
before save
/Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:218:in `valid?': wrong number of arguments (1 for 0) (ArgumentError)
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:51:in `save_self'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1006:in `block in _save'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1222:in `run_once'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1005:in `_save'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-core-1.2.0/lib/dm-core/resource.rb:405:in `save'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `block in save'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations/context.rb:16:in `in_context'
from /Users/jo/.rvm/gems/ruby-1.9.3-p194@tdqmed.rails/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `save'
from tester.rb:34:in `setup'
from tester.rb:42:in `<main>'

The same error appears running jruby.
It doesn't matter if I specify sqlite:memory or an actual db file. Changing values for DataMapper::Property::Boolean.allow_nil has no impact and other options for the boolean property (:required or :default) don’t help either. Sadly I couldn’t test another database (as my mysql environment is somehow ‘dead’…)

However, if I remove the the lines require 'dm-validations' and validates_uniqueness_of :name the code runs w/o any errors.

-- Johannes

Comments and changes to this ticket

  • Johannes

    Johannes May 16th, 2012 @ 09:19 AM

    … having a property named valid creates some getter and setters. Which in turn stab dm-validation’s valid. :-(

    I rename my property. :-)

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

Pages