turn `values' into a normal prefix operator and require tuples to be given as vectors to reduce special-casing

master
Moritz Heidkamp 13 years ago
parent 25e5e8b98b
commit d63c4c9063

@ -66,14 +66,6 @@
list) list)
", "))) ", ")))
((values records)
(sprintf "VALUES ~A"
(string-intersperse
(map (lambda (record)
(self 'list->sql-tuple record))
records)
", ")))
((vector->sql vec) ((vector->sql vec)
(self 'list->sql-tuple (vector->list vec))) (self 'list->sql-tuple (vector->list vec)))
@ -214,6 +206,7 @@
(update prefix*) (update prefix*)
(delete prefix*) (delete prefix*)
(from prefix "FROM" ", ") (from prefix "FROM" ", ")
(values prefix "VALUES" ", ")
(where prefix) (where prefix)
(order prefix "ORDER BY" ", ") (order prefix "ORDER BY" ", ")
(having prefix) (having prefix)

@ -44,7 +44,7 @@
"INSERT INTO roles (character, movie_id, actor_id) VALUES ('Dr. Hasenbein', (SELECT id FROM movies WHERE (title = 'Praxis Dr. Hasenbein')), (SELECT id FROM actors WHERE ((firstname = 'Helge') AND (lastname = 'Schneider'))))" "INSERT INTO roles (character, movie_id, actor_id) VALUES ('Dr. Hasenbein', (SELECT id FROM movies WHERE (title = 'Praxis Dr. Hasenbein')), (SELECT id FROM actors WHERE ((firstname = 'Helge') AND (lastname = 'Schneider'))))"
(ssql->sql #f '(insert (into roles) (ssql->sql #f '(insert (into roles)
(columns character movie_id actor_id) (columns character movie_id actor_id)
(values ("Dr. Hasenbein" (values #("Dr. Hasenbein"
(select (columns id) (from movies) (where (= title "Praxis Dr. Hasenbein"))) (select (columns id) (from movies) (where (= title "Praxis Dr. Hasenbein")))
(select (columns id) (from actors) (where (and (= firstname "Helge") (select (columns id) (from actors) (where (and (= firstname "Helge")
(= lastname "Schneider"))))))))) (= lastname "Schneider")))))))))
@ -53,12 +53,12 @@
"INSERT INTO actors (firstname, lastname) VALUES ('Sylvester', 'Stallone'), ('Arnold', 'Schwarzenegger')" "INSERT INTO actors (firstname, lastname) VALUES ('Sylvester', 'Stallone'), ('Arnold', 'Schwarzenegger')"
(ssql->sql #f '(insert (into actors) (ssql->sql #f '(insert (into actors)
(columns firstname lastname) (columns firstname lastname)
(values ("Sylvester" "Stallone") (values #("Sylvester" "Stallone")
("Arnold" "Schwarzenegger"))))) #("Arnold" "Schwarzenegger")))))
(test "without explicit columns" (test "without explicit columns"
"INSERT INTO actors VALUES ('Marlon', 'Brando')" "INSERT INTO actors VALUES ('Marlon', 'Brando')"
(ssql->sql #f '(insert (into actors) (values ("Marlon" "Brando")))))) (ssql->sql #f '(insert (into actors) (values #("Marlon" "Brando"))))))
(test-group "deletes" (test-group "deletes"
(test "DELETE FROM actors WHERE (id IN (10, 11, 93))" (test "DELETE FROM actors WHERE (id IN (10, 11, 93))"

Loading…
Cancel
Save