Liking cljdoc? Tell your friends :D

java-jdbc.sql

An optional DSL for generating SQL.

Intended to be used with clojure.java.jdbc, this provides a simple DSL - Domain Specific Language - that generates raw SQL strings. Any other DSL can be used instead. This DSL is entirely optional and is deliberately not very sophisticated. It is sufficient to support the delete!, insert! and update! high-level operations within clojure.java.jdbc directly.

An optional DSL for generating SQL.

Intended to be used with clojure.java.jdbc, this provides a simple DSL -
Domain Specific Language - that generates raw SQL strings. Any other DSL
can be used instead. This DSL is entirely optional and is deliberately
not very sophisticated. It is sufficient to support the delete!, insert!
and update! high-level operations within clojure.java.jdbc directly.
raw docstring

as-isclj

source

as-quoted-strclj

(as-quoted-str q)
(as-quoted-str q x)

Given a quoting pattern - either a single character or a vector pair of characters - and a string, return the quoted string: (as-quoted-str X foo) will return XfooX (as-quoted-str [A B] foo) will return AfooB

Given a quoting pattern - either a single character or a vector pair of
characters - and a string, return the quoted string:
  (as-quoted-str X foo) will return XfooX
  (as-quoted-str [A B] foo) will return AfooB
sourceraw docstring

as-strclj

(as-str f)
(as-str f x)

Given a naming strategy and a keyword, return the keyword as a string per that naming strategy. Given (a naming strategy and) a string, return it as-is. A keyword of the form :x.y is treated as keywords :x and :y, both are turned into strings via the naming strategy and then joined back together so :x.y might become x.y if the naming strategy quotes identifiers with `.

Given a naming strategy and a keyword, return the keyword as a
string per that naming strategy. Given (a naming strategy and)
a string, return it as-is.
A keyword of the form :x.y is treated as keywords :x and :y,
both are turned into strings via the naming strategy and then
joined back together so :x.y might become `x`.`y` if the naming
strategy quotes identifiers with `.
sourceraw docstring

deleteclj

(delete table [where & params] & {:keys [entities] :or {entities as-is}})

Given a table name, a where class and its parameters and an optional entities spec, return a vector of the SQL for that delete operation followed by its parameters. The entities spec (default 'as-is') specifies how to transform column names.

Given a table name, a where class and its parameters and an optional entities spec,
return a vector of the SQL for that delete operation followed by its parameters. The
entities spec (default 'as-is') specifies how to transform column names.
sourceraw docstring

entitiescljmacro

(entities entities sql)

Given an entities function and a SQL-generating DSL form, transform the DSL form to inject an :entities keyword argument with the function at the end of each appropriate form.

Given an entities function and a SQL-generating DSL form, transform the DSL form
to inject an :entities keyword argument with the function at the end of each appropriate
form.
sourceraw docstring

identifierscljmacro

(identifiers identifiers sql)

Given an identifiers function and a SQL-generating DSL form, transform the DSL form to inject an :identifiers keyword argument with the function at the end of each appropriate form.

Given an identifiers function and a SQL-generating DSL form, transform the DSL form
to inject an :identifiers keyword argument with the function at the end of each
appropriate form.
sourceraw docstring

insertclj

(insert table & clauses)

Given a table name and either column names and values or maps representing rows, retun return a vector of the SQL for that insert operation followed by its parameters. An optional entities spec (default 'as-is') specifies how to transform column names.

Given a table name and either column names and values or maps representing rows, retun
return a vector of the SQL for that insert operation followed by its parameters. An
optional entities spec (default 'as-is') specifies how to transform column names.
sourceraw docstring

joinclj

(join table on-map & {:keys [entities] :or {entities as-is}})

Given a table name and a map of how to join it (to the existing SQL fragment), retun the SQL string for the JOIN clause. The optional entities spec (default 'as-is') specifies how to transform column names.

Given a table name and a map of how to join it (to the existing SQL fragment),
retun the SQL string for the JOIN clause. The optional entities spec (default 'as-is')
specifies how to transform column names.
sourceraw docstring

lower-caseclj

source

order-byclj

(order-by cols & {:keys [entities] :or {entities as-is}})

Given a sequence of column order specs, and an optional entities spec, return the SQL string for the ORDER BY clause. A column order spec may be a column name or a map of the column name to the desired order.

Given a sequence of column order specs, and an optional entities spec, return the
SQL string for the ORDER BY clause. A column order spec may be a column name or a
map of the column name to the desired order.
sourceraw docstring

quotedclj

(quoted q)
source

selectclj

(select col-seq table & clauses)

Given a sequence of column names (or *) and a table name, followed by optional SQL clauses, return a vector for the SQL followed by its parameters. The general form is: (select [columns] table joins [where params] order-by options) where joins are optional strings, as is order-by, and the where clause is a vector of a where SQL clause followed by its parameters. The options may may include an entities spec to specify how column names should be transformed. The intent is that the joins, where clause and order by clause are generated by other parts of the DSL: (select * {:person :p} (join {:address :a} {:p.addressId :a.id}) (where {:a.zip 94546}) (order-by :p.name))

Given a sequence of column names (or *) and a table name, followed by optional SQL
clauses, return a vector for the SQL followed by its parameters. The general form is:
  (select [columns] table joins [where params] order-by options)
where joins are optional strings, as is order-by, and the where clause is a vector
of a where SQL clause followed by its parameters. The options may may include an
entities spec to specify how column names should be transformed.
The intent is that the joins, where clause and order by clause are generated by
other parts of the DSL:
  (select * {:person :p}
          (join {:address :a} {:p.addressId :a.id})
          (where {:a.zip 94546})
          (order-by :p.name))
sourceraw docstring

updateclj

(update table set-map & where-etc)

Given a table name and a map of columns to set, and optional map of columns to match (and an optional entities spec), return a vector of the SQL for that update followed by its parameters. Example: (update :person {:zip 94540} (where {:zip 94546})) returns: ["UPDATE person SET zip = ? WHERE zip = ?" 94540 94546]

Given a table name and a map of columns to set, and optional map of columns to
match (and an optional entities spec), return a vector of the SQL for that update
followed by its parameters. Example:
  (update :person {:zip 94540} (where {:zip 94546}))
returns:
  ["UPDATE person SET zip = ? WHERE zip = ?" 94540 94546]
sourceraw docstring

whereclj

(where param-map & {:keys [entities] :or {entities as-is}})

Given a map of columns and values, return a vector containing the where clause SQL followed by its parameters. Example: (where {:a 42 :b nil}) returns: ["a = ? AND b IS NULL" 42]

Given a map of columns and values, return a vector containing the where clause SQL
followed by its parameters. Example:
  (where {:a 42 :b nil})
returns:
  ["a = ? AND b IS NULL" 42]
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close