Add support for SELECT without FROM

This commit is contained in:
Loic Nageleisen 2017-11-21 11:14:45 +01:00
parent 818da9047a
commit a3712ceefd
2 changed files with 10 additions and 1 deletions

View file

@ -105,6 +105,10 @@ class TestRaw < Minitest::Test
assert_str_equal(Rebel::SQL.select(Rebel::SQL.raw('*'), from: Rebel::SQL.name(:foo)).gsub(/\s+/, ' ').strip, 'SELECT * FROM "foo"')
end
def test_select_without_from
assert_str_equal(Rebel::SQL.select(Rebel::SQL.raw('1')).strip, 'SELECT 1')
end
def test_nested_select
assert_str_equal(Rebel::SQL.select(Rebel::SQL.raw('*'), from: Rebel::SQL.name(:foo), where: Rebel::SQL.name(:bar).in(Rebel::SQL.select(Rebel::SQL.name(:bar), from: Rebel::SQL.name(:foo)))).gsub(/\s+/, ' ').strip, 'SELECT * FROM "foo" WHERE "bar" IN ( SELECT "bar" FROM "foo" )')
end