mirror of
https://github.com/lloeki/rebel.git
synced 2025-12-06 10:04:39 +01:00
Add support for LIMIT and OFFSET
This commit is contained in:
parent
adfa38baea
commit
6c4b435ae6
2 changed files with 18 additions and 3 deletions
|
|
@ -117,6 +117,14 @@ class TestRaw < Minitest::Test
|
|||
assert_str_equal(Rebel::SQL.select(distinct: [:bar, :baz], from: :foo).gsub(/\s+/, ' ').strip, 'SELECT DISTINCT "bar", "baz" FROM "foo"')
|
||||
end
|
||||
|
||||
def test_select_limit
|
||||
assert_str_equal(Rebel::SQL.select(:bar, from: :foo, limit: 10).gsub(/\s+/, ' ').strip, 'SELECT "bar" FROM "foo" LIMIT 10')
|
||||
end
|
||||
|
||||
def test_select_offset
|
||||
assert_str_equal(Rebel::SQL.select(:bar, from: :foo, limit: 10, offset: 20).gsub(/\s+/, ' ').strip, 'SELECT "bar" FROM "foo" LIMIT 10 OFFSET 20')
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue