mirror of
https://github.com/lloeki/rebel.git
synced 2025-12-06 10:04:39 +01:00
IN support
This commit is contained in:
parent
22fe1981db
commit
3415cf8ad4
1 changed files with 10 additions and 1 deletions
|
|
@ -192,12 +192,21 @@ module Rebel::SQL
|
||||||
list(clause.map { |k, v| equal(k, v) })
|
list(clause.map { |k, v| equal(k, v) })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clause_term(left, right)
|
||||||
|
case right
|
||||||
|
when Array
|
||||||
|
"#{name(left)} IN (#{values(*right)})"
|
||||||
|
else
|
||||||
|
"#{name(left)} = #{name_or_value(right)}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def and_clause(clause)
|
def and_clause(clause)
|
||||||
return clause if clause.is_a?(Raw) || clause.is_a?(String)
|
return clause if clause.is_a?(Raw) || clause.is_a?(String)
|
||||||
|
|
||||||
clause.map do |e|
|
clause.map do |e|
|
||||||
case e
|
case e
|
||||||
when Array then "#{name(e[0])} = #{name_or_value(e[1])}"
|
when Array then clause_term(e[0], e[1])
|
||||||
when Raw, String then e
|
when Raw, String then e
|
||||||
else fail NotImplementedError, e.class
|
else fail NotImplementedError, e.class
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue