mirror of
https://github.com/lloeki/rebel.git
synced 2025-12-06 10:04:39 +01:00
review
This commit is contained in:
parent
4ce508862d
commit
52ff7ffd50
3 changed files with 44 additions and 25 deletions
|
|
@ -59,8 +59,8 @@ class TestExec < Minitest::Test
|
|||
insert_into :foo, id: 1, value: '2', col: 'whatevs'
|
||||
insert_into :foo, id: 2, value: '2', col: 'something'
|
||||
insert_into :foo, id: 3, value: '1', col: 'else'
|
||||
assert_equal(select(:id, from: :foo, order_by: :col), [[3], [2], [1]])
|
||||
assert_equal(select(:id, from: :foo, order_by: {id: :desc}), [[3], [2], [1]])
|
||||
assert_equal(select(:id, from: :foo, order_by: [value: :asc, id: :asc]), [[3], [1], [2]])
|
||||
assert_equal(select(:id, from: :foo, order: by(:id).desc), [[3], [2], [1]])
|
||||
assert_equal(select(:id, from: :foo, order: by(:value, :id).asc), [[3], [1], [2]])
|
||||
assert_equal(select(:id, from: :foo, order: by(:value).asc.by(:id).desc), [[3], [2], [1]])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -96,4 +96,18 @@ class TestRaw < Minitest::Test
|
|||
assert_str_equal(Rebel::SQL.value(DateTime.new(2016, 12, 31, 23, 59, 59)), "'2016-12-31T23:59:59+00:00'")
|
||||
assert_str_equal(Rebel::SQL.value(nil), 'NULL')
|
||||
end
|
||||
|
||||
def test_asc
|
||||
assert_str_equal(Rebel::SQL.raw("'FOO'").asc, "'FOO' ASC")
|
||||
end
|
||||
|
||||
def test_desc
|
||||
assert_str_equal(Rebel::SQL.raw("'FOO'").desc, "'FOO' DESC")
|
||||
end
|
||||
|
||||
def test_by
|
||||
assert_str_equal(Rebel::SQL.by(:foo), 'BY "foo"')
|
||||
assert_str_equal(Rebel::SQL.by(:foo).desc, 'BY "foo" DESC')
|
||||
assert_str_equal(Rebel::SQL.by(:foo).desc.by(:bar).asc, 'BY "foo" DESC, "bar" ASC')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue