honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
adam 2020-07-11T14:03:35.202800Z

I see an odd behavior here: https://github.com/nilenso/honeysql-postgres/blob/feb22bf7a164a23d4dbcffba35c3af4f3e4e38a3/test/honeysql_postgres/postgres_test.cljc#L3 If [honeysql-postgres.format :as sqlpf] is removed from the ns declaration, ON CONFLICT ON ... stops getting added despite sqlpf not being used. How come? Even worse, everything keeps working after the removal until the webserver is restarted

adam 2020-07-11T14:07:42.203200Z

Is that the monkey patching version of Clojure? 🙂

seancorfield 2020-07-11T14:28:26.204Z

That's just how multimethods work: if you don't require the namespace containing the definitions of specific "clauses", then those clauses won't work.

seancorfield 2020-07-11T14:28:32.204200Z

^ @somedude314

seancorfield 2020-07-11T14:28:50.204600Z

It's the same with protocol extensions.

seancorfield 2020-07-11T14:32:29.208500Z

Namespaces are one of the few mutable, side-effect-y things in Clojure and require modifies your "environment" by executing the top-level forms in a namespace, which both adds their definitions (bindings) to the namespace and runs any side-effecting changes those definitions cause (`def` forms have their body evaluated, defrecord introduces several new helper functions that are "in the code", defmethod adds to an existing defmulti, extend-protocol adds to an existing defprotocol -- the latter two are potentially cross-namespace). There are probably a few other things.

adam 2020-07-11T14:48:09.208700Z

Thanks for the clarification @seancorfield. It seems like I should add some tests to this area, the code is super fragile by itself.

seancorfield 2020-07-11T14:54:06.211400Z

The same is true of some namespaces in next.jdbc BTW: next.jdbc.datafy and next.jdbc.date-time -- requiring them adds/changes behavior. They're optional, but if you want that behavior, you have to require them (the former exposes a single dynamic Var that controls how exceptions should be handled in the optional functionality enabled by that namespace, the latter exposes three functions that let you modify the additional behavior that requiring that namespace provides by default).

🆗 1
🙏 1