Hacker News new | ask | show | jobs
by emidln 1641 days ago
This is a good use case for an AST-based query compiler which would allow construction of clauses in arbitrary order. Using HoneySQL in Clojure, I frequently would write:

  (-> (from [:cities :c])
      (join [:population :c] [:= :c.name :p.city-name])
      (select :c.name :c.pizza-rank :p.population)
      (order-by [:c.pizza-rank :asc]))
It's handy for a lot of reasons, but unless I had mostly static queries (changing just some where clause params), I would always seek out a AST library rather than attempt string building for a SQL use case.