Hello all, quick beginners question, how do you declare an array type in a create table statement?
CREATE TABLE table_name (attribute_name INT[])
You probably need to use [:raw "INT[]"] for that.
👌 thanks
I registered a function to do extactly this
(hsql/register-fn! :array (fn [_ [type]]
(if type
[(str (hsql/sql-kw type) "[]")]
["'[]'"])))
#_(hsql/format [:array :int])
;; => ["INT[]"]
#_(hsql/format {:create-table :table-name
:with-columns [[:attribute-name [:array :int]]]})
;; => ["CREATE TABLE table_name (attribute_name INT[])"]
@pragyan474 That's probably not a good idea since there's a built-in for :array already https://cljdoc.org/d/com.github.seancorfield/honeysql/2.4.1045/doc/getting-started/sql-special-syntax-#array -- it just means something different.
Oh. Thanks for pointing it out.