From d63c4c9063363eed0b2c63c279fba5c7dd75b004 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Tue, 23 Aug 2011 17:11:44 +0200 Subject: [PATCH] turn `values' into a normal prefix operator and require tuples to be given as vectors to reduce special-casing --- ssql.scm | 9 +-------- tests/ansi-test.scm | 14 +++++++------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ssql.scm b/ssql.scm index 3db7b77..a6d259d 100644 --- a/ssql.scm +++ b/ssql.scm @@ -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) diff --git a/tests/ansi-test.scm b/tests/ansi-test.scm index 6584d05..7870f30 100644 --- a/tests/ansi-test.scm +++ b/tests/ansi-test.scm @@ -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))"