Skip to content

Commit

Permalink
Fixed rubyforge bug #11294 which didn't allow boolean searches to work.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/arext/trunk@116 5128a5ed-121c-0410-8d5c-98af306bc9be
  • Loading branch information
zachdennis committed Aug 12, 2007
1 parent 12162da commit 25b0dec
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions ar-extensions/db/migrate/generic_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
t.column :updated_at, :time
t.column :updated_on, :datetime
t.column :topic_id, :integer
t.column :for_sale, :boolean, :default => true
end

create_table :languages, :force=>true do |t|
Expand Down
1 change: 1 addition & 0 deletions ar-extensions/db/migrate/mysql_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
t.column :updated_at, :datetime
t.column :updated_on, :datetime
t.column :topic_id, :integer
t.column :for_sale, :boolean, :default => true
end
execute "ALTER TABLE books ADD FULLTEXT( `title`, `publisher`, `author_name` )"

Expand Down
2 changes: 1 addition & 1 deletion ar-extensions/db/migrate/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SchemaInfo < ActiveRecord::Base
set_table_name 'schema_info'
VERSION = 8
VERSION = 10
end
4 changes: 2 additions & 2 deletions ar-extensions/lib/ar-extensions/finders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def sanitize_sql_from_hash( hsh ) #:nodoc:
sql = nil
result = ActiveRecord::Extensions.process( key, val, self )
if result
conditions << result.sql if result.sql
values.push( result.value ) if result.value
conditions << result.sql
values.push( result.value )
else
conditions << "#{table_name}.#{connection.quote_column_name(key.to_s)} #{attribute_condition( val )} "
values << val
Expand Down
1 change: 1 addition & 0 deletions ar-extensions/tests/fixtures/books.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ second:
title: "The Voyage of Jerle Shannara: Ilse Witch"
publisher: Del Rey
author_name: Terry Brooks
for_sale: false
third:
id: 3
title: "The Voyage of Jerle Shannara: Jarka Ruus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ second:
publisher: Del Rey
author_name: Terry Brooks
created_at: 2007-01-10 21:20:00
for_sale: false
third:
id: 3
title: "The Voyage of Jerle Shannara: Jarka Ruus"
Expand Down
7 changes: 6 additions & 1 deletion ar-extensions/tests/test_finders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,12 @@ def to_sql( caller )
end

def test_find_should_not_break_proper_string_escapes
assert Book.find_or_create_by_title_and_publisher_and_author_name( "Book1%20Something", "Publisher%20", "%20Author%20" );
assert Book.find_or_create_by_title_and_publisher_and_author_name( "Book1%20Something", "Publisher%20", "%20Author%20" )
end

def test_find_should_not_break_boolean_searches
record = Book.find_by_author_name_and_for_sale('Terry Brooks', false)
assert_equal books(:second), record, "wrong record"
end

end

0 comments on commit 25b0dec

Please sign in to comment.