railswhere 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/where.rb +10 -2
  2. metadata +3 -3
@@ -180,16 +180,24 @@ protected
180
180
 
181
181
  case criteria
182
182
  when Array # if it's an array, sanitize it
183
- @criteria = ActiveRecord::Base.send(:sanitize_sql_array, criteria)
183
+ @criteria = sanitize_sql_array(criteria)
184
184
  when Hash
185
185
  return nil if criteria.empty?
186
186
  @criteria = criteria.keys.sort_by { |v| v.to_s }.map do |field|
187
- ActiveRecord::Base.send(:sanitize_sql_array, ["#{field} = ?", criteria[field]])
187
+ if criteria[field].nil?
188
+ "#{field} IS NULL"
189
+ else
190
+ sanitize_sql_array(["#{field} = ?", criteria[field]])
191
+ end
188
192
  end.join(' AND ')
189
193
  else
190
194
  @criteria = criteria.to_s # otherwise, run to_s. If it's a recursive Where clause, it will return the sql we need
191
195
  end
192
196
  end
197
+
198
+ def sanitize_sql_array(*args)
199
+ ActiveRecord::Base.send(:sanitize_sql_array, *args)
200
+ end
193
201
 
194
202
  def to_s(omit_conjuction=false) # :nodoc:
195
203
  if omit_conjuction
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railswhere
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tim Harper