-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parameterization, cleanup, configurable exception throwing, type mapp…
…ings, default handlers
- Loading branch information
Showing
5 changed files
with
171 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns route-craft.queries.requests) | ||
|
||
(defmulti query-params->sql (fn [type _query-params] type)) | ||
|
||
(defmethod query-params->sql :honeysql | ||
[_ query-params] | ||
|
||
|
||
) | ||
|
||
(defmethod query-params->sql :default | ||
[type _] | ||
(throw (ex-info "Unsupported query type" {:type ::unsupported-query-type | ||
:query-type type}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns route-craft.queries.sql) | ||
|
||
(defprotocol SQLFromRequestParams | ||
;; Equality | ||
(eq [this key value]) | ||
(neq [this key value]) | ||
(is [this key value]) | ||
(distinct [this key value]) | ||
(gt [this key value]) | ||
(gte [this key value]) | ||
(lt [this key value]) | ||
(lte [this key value]) | ||
;; Partial matching | ||
(like [this key value]) | ||
(ilike [this key value]) | ||
;; Collections | ||
(in [this key value]) | ||
;; Array operators | ||
(contains [this key value]) | ||
(contained [this key value]) | ||
(overlap [this key value]) | ||
;; Logical operator | ||
(or [this key value]) | ||
(and [this key value]) | ||
(not [this key value]) | ||
(all [this key value]) | ||
(any [this key value])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(ns route-craft.queries.sql.map-like | ||
(:require | ||
[route-craft.queries.sql :as sql])) | ||
|
||
|
||
|
||
(def sql->map-like | ||
(reify | ||
sql/SQLFromRequestParams | ||
(sql/eq [this k v] | ||
))) | ||
|
||
|
||
(comment | ||
(def test-query {:a {:eq 13} | ||
:b {:gt 5 | ||
:ne 10} | ||
:or [{:a {:eq 5} | ||
:b {:eq 6}}]})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters