(add-deps map-of-joins edges tbl)
recursively add dependencies of tbl into a list
recursively add dependencies of tbl into a list
(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
(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.
(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.
(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
(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.
(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
(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
(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
(join-table-alias tna)
given tna from the first position of the :data value of a join definition, which is one of
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
(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
(nskeyword k)
Converts a namespace qualified keyword to a string
Converts a namespace qualified keyword to a string
(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
(sort-joins joins)
sort a list of joins into dependency order
sort a list of joins into dependency order
(subselect-table-alias tname)
given an RTable tname, which is either
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
(table-alias tname)
given an RTable tname, which is either
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
(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)'
(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
(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)'
(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.
(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.
(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
(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.
(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.
(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)'
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close