mirror of
https://github.com/lloeki/rebel.git
synced 2025-12-06 01:54:40 +01:00
add LIKE
This commit is contained in:
parent
3c2d41788c
commit
06ff4227af
2 changed files with 8 additions and 0 deletions
|
|
@ -137,6 +137,10 @@ module Rebel::SQL
|
|||
def in(*v)
|
||||
Raw.new("#{self} IN (#{Rebel::SQL.values(*v)})")
|
||||
end
|
||||
|
||||
def like(n)
|
||||
Raw.new("#{self} LIKE #{Rebel::SQL.value(n)}")
|
||||
end
|
||||
end
|
||||
|
||||
@identifier_quote = '"'
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ class TestRaw < Minitest::Test
|
|||
assert_str_equal(Rebel::SQL.name(:foo).in(1, 2, 3), '"foo" IN (1, 2, 3)')
|
||||
end
|
||||
|
||||
def test_like
|
||||
assert_str_equal(Rebel::SQL.name(:foo).like('%bar%'), %("foo" LIKE '%bar%'))
|
||||
end
|
||||
|
||||
def test_where
|
||||
assert_str_equal(Rebel::SQL.where?(foo: 1, bar: 2, baz: 3), 'WHERE "foo" = 1 AND "bar" = 2 AND "baz" = 3')
|
||||
assert_str_equal(Rebel::SQL.where?(Rebel::SQL.name(:foo).eq(1).or(Rebel::SQL.name(:bar).eq(2)), Rebel::SQL.name(:baz).eq(3)), 'WHERE ("foo" = 1 OR "bar" = 2) AND "baz" = 3')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue