searchlogic 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 2
3
3
  :minor: 5
4
- :patch: 1
4
+ :patch: 2
5
5
  :build:
@@ -159,11 +159,13 @@ module Searchlogic
159
159
  # Kepp in mind that the lambdas get cached in a method, so you want to keep the contents of the lambdas as
160
160
  # fast as possible, which is why I didn't do the case statement inside of the lambda.
161
161
  def scope_options(condition, column, sql, options = {})
162
+ equals = !(condition.to_s =~ /^equals/).nil?
163
+ does_not_equal = !(condition.to_s =~ /^does_not_equal/).nil?
164
+
162
165
  case condition.to_s
163
166
  when /_(any|all)$/
164
167
  any = $1 == "any"
165
168
  join_word = any ? " OR " : " AND "
166
- equals = condition.to_s =~ /^equals_/
167
169
  searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values|
168
170
  unless values.empty?
169
171
  if equals && any
@@ -194,6 +196,12 @@ module Searchlogic
194
196
  searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values|
195
197
  values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
196
198
 
199
+ if does_not_equal && values == [nil]
200
+ sql.gsub!('!=', 'IS NOT')
201
+ elsif equals && values == [nil]
202
+ sql.gsub!('=', 'IS')
203
+ end
204
+
197
205
  {:conditions => [sql, *values]}
198
206
  }
199
207
  end
data/searchlogic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{searchlogic}
8
- s.version = "2.5.1"
8
+ s.version = "2.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Johnson of Binary Logic"]
12
- s.date = %q{2011-03-07}
12
+ s.date = %q{2011-03-08}
13
13
  s.description = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
14
14
  s.email = %q{bjohnson@binarylogic.com}
15
15
  s.extra_rdoc_files = [
@@ -18,7 +18,9 @@ describe Searchlogic::NamedScopes::ColumnConditions do
18
18
  context "comparison conditions" do
19
19
  it "should have equals" do
20
20
  (5..7).each { |age| User.create(:age => age) }
21
+ nil_user = User.create
21
22
  User.age_equals(6).all.should == User.find_all_by_age(6)
23
+ User.age_equals(nil).all.should == User.find_all_by_age(nil)
22
24
  end
23
25
 
24
26
  it "should have does not equal" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: searchlogic
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.5.1
5
+ version: 2.5.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Johnson of Binary Logic
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-07 00:00:00 -05:00
13
+ date: 2011-03-08 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="
106
106
  - !ruby/object:Gem::Version
107
- hash: 3867295679913094834
107
+ hash: -2121447102080969670
108
108
  segments:
109
109
  - 0
110
110
  version: "0"