fix join without clause

This commit is contained in:
Loic Nageleisen 2017-03-01 17:02:19 +01:00
parent 2c727a38cb
commit d3ba98ab1b
2 changed files with 5 additions and 1 deletions

View file

@ -78,7 +78,7 @@ module Rebel::SQL
end end
def on?(*clause) def on?(*clause)
clause ? on(clause) : self clause.any? ? on(clause) : self
end end
def and(*clause) def and(*clause)

View file

@ -58,4 +58,8 @@ class TestRaw < Minitest::Test
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') 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')
assert_str_equal(Rebel::SQL.where?(Rebel::SQL.name(:foo).eq(1).or(Rebel::SQL.name(:bar).eq(2))), 'WHERE "foo" = 1 OR "bar" = 2') assert_str_equal(Rebel::SQL.where?(Rebel::SQL.name(:foo).eq(1).or(Rebel::SQL.name(:bar).eq(2))), 'WHERE "foo" = 1 OR "bar" = 2')
end end
def test_join
assert_str_equal(Rebel::SQL.join(:foo), 'JOIN "foo"')
end
end end