Liking cljdoc? Tell your friends :D

clojureql.internal


add-depsclj

(add-deps map-of-joins edges tbl)

recursively add dependencies of tbl into a list

recursively add dependencies of tbl into a list
sourceraw docstring

add-tnameclj

(add-tname tname colname)
source

aggregate?clj

(aggregate? c)
source

apply-aliasesclj

(apply-aliases stmt aliases)

Takes a statement and a hashmap of aliases and returns a statement with all aliases applied

Takes a statement and a hashmap of aliases and returns
a statement with all aliases applied
sourceraw docstring

assemble-sqlclj

(assemble-sql s & args)
source

clean-sqlclj

(clean-sql coll)
source

conj-rowsclj

(conj-rows table column-names & value-groups)

Inserts rows into a table with values for specified columns only. column-names is a vector of strings or keywords identifying columns. Each value-group is a vector containing a values for each column in order. When inserting complete rows (all columns), consider using insert-rows instead.

Inserts rows into a table with values for specified columns only.
column-names is a vector of strings or keywords identifying columns. Each
value-group is a vector containing a values for each column in
order. When inserting complete rows (all columns), consider using
insert-rows instead.
sourceraw docstring

emit-caseclj

(emit-case {:keys [alias clauses returns else]})
source

exec-preparedclj

(exec-prepared sql param-group)
(exec-prepared sql param-group & param-groups)

Executes an (optionally parameterized) SQL prepared statement on the open database connection. Each param-group is a seq of values for all of the parameters.

Executes an (optionally parameterized) SQL prepared statement on the
open database connection. Each param-group is a seq of values for all of
the parameters.
sourceraw docstring

extract-aliasesclj

(extract-aliases joins)

Internal: Looks through the tables in 'joins' and finds tables which requires subselects. It returns a vector of the original name and the new name for each table

 Internal: Looks through the tables in 'joins' and finds tables
which requires subselects. It returns a vector of the
original name and the new name for each table 
sourceraw docstring

find-aggregatesclj

(find-aggregates tcols)

Goes through tcols looking for vectors with 3 items and returns the alias for those found.

Goes through tcols looking for vectors with 3 items and returns
the alias for those found.
sourceraw docstring

find-aliasesclj

(find-aliases tcols)

Scans a column spec to find the first alias, if none is found the first column is used instead

Scans a column spec to find the first alias, if none is found the
first column is used instead
sourceraw docstring

flatten-depsclj

(flatten-deps map-of-joins edges set-of-root-nodes)
source

generated-keysclj

(generated-keys stmt)
source

get-foreignfieldclj

(get-foreignfield tname s)

Extracts the first foreign field in a column spec

:t1 [:t1.x :t2x] => :t2.x

Extracts the first foreign field in a column spec

:t1 [:t1.x :t2x]  => :t2.x 
sourceraw docstring

has-aggregate?clj

(has-aggregate? tble)
source

join-column-namesclj

(join-column-names table-name-alias cols)

given table-name-alias from the first position of the :data value of a join def, if table-name-alias is an RTable, representing a subselect, then return the renamed join cols according the the subselect alias. if table-name-alias is not an RTable then return cols unmodified

given table-name-alias from the first position of the :data value of a join def,
if table-name-alias is an RTable, representing a subselect, then return the renamed
join cols according the the subselect alias. if table-name-alias is not an
RTable then return cols unmodified
sourceraw docstring

join-table-aliasclj

(join-table-alias tna)

given tna from the first position of the :data value of a join definition, which is one of

  • an RTable (for subselects)
  • a simple table-name
  • a space separated "table-name alias" pair return
  • if the object was an RTable, return the subselect table alias, which is either an explicit alias, or (str (nskeyword (:tname tna)) "_subselect")
  • if the object was a simple table-name, return it
  • if the object was an aliased table-name, return just the alias
given tna from the first position of the :data value of a join definition,
which is one of
  - an RTable (for subselects)
  - a simple table-name
  - a space separated "table-name alias" pair
return
  - if the object was an RTable, return the subselect table
    alias, which is either an explicit alias, or
     (str (nskeyword (:tname tna)) "_subselect")
  - if the object was a simple table-name, return it
  - if the object was an aliased table-name, return
    just the alias
sourceraw docstring

joins-by-table-aliasclj

(joins-by-table-alias joins)

given a list of joins return a map of joins keyed by the join table-alias or, in the case of subselects, the subselect table alias

given a list of joins return a map of joins
keyed by the join table-alias or,
in the case of subselects, the subselect table alias
sourceraw docstring

nskeywordclj

(nskeyword k)

Converts a namespace qualified keyword to a string

Converts a namespace qualified keyword to a string
sourceraw docstring

prepare-statementclj

(prepare-statement conn sql)
source

qualified?clj

(qualified? c)
source

rename-subselectsclj

(rename-subselects tname tcols)
source

requires-subselect?clj

(requires-subselect? table)
source

result-seqclj

(result-seq rs)

Creates and returns a lazy sequence of structmaps corresponding to the rows in the java.sql.ResultSet rs. Accepts duplicate keys

Creates and returns a lazy sequence of structmaps corresponding to
the rows in the java.sql.ResultSet rs. Accepts duplicate keys
sourceraw docstring

sort-joinsclj

(sort-joins joins)

sort a list of joins into dependency order

sort a list of joins into dependency order
sourceraw docstring

split-fieldsclj

(split-fields t a)
source

sql-clauseclj

(sql-clause pred & args)
source

subselect-table-aliasclj

(subselect-table-alias tname)

given an RTable tname, which is either

  • a simple table-name string
  • a {:table-name :alias} map return in the case of the simple string, the string with _subselect appended in the case of the alias map, the value of the explicit alias
given an RTable tname, which is either
 - a simple table-name string
 - a {:table-name :alias} map
return
  in the case of the simple string, the string with _subselect appended
  in the case of the alias map, the value of the explicit alias
sourceraw docstring

supports-generated-keys?clj

(supports-generated-keys? conn)
source

table-aliasclj

(table-alias tname)

given an RTable tname, which is either

  • a simple table-name string
  • a {:table-name :alias} map return in the case of the simple string, the string itself in the case of the alias map, the value of the explicit alias
given an RTable tname, which is either
 - a simple table-name string
 - a {:table-name :alias} map
return
  in the case of the simple string, the string itself
  in the case of the alias map, the value of the explicit alias
sourceraw docstring

to-fieldlistclj

(to-fieldlist tcols)
(to-fieldlist tname tcols)

Converts a column specification to SQL notation field list

:tble [:sum/k1 :k2 [:avg/k3 :as :c]] => 'sum(tble.k1),tble.k2,avg(tble.k3) AS c' :tble :t1 [:avg/a:b] => 'avg(t1.a, t1.b)'

Converts a column specification to SQL notation field list

:tble [:sum/k1 :k2 [:avg/k3 :as :c]] => 'sum(tble.k1),tble.k2,avg(tble.k3) AS c'
:tble :t1 [:avg/a:b] => 'avg(t1.a, t1.b)' 
sourceraw docstring

to-graph-elclj

(to-graph-el m {[table-name-alias join-on] :data :as join})

given a join definition return an edge in the table alias dependency graph

given a join definition return an edge in the table
alias dependency graph
sourceraw docstring

to-nameclj

(to-name c)
(to-name p c)

Converts a keyword to a string, checking for aggregates

(to-name :avg/y) => 'avg(y)' (to-name :y) => 'y' (to-name :parent :fn/field => 'fn(master.field)'

 Converts a keyword to a string, checking for aggregates

(to-name :avg/y) => 'avg(y)'
(to-name :y) => 'y'
(to-name :parent :fn/field => 'fn(master.field)' 
sourceraw docstring

to-orderlistclj

(to-orderlist tname aggregates fields)

Converts a list like [:id#asc :name#desc] to "id asc, name desc"

Also takes a single keyword argument. Does not qualify fields found in aggregates. aggregates can also be a keyword in which case all fields are left unqualified.

Converts a list like [:id#asc :name#desc] to "id asc, name desc"

Also takes a single keyword argument. Does not qualify fields found
in aggregates. aggregates can also be a keyword in which case all
fields are left unqualified.
sourceraw docstring

to-tablealiasclj

(to-tablealias c)

Returns the alias of a :tname. If :tname is not aliased it returns the same as to-tablename.

Returns the alias of a :tname. If :tname is not aliased it
returns the same as to-tablename.
sourceraw docstring

to-tablenameclj

(to-tablename c)
source

to-tbl-nameclj

(to-tbl-name {[table-name-alias join-on] :data :as join})

given a join definition, return a table alias that the join depends on

given a join definition, return a table alias
that the join depends on
sourceraw docstring

update-or-insert-valsclj

(update-or-insert-vals table where-params record)

Updates values on selected rows in a table, or inserts a new row when no existing row matches the selection criteria. where-params is a vector containing a string providing the (optionally parameterized) selection criteria followed by values for any parameters. record is a map from strings or keywords (identifying columns) to updated values.

Updates values on selected rows in a table, or inserts a new row when no
existing row matches the selection criteria. where-params is a vector
containing a string providing the (optionally parameterized) selection
criteria followed by values for any parameters. record is a map from
strings or keywords (identifying columns) to updated values.
sourceraw docstring

update-valsclj

(update-vals table where-params record)

Updates values on selected rows in a table. where-params is a vector containing a string providing the (optionally parameterized) selection criteria followed by values for any parameters. record is a map from strings or keywords (identifying columns) to updated values.

Updates values on selected rows in a table. where-params is a vector
containing a string providing the (optionally parameterized) selection
criteria followed by values for any parameters. record is a map from
strings or keywords (identifying columns) to updated values.
sourceraw docstring

upper-nameclj

(upper-name kw)
source

with-renameclj

(with-rename tname tcols renames)

Renames fields that have had their parent aliased. (name is horribly misleading, it protects against errors when tables have been renamed)

:one [:one.a :one.b] {:one :two} => 'one AS one(a,b)'

Renames fields that have had their parent aliased.
(name is horribly misleading, it protects against errors when
 tables have been renamed)

:one [:one.a :one.b] {:one :two} => 'one AS one(a,b)' 
sourceraw docstring

with-results*clj

(with-results* [sql & params :as sql-params] func)

Executes a query, then evaluates func passing in a seq of the results as an argument. The first argument is a vector containing the (optionally parameterized) sql query string followed by values for any parameters.

Executes a query, then evaluates func passing in a seq of the results as
an argument. The first argument is a vector containing the (optionally
parameterized) sql query string followed by values for any parameters.
sourceraw docstring

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

× close