PathQL server: safe SQL to JSON
In an earlier post I introduced PathQL: write a SQL query, get nested JSON back, with the structure inferred from table aliases and foreign keys. That post ended with a one-liner: “You may even want to set up a PathQL server.” This is the follow-up about that server, because the moment you turn PathQL into an HTTP endpoint you run into an uncomfortable question. A PathQL server accepts arbitrary SQL. That is the whole point: the caller sends SQL, the server runs it and shapes the result. But if you put that on a network with a single shared connection and no guards, you have handed the world a SQL console. It turned out that shaping SQL results in nested JSON was the easy part. The hard part was properly limiting the SQL you are allowed to execute. ...