use test-group
parent
c8a5172bcd
commit
e5ce524449
@ -1,30 +1,28 @@
|
|||||||
(use test)
|
(use test)
|
||||||
(import ssql)
|
(import ssql)
|
||||||
|
|
||||||
(test-begin "selects")
|
(test-group "selects"
|
||||||
(test "Simple query"
|
(test "Simple query"
|
||||||
"SELECT actors.firstname, actors.lastname FROM actors"
|
"SELECT actors.firstname, actors.lastname FROM actors"
|
||||||
(ssql->sql #f `(select (columns actors.firstname actors.lastname)
|
(ssql->sql #f `(select (columns actors.firstname actors.lastname)
|
||||||
(from actors))))
|
(from actors))))
|
||||||
(test "Many columns"
|
(test "Many columns"
|
||||||
"SELECT actors.id, actors.firstname, actors.lastname, roles.character, roles.movie_id AS movie FROM actors, roles"
|
"SELECT actors.id, actors.firstname, actors.lastname, roles.character, roles.movie_id AS movie FROM actors, roles"
|
||||||
(ssql->sql #f `(select (columns (col actors id firstname lastname) (col roles character (as movie_id movie)))
|
(ssql->sql #f `(select (columns (col actors id firstname lastname) (col roles character (as movie_id movie)))
|
||||||
(from actors roles))))
|
(from actors roles))))
|
||||||
(test "Joined query"
|
(test "Joined query"
|
||||||
(string-append
|
(string-append
|
||||||
"SELECT actors.firstname, actors.lastname, roles.character, movies.title "
|
"SELECT actors.firstname, actors.lastname, roles.character, movies.title "
|
||||||
|
|
||||||
"FROM ((actors LEFT JOIN roles ON (roles.actor_id = actors.id)) "
|
"FROM ((actors LEFT JOIN roles ON (roles.actor_id = actors.id)) "
|
||||||
"LEFT JOIN movies ON (movies.id = roles.movie_id))")
|
"LEFT JOIN movies ON (movies.id = roles.movie_id))")
|
||||||
(ssql->sql #f `(select (columns actors.firstname actors.lastname roles.character movies.title)
|
(ssql->sql #f `(select (columns actors.firstname actors.lastname roles.character movies.title)
|
||||||
(from (join left
|
(from (join left
|
||||||
(join left actors roles
|
(join left actors roles
|
||||||
(on (= roles.actor_id actors.id)))
|
(on (= roles.actor_id actors.id)))
|
||||||
movies
|
movies
|
||||||
(on (= movies.id roles.movie_id)))))))
|
(on (= movies.id roles.movie_id)))))))
|
||||||
|
|
||||||
(test "Order"
|
(test "Order"
|
||||||
"SELECT lastname, firstname FROM people ORDER BY lastname DESC, firstname"
|
"SELECT lastname, firstname FROM people ORDER BY lastname DESC, firstname"
|
||||||
(ssql->sql #f '(select (columns lastname firstname) (from people) (order (desc lastname) firstname))))
|
(ssql->sql #f '(select (columns lastname firstname) (from people) (order (desc lastname) firstname)))))
|
||||||
|
|
||||||
(test-end "selects")
|
|
||||||
|
Loading…
Reference in New Issue