
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
-
Deleted User June 27th, 2009 @ 01:34 AM
This is the same issue as in ticket #927 but for the Boolean type rather than the ParanoidBoolean type.
see the other ticket for further information on why the problem arises.
-
Dan Kubb (dkubb) June 27th, 2009 @ 04:03 AM
- State changed from new to resolved
(from [9d3a1f1a8e63b5d977c211b410bb27735ec82640]) Fixed bug where false was not considered valid for a Boolean property
- Refactored primitive test for values
- Updated boolean typecasting to be more precise
- Added specs for typecasting boolean property values
- Added specs for validating boolean property values
- Added specs for conditions with values that need to be coerced to match the property
[#924 state:resolved] [#927 state:resolved] http://github.com/datamapper/dm-core/commit/9d3a1f1a8e63b5d977c211b...
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
Referenced by
-
927 problem accessing models with ParanoidBoolean attributes this may be the same problem as in ticket #924
-
924 We can't made search with false result [#924 state:resolved] [#927 state:resolved] http://githu...
-
927 problem accessing models with ParanoidBoolean attributes [#924 state:resolved] [#927 state:resolved] http://githu...