allow inserts without explicit column list

master
Moritz Heidkamp 13 years ago
parent f0b456f288
commit 8307540474

@ -107,14 +107,23 @@
values)
", ")))
((insert (('into table) ('columns columns ...) values ...))
(sprintf "INSERT INTO ~A (~A) VALUES ~A"
table
(string-intersperse (map symbol->string columns) ", ")
((insert into values)
(sprintf "INSERT INTO ~A VALUES ~A"
into
(string-intersperse (map (lambda (val)
(self (car val) (cdr val)))
values) ", ")))
((insert (('into table) ('columns columns ...) values ...))
(self 'insert
(sprintf "~A (~A)"
table
(string-intersperse (map symbol->string columns) ", "))
values))
((insert (('into table) values ...))
(self 'insert table values))
((operator->sql type operator separator operands)
(case type
((infix)

@ -43,7 +43,15 @@
(values "Dr. Hasenbein"
(select (columns id) (from movies) (where (= title "Praxis Dr. Hasenbein")))
(select (columns id) (from actors) (where (and (= firstname "Helge")
(= lastname "Schneider")))))))))
(= lastname "Schneider"))))))))
(test "multiple records"
"INSERT INTO actors (firstname, lastname) VALUES ('Sylvester', 'Stallone'), ('Arnold', 'Schwarzenegger')"
(ssql->sql #f '(insert (into actors) (columns firstname lastname) (values "Sylvester" "Stallone") (values "Arnold" "Schwarzenegger"))))
(test "without explicit columns"
"INSERT INTO actors VALUES ('Marlon', 'Brando')"
(ssql->sql #f '(insert (into actors) (values "Marlon" "Brando")))))
(test-group "syntax"
(test "set literals"

Loading…
Cancel
Save