ruricolist / cl-yesql

Common Lisp library for using SQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate SETF functions

phoe opened this issue · comments

Yet another random idea. Let's imagine a query like:

-- name: (setf activated) @execute
-- Activates or deactivates the player with the provided ID.
UPDATE player SET activatedp = ?
    WHERE player_id = ?;

The order of query arguments matches the order of arguments for a SETF writer. Therefore it would be possible to write (setf (activated player-id) activatedp) instead of (set-activated activated-p player-id) where the SETF option feels much more lispy for me.

The downside of this approach is that it breaks the simplicity of the YESQL interface where each function is simple and dumb. It might be preferable to keep it this way in order to avoid trouble and bugs.

I revisited this old codebase today and the first thing I thought was, "damn, it would be good if this thing was able to generate SETF functions".

And I came here, and I was like, hey, I wrote this issue a year ago. And, hey, the reasons I have right now are the same as the reasons I had a year ago.