LauJensen / clojureql

ClojureQL is superior SQL integration for Clojure
https://clojureql.sabrecms.com
Eclipse Public License 1.0
285 stars 39 forks source link

project - rename syntax should allow strings on select side #44

Closed bendlas closed 13 years ago

bendlas commented 13 years ago

(project (table :t) [["db-func(x, '\"')" :as :x]])

produces an error

bendlas commented 13 years ago

on a related note; do you think it would be worthwhile to have a compiler protocol here? Like (project tbl sql-expr-vec) would take instances of

(protocol RelationField
  "e.g. http://www.postgresql.org/docs/8.4/static/sql-expressions.html"
  (projected-name [this] "a keyword (?)")
  (selectable-field-str [this] "sequence of compiled SQL string bits"))

struck me while porting

SELECT node_id,
        (CASE WHEN type='container' THEN ...
                   WHEN type='customer' THEN ... END)  FROM ...
bendlas commented 13 years ago

FIX https://github.com/bendlas/clojureql/commit/32a8f6afd8a8f15fd02d413370e379e2b1b3442b https://github.com/bendlas/clojureql/commit/81a88dd294a4f4f28586070a98455e16037d44b0

LauJensen commented 13 years ago

Thanks a lot for bring this up Bendlas. I wasn't quite sure what to make of your fix since every line in a complicate tree was changed, does this look okay?

FIX: https://github.com/LauJensen/clojureql/commit/2285a7bb9c78b211082064c58394e141c8619512

bendlas commented 13 years ago

Yeah, clojure-mode in my emacs does some funky things to indentation. Essentially I replaced the (if (aggregate? ..)..) with a (cond (string? ..) (aggregate?..)..)

Your fix should do the trick too, however, you wouldn't need the double (ns-keyword ..), right?

Another question would be if strings shouldn't just be included verbatim, wherever they are allowed.