Skip to content

The project+ fn #87

@r0man

Description

@r0man

Sometimes I want to add artificial fields to a query but can't
use project, because it overwrites previous selections. What
about adding something like:

(defn project+
  [relation fields]
  (assoc relation :tcols (concat (:tcols relation) fields)))

to ClojureQL? With this function I can add a "distance
calculation" to the query with something like this:

(-> spots-with-address
    (select-in-bounding-box :spots.location bounding-box)
    (project+ [[(str "distance(spots.location, ST_GeomFromText('" (make-point-2d 0 0) "'))") :as :distance]])
    (sort [:distance]))

Thoughts? Suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions