2022-03-26 04:48:00 +00:00
|
|
|
;; copyright (c) 2022 sean corfield, all rights reserved
|
|
|
|
|
|
|
|
|
|
(ns honey.sql.pg-json
|
|
|
|
|
"Register all the PostgreSQL JSON/JSONB operators
|
2022-03-26 21:20:58 +00:00
|
|
|
and provide convenient Clojure names for those ops.
|
|
|
|
|
|
|
|
|
|
For the seven that cannot be written directly as
|
|
|
|
|
symbols, use mnemonic names: hash for # and at for @.
|
|
|
|
|
|
|
|
|
|
For the four of those that cannot be written as
|
|
|
|
|
keywords, invoke the `keyword` function instead.
|
|
|
|
|
|
|
|
|
|
Those latter four (`at>`, `<at`, `at?`, and `atat`)
|
|
|
|
|
are the only ones that should really be needed in the
|
|
|
|
|
DSL. The other names are provided for completeness."
|
|
|
|
|
(:refer-clojure :exclude [-> ->> -])
|
2022-03-26 04:48:00 +00:00
|
|
|
(:require [honey.sql :as sql]))
|
|
|
|
|
|
|
|
|
|
;; see https://www.postgresql.org/docs/current/functions-json.html
|
|
|
|
|
|
2022-03-26 21:20:58 +00:00
|
|
|
(def -> "The -> operator." :->)
|
|
|
|
|
(def ->> "The ->> operator." :->>)
|
|
|
|
|
(def hash> "The #> operator." :#>)
|
|
|
|
|
(def hash>> "The #>> operator." :#>>)
|
|
|
|
|
(def at> "The @> operator." (keyword "@>"))
|
|
|
|
|
(def <at "The <@ operator." (keyword "<@"))
|
|
|
|
|
(def ? "The ? operator." :?)
|
|
|
|
|
(def ?| "The ?| operator." :?|)
|
|
|
|
|
(def ?& "The ?& operator." :?&)
|
|
|
|
|
(def || "The || operator." :||)
|
|
|
|
|
(def - "The - operator." :-)
|
|
|
|
|
(def hash- "The #- operator." :#-)
|
|
|
|
|
(def at? "The @? operator." (keyword "@?"))
|
|
|
|
|
(def atat "The @@ operator." (keyword "@@"))
|
2022-03-26 04:48:00 +00:00
|
|
|
|
2022-03-26 15:28:24 +00:00
|
|
|
(sql/register-op! :-> :variadic true)
|
2022-03-26 04:48:00 +00:00
|
|
|
(sql/register-op! :->>)
|
|
|
|
|
(sql/register-op! :#>)
|
|
|
|
|
(sql/register-op! :#>>)
|
|
|
|
|
(sql/register-op! at>)
|
|
|
|
|
(sql/register-op! <at)
|
|
|
|
|
(sql/register-op! :?)
|
|
|
|
|
(sql/register-op! :?|)
|
|
|
|
|
(sql/register-op! :?&)
|
|
|
|
|
;; these are already known operators:
|
|
|
|
|
;(sql/register-op! :||)
|
|
|
|
|
;(sql/register-op! :-)
|
|
|
|
|
(sql/register-op! :#-)
|
|
|
|
|
(sql/register-op! at?)
|
|
|
|
|
(sql/register-op! atat)
|