Marijn Haverbeke marijnh@gmail.com writes:
It seems the TRUNCATE¹ operation is missing, would it be possible to add it to postmodern?
You could, and I'd welcome such a patch. But since it's a rather simple command, you can also just use a string to issue it.
I tries the following:
(def-sql-op :truncate (&rest args) (split-on-keywords ((tables *) (only - ?) (identity - ?) (fkey - ?)) (cons :tables args) (let ((identity-str (case identity (:restart-identity "RESTART IDENTITY ") (:continue-identity "CONTINUE IDENTITY "))) (fkey-str (case fkey (:cascade "CASCADE ") (:restrict "RESTRICT ")))) `("(TRUNCATE " ,@(when only '("ONLY ")) ,@(sql-expand-list tables) ,@(when identity identity-str) ,@(when fkey fkey-str) ")"))))
But SPLIT-ON-KEYWORDS doesn't work as I thought (doesn't seem to like several optional keywords without arguments).
Would you have a suggestion on how to fix this ?
I'm also not sure about how to have the :only keyword before the tables so that it matches the order in the SQL command.
Regards,