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

@ -44,21 +44,21 @@
"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)
(columns character movie_id actor_id)
(values ("Dr. Hasenbein"
(select (columns id) (from movies) (where (= title "Praxis Dr. Hasenbein")))
(select (columns id) (from actors) (where (and (= firstname "Helge")
(= lastname "Schneider")))))))))
(values #("Dr. Hasenbein"
(select (columns id) (from movies) (where (= title "Praxis Dr. Hasenbein")))
(select (columns id) (from actors) (where (and (= firstname "Helge")
(= lastname "Schneider")))))))))
(test "multiple records using vectors for the records"
"INSERT INTO actors (firstname, lastname) VALUES ('Sylvester', 'Stallone'), ('Arnold', 'Schwarzenegger')"
(ssql->sql #f '(insert (into actors)
(columns firstname lastname)
(values ("Sylvester" "Stallone")
("Arnold" "Schwarzenegger")))))
(values #("Sylvester" "Stallone")
#("Arnold" "Schwarzenegger")))))
(test "without explicit columns"
"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 "DELETE FROM actors WHERE (id IN (10, 11, 93))"

Loading…
Cancel
Save