diff --git a/src/honey/sql/pg_ops.cljc b/src/honey/sql/pg_ops.cljc index ef66509..247d75d 100644 --- a/src/honey/sql/pg_ops.cljc +++ b/src/honey/sql/pg_ops.cljc @@ -27,20 +27,36 @@ ;; see https://www.postgresql.org/docs/current/functions-json.html -(def -> "The -> operator." :->) -(def ->> "The ->> operator." :->>) -(def hash> "The #> operator." :#>) -(def hash>> "The #>> operator." :#>>) -(def at> "The @> operator." (keyword "@>")) -(def + "The -> operator for accessing nested JSON(B) values as JSON(B). + Ex.: + ```clojure + (sql/format {:select [[[:->> [:-> :my_column \"kids\" [:inline 0]] \"name\"]]]}) + ; => [\"SELECT (my_column -> ? -> 0) ->> ?\" \"kids\" \"name\"] + ``` + + Notice we need to wrap the keys/indices with :inline if we don't want them to become parameters." + :->) +(def ->> "The ->> operator - like -> but returns the value as text instead of a JSON object." :->>) +(def hash> "The #> operator extracts JSON sub-object at the specified path." :#>) +(def hash>> "The #>> operator - like hash> but returns the value as text instead of JSON object." :#>>) +(def at> "The @> operator - does the first JSON value contain the second?" (keyword "@>")) +(def