Hello everyone!
(def format-params {:checking :strict
:params {}
:pretty true
:dialect :postgresql})
I getting this error : (query! {:select [:*] :from [:web-user]}) Execution error (ExceptionInfo) at honey.sql/check-dialect (sql.cljc:1736). Invalid dialect: postgresql Any ideas why?
Use :ansi instead of :postgresql.
When I delete :ansi it is working
What is query!?
(def fmt sql/format)
(defn execute! [q]
(let [sql-string (fmt q #_format-params)]
(println q)
(println sql-string)
(j/db-do-prepared conn-str sql-string)))
(defn query! [q]
(let [sql-string (fmt q #_format-params)]
(println q)
(println sql-string)
(j/query conn-str sql-string)))Ah, huh. When :dialect is set explicitly, :quoted true is also assumed, unless it's explicitly set to false or the dialect is :nrql.
So you can either omit :dialect completely (`:ansi` is the default anyway), or add :quoted nil to the options.
Ah ":quoted nil" fixed, thank you 🙂
I have a new journey now. I am learning to use HoneySQL to create a basic app. I have one more question: Is there a list that matches SQL types to Clojure types, like varchar to text, number int etc.? While trying to create complex tables getting strange errors 😄
next.jdbc or whatever you're using instead of it would have such a list. If not in the docs, then in the impl. I imagine some of the mappings come from the underlying Java impl, specifically text and numbers are definitely at the Java level, built into JDK.
thanks for seperating time, good day 🙂
All this is in the documentation, by the way.
If you have suggestions for improving the docs, feel free to create issues on GitHub.
Specifically, Getting Started lists the valid dialects: https://cljdoc.org/d/com.github.seancorfield/honeysql/2.6.1147/doc/getting-started?q=dialect#dialects
Awesome thanks!
That section says "If you want to use a dialect and use the default quoting strategy (automatically quote any SQL entities that seem unusual), specify a :dialect option and set :quoted nil:" and then provides a bunch of examples of how :dialect and :quoted interact.