rquery-activerecord 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rquery-activerecord.rb +6 -2
  2. metadata +1 -1
@@ -24,7 +24,11 @@ module RQuery
24
24
  def where_clause(cmd)
25
25
  ar_statement, clause = ""
26
26
  cmd.each do |key, value|
27
- clause = value.kind_of?(Hash) ? where_key_value(key, value) : "#{self.name.tableize}.#{key} = \"" + value.gsub("'", "\\\\'") + "\""
27
+ if value.kind_of?(Hash)
28
+ clause = where_key_value(key, value)
29
+ else
30
+ clause = value.nil? ? "#{self.name.tableize}.#{key} IS NULL" : "#{self.name.tableize}.#{key} = \"" + value.gsub("'", "\\\\'") + "\""
31
+ end
28
32
  ar_statement += ".where('#{clause}')"
29
33
  end
30
34
  ar_statement
@@ -45,7 +49,7 @@ module RQuery
45
49
  elsif action == "IN" || action == "NOT IN"
46
50
  "#{key} #{action} #{val.gsub("\'", "\"")}"
47
51
  else
48
- "#{key} #{action} \"" + val.to_s + "\""
52
+ val.nil? ? "#{key} #{action} IS NULL" : "#{key} #{action} \"" + (val.gsub("'", "\\\\'")).to_s + "\""
49
53
  end
50
54
  end
51
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rquery-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: