3 ms·
We abstracted JSONB operations into the Clojure Query AST library HoneySQL and never really looked back. It was something one person on the team learned thoroug
by emidln 8y ago
We abstracted JSONB operations into the Clojure Query AST library HoneySQL and never really looked back. It was something one person on the team learned thoroughly for a half day and promptly forgot about. Now we say things like:
(jsonb/get-in :jsonb-column [:field :sub-field])
;; jsonb_column#>>'{field, subfield}'
(jsonb/get-in :jsonb-column [:field :sub-field] "default")
;; COALESCE(jsonb_column#>>'{field, subfield}', 'default')
(jsonb/get-in :jsonb-column [:field])
;; jsonb_column->>'field'
Which each generate the appropriate data structures for HoneySQL to do some combination of using #>>, ->> and COALESCE as needed. I can't imagine this is too difficult in any language. Even if you are writing static SQL, I don't think learning the syntax to go with a feature is too high of an ask to use a feature.
- ganonm 8y agoNice library - I agree with you, learning the syntax shouldn't be considered a downside of an otherwise novel feature, my concern is mainly around the appropriateness of the feature in the context of problems that already have well established relational solutions