#924 ✓resolved
Cyril Mougel

We can't made search with false result

Reported by Cyril Mougel | June 26th, 2009 @ 01:10 AM | in 0.10.0

I reproduce a bug in search in boolean field.

this Gist http://gist.github.com/136325 show the bug

require 'rubygems'
 
gem 'addressable', '2.0.1'
gem 'data_objects', '0.10.0'
gem 'do_sqlite3', '0.10.0'
gem 'dm-core', '0.10.0'
require 'dm-core'
 
class Post
  include DataMapper::Resource
 
  def self.default_repository_name
    :post
  end
 
  property :id, Serial
  property :title, String
  property :published, Boolean
end
 
DataMapper.setup(:post, "sqlite3::memory:")
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, 0)
DataMapper.auto_migrate!
 
 
post = Post.create(:title => 'Post 1', :published => true)
post_2 = Post.create(:title => 'Post 2', :published => false)
 
p Post.all(:published => true)
p Post.all(:published => false) # No request made. See result in line 43. but without request before
p Post.all(:published.not => true) # Result same than previous request ? no :(
 
 
# STDOUT
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000076) SELECT sqlite_version(*)
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000111) DROP TABLE IF EXISTS "posts"
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000025) PRAGMA table_info("posts")
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000515) CREATE TABLE "posts" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "title" VARCHAR(50), "published" BOOLEAN)
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000097) INSERT INTO "posts" ("title", "published") VALUES ('Post 1', 't')
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000086) INSERT INTO "posts" ("title", "published") VALUES ('Post 2', 'f')
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000082) SELECT "id", "title", "published" FROM "posts" WHERE "published" = t' ORDER BY "id"
 [#<Post @id=1 @title="Post 1" @published=true>]
 []
 Fri, 26 Jun 2009 06:04:45 GMT ~ debug ~ (0.000082) SELECT "id", "title", "published" FROM "posts" WHERE "published" <> 't' ORDER BY "id"
 [#<Post @id=2 @title="Post 2" @published=false>]

If I search on boolean field the false result, I have no result. I need search not true.

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

Pages