title: How to avoid unresolved symbol with clj-kond when using hugSQL def-db-fns macro?
body: <p>I write Clojure using the VS Code <a href="https://github.com/BetterThanTomorrow/calva" rel="noreferrer">Calva</a> extension, which uses <a href="https://github.com/borkdude/clj-kondo" rel="noreferrer">clj-kondo</a> to perform static analysis of my code.</p>
  
  <p>I'm using <a href="https://www.hugsql.org/" rel="noreferrer">HugSQL</a> to create Clojure functions from SQL queries and statements.</p>
  
  <p>I'm aware that I could handle the database connection and the HugSQL integration with a library like <a href="https://github.com/luminus-framework/conman" rel="noreferrer">conman</a>, infact I used it in the past and I like it, but this time I wanted to keep things vanilla and talk to HugSQL myself.</p>
  
  <p>HugSQL's <code>def-db-fns</code> macro takes a SQL file and creates Clojure functions based on the SQL queries and statements contained in that file.</p>
  
  <p>My code below works, but clj-kondo complains that <code>seed-mytable!</code> is an unresolved symbol.</p>
  
  <pre><code>(ns my-app.db
    "This namespace represents the bridge between the database world and the clojure world."
    (:require [environ.core :refer [env]]
              [hugsql.core :as hugsql]
              [nano-id.core :refer [nano-id]]))
  
  ;; This create the function seed-mytable!, but clj-kondo doesn't (cannot?) know it.
  (hugsql/def-db-fns "sql/mytable.sql")
  
  ;; The functions created by HugSQL can accept a db-spec, a connection, a connection pool,
  ;; or a transaction object. Let's keep it simple and use a db-spec for a SQLite database.
  (def db-spec {:classname "org.sqlite.JDBC"
                :subprotocol "sqlite"
                :subname (env :database-subname)})
  
  (defn db-seed
    "Populate the table with some fakes."
    []
    (let [fakes [[(nano-id) "First fake title" "First fake content"]
                 [(nano-id) "Second fake title" "Second fake content"]]]
  
      ;; clj-kondo complains that seed-my-table! is an unresolved symbol
      (seed-mytable! db-spec {:fakes fakes})))
  </code></pre>
  
  <p>I understand why clj-kondo complains: <code>seed-mytable!</code> is not defined anywhere, it's "injected" in this namespace when calling the <code>def-db-fns</code> macro.</p>
  
  <p>Is there a way to tell clj-kondo that after calling the <code>hugsql/def-db-fns</code> macro the symbol does indeed exist?</p>
  
  <p>Probably it's not that useful, but this is the SQL file I'm loading with HugSQL.</p>
  
  <pre><code>-- :name seed-mytable!
  -- :command :execute
  -- :result :affected
  -- :doc Seed the `mytable` table with some fakes.
  INSERT INTO mytable (id, title, content)
  VALUES :t*:fakes;
  </code></pre>