hugsql.core

db-fn

(db-fn sql)(db-fn sql command)(db-fn sql command result)(db-fn sql command result options)
Given an sql string and optionally a command, result, and options,
return an anonymous function that can run hugsql database
execute/queries and supports hugsql parameter replacement

db-fn*

(db-fn* psql)(db-fn* psql command)(db-fn* psql command result)(db-fn* psql command result options)
Given parsed sql and optionally a command, result, and options,
return an anonymous function that can run hugsql database
execute/queries and supports hugsql parameter replacement

db-fn-map

(db-fn-map pdef options)
Hashmap of db fn from a parsed def
with the form:
{:fn-name {:meta {:doc "doc string"}
           :fn <anon-db-fn>}

db-run

(db-run db sql)(db-run db sql param-data)(db-run db sql param-data command)(db-run db sql param-data command result)(db-run db sql param-data command result options & command-options)
Given a database spec/connection, sql string,
parameter data, and optional command, result,
and options, run the sql statement

def-db-fns

macro

(def-db-fns file)(def-db-fns file options)
Given a HugSQL SQL file, define the database
functions in the current namespace.

Usage:

(def-db-fns file options?)

where:
 - file is a string file path in your classpath,
   a resource object (java.net.URL),
   or a file object (java.io.File)
 - options (optional) hashmap:
   {:quoting :off(default) | :ansi | :mysql | :mssql
    :adapter adapter }

:quoting options for identifiers are:
  :ansi double-quotes: "identifier"
  :mysql backticks: `identifier`
  :mssql square brackets: [identifier]
  :off no quoting (default)

Identifiers containing a period/dot . are split, quoted separately,
and then rejoined. This supports myschema.mytable conventions.

:quoting can be overridden as an option in the calls to functions
created by def-db-fns.

:adapter specifies the HugSQL adapter to use for all defined
functions. The default adapter used is
(hugsql.adapter.clojure-java-jdbc/hugsql-adapter-clojure-java-jdbc)
when :adapter is not given.

See also hugsql.core/set-adapter! to set adapter for all def-db-fns
calls.  Also, :adapter can be specified for individual function
calls (overriding set-adapter! and the :adapter option here).

def-db-fns-from-string

macro

(def-db-fns-from-string s)(def-db-fns-from-string s options)
Given a HugSQL SQL string, define the database
functions in the current namespace.

Usage:

(def-db-fns-from-string s options?)

where:
 - s is a string of HugSQL-flavored sql statements
 - options (optional) hashmap:
   {:quoting :off(default) | :ansi | :mysql | :mssql
    :adapter adapter }

See hugsql.core/def-db-fns for :quoting and :adapter details.

def-sqlvec-fns

macro

(def-sqlvec-fns file)(def-sqlvec-fns file options)
Given a HugSQL SQL file, define the <name>-sqlvec functions in the
current namespace.  Returns sqlvec format: a vector of SQL and
parameter values. (e.g., ["select * from test where id = ?" 42])

Usage:

 (def-sqlvec-fns file options?)

 where:
  - file is a string file path in your classpath,
    a resource object (java.net.URL),
    or a file object (java.io.File)
  - options (optional) hashmap:
    {:quoting :off(default) | :ansi | :mysql | :mssql
     :fn-suffix "-sqlvec" (default)

 See hugsql.core/def-db-fns for :quoting option details.

 :fn-suffix is appended to the defined function names to
 differentiate them from the functions defined by def-db-fns.

def-sqlvec-fns-from-string

macro

(def-sqlvec-fns-from-string s)(def-sqlvec-fns-from-string s options)
Given a HugSQL SQL string, define the <name>-sqlvec functions in the
current namespace.  Returns sqlvec format: a vector of SQL and
parameter values. (e.g., ["select * from test where id = ?" 42])

Usage:

 (def-sqlvec-fns-from-string s options?)

 where:
  - s is a HugSQL-flavored sql string
  - options (optional) hashmap:
    {:quoting :off(default) | :ansi | :mysql | :mssql
     :fn-suffix "-sqlvec" (default)

 See hugsql.core/def-db-fns for :quoting option details.

 :fn-suffix is appended to the defined function names to
 differentiate them from the functions defined by def-db-fns.

default-db-options

default-sqlvec-options

hugsql-command-fn

multimethod

hugsql-result-fn

multimethod

intern-db-fn

(intern-db-fn pdef options)
Intern the db fn from a parsed def

intern-sqlvec-fn

(intern-sqlvec-fn pdef options)
Intern the sqlvec fn from a parsed def

map-of-db-fns

macro

(map-of-db-fns file)(map-of-db-fns file options)
Given a HugSQL SQL file, return a hashmap of database
functions of the form:

{:fn1-name {:meta {:doc "doc string"}
            :fn <fn1>}
 :fn2-name {:meta {:doc "doc string"
                   :private true}
            :fn <fn2>}}

Usage:

(map-of-db-fns file options?)

where:
 - file is a string file path in your classpath,
   a resource object (java.net.URL),
   or a file object (java.io.File)
 - options (optional) hashmap:
   {:quoting :off(default) | :ansi | :mysql | :mssql
    :adapter adapter }

See hugsql.core/def-db-fns for :quoting and :adapter details.

map-of-db-fns-from-string

macro

(map-of-db-fns-from-string s)(map-of-db-fns-from-string s options)
Given a HugSQL SQL string, return a hashmap of database
functions of the form:

{:fn1-name {:meta {:doc "doc string"}
            :fn <fn1>}
 :fn2-name {:meta {:doc "doc string"
                   :private true}
            :fn <fn2>}}

Usage:

(map-of-db-fns-from-string s options?)

where:
 - s is a string of HugSQL-flavored sql statements
 - options (optional) hashmap:
   {:quoting :off(default) | :ansi | :mysql | :mssql
    :adapter adapter }

See hugsql.core/def-db-fns for :quoting and :adapter details.

map-of-sqlvec-fns

macro

(map-of-sqlvec-fns file)(map-of-sqlvec-fns file options)
Given a HugSQL SQL file, return a hashmap of database
 functions of the form:

 {:fn1-name {:meta {:doc "doc string"}
             :fn <fn1>}
  :fn2-name {:meta {:doc "doc string"
                    :private true}
             :fn <fn2>}}

Usage:

 (map-sqlvec-fns file options?)

 where:
  - file is a string file path in your classpath,
    a resource object (java.net.URL),
    or a file object (java.io.File)
  - options (optional) hashmap:
    {:quoting :off(default) | :ansi | :mysql | :mssql
     :fn-suffix "-sqlvec" (default)

 See hugsql.core/def-db-fns for :quoting option details.

 :fn-suffix is appended to the defined function names to
 differentiate them from the functions defined by def-db-fns.

map-of-sqlvec-fns-from-string

macro

(map-of-sqlvec-fns-from-string s)(map-of-sqlvec-fns-from-string s options)
Given a HugSQL SQL string, return a hashmap of sqlvec
 functions of the form:

 {:fn1-name {:meta {:doc "doc string"}
             :fn <fn1>}
  :fn2-name {:meta {:doc "doc string"
                    :private true}
             :fn <fn2>}}

Usage:

 (map-sqlvec-fns-from-string s options?)

 where:
  - s is a HugSQL-flavored sql string
  - options (optional) hashmap:
    {:quoting :off(default) | :ansi | :mysql | :mssql
     :fn-suffix "-sqlvec" (default)

 See hugsql.core/def-db-fns for :quoting option details.

 :fn-suffix is appended to the defined function names to
 differentiate them from the functions defined by def-db-fns.

set-adapter!

(set-adapter! the-adapter)
Set a global adapter.

snip

Alias for sqlvec

snip-fn

Alias for sqlvec-fn

sqlvec

(sqlvec sql param-data)(sqlvec sql options param-data)
Given an sql string, optional options, and param data, return an sqlvec

sqlvec-fn

(sqlvec-fn sql)(sqlvec-fn sql options)
Given an sql string and optional options, return an
anonymous function that returns hugsql sqlvec format

sqlvec-fn*

(sqlvec-fn* psql)(sqlvec-fn* psql options)
Given parsed sql and optional options, return an
anonymous function that returns hugsql sqlvec format

sqlvec-fn-map

(sqlvec-fn-map pdef options)
Hashmap of sqlvec/snip fn from a parsed def
with the form:
{:fn-name {:meta {:doc "doc string"}
           :fn <anon-db-fn>}