clj-commons / camel-snake-kebab

A Clojure[Script] library for word case conversions
https://clj-commons.org/camel-snake-kebab/
Eclipse Public License 1.0
475 stars 48 forks source link

namespaces are filtered from processed keys #43

Open waffletower opened 6 years ago

waffletower commented 6 years ago

Expected (->kebab-case-keyword :hmm.com/MonkeyFace) => :hmm.com/monkey-face Actual => monkey-face

qerub commented 6 years ago

The type-preserving functions throw an exception for namespaced keywords:

(try
  (->kebab-case :hmm.com/MonkeyFace)
  (catch Exception e
    (.getMessage e)))
; => "Namespaced keywords are not supported"

The type-converting functions should do the same to be consistent and match the documentation at https://github.com/qerub/camel-snake-kebab/blame/master/README.md#L77.

In what situation do you want to transform namespaced keywords?

Related issue: #8

arichiardi commented 3 years ago

I have a use case for transforming - and the might be a better option there.

The use case would be when you have a clojure.java.jdbc call that contains :qualifier:

(clj-jdbc/execute! db-spec-or-tx multi-sql-params {:return-keys true
                                                   :multi? true
                                                   :qualifier "core2.models.file"
                                                   :transaction? true
                                                   :row-fn csk->kebab-case})

I can work around it by doing both conversions in :row-fn clearly here but I just wanted to report the use case...

arichiardi commented 3 years ago

...and it turns out there exists a :identifiers functionality for doing that before :qualifier is applied.

Therefore the following works for me without any change to camel-snake-kebab:

(clj-jdbc/execute! db-spec-or-tx multi-sql-params {:return-keys true
                                                   :multi? true
                                                   :identifiers csk->kebab-case
                                                   :qualifier "core2.models.file"
                                                   :transaction? true})