Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Petrol.Query
SourceProvides an E-DSL for specifying SQL queries in OCaml.
('ret_ty, 'query_tag) t
represents an SQL query that returns values of type 'ret_ty
and is a SQL query of kind 'query_kind
.
pp fmt q
prints the query q
in a form that can be parsed by an SQL engine.
Defines the type of join to be used to combine two tables
type ('a, 'c) where_fun = bool Expr.t -> ('c, 'a) t -> ('c, 'a) t constraint 'a = [< `DELETE | `SELECT | `SELECT_CORE | `UPDATE ]
('a,'c) where_fun
defines the type of an SQL function that corresponds to SQL's WHERE clause.
type ('a, 'b, 'c) group_by_fun = 'b Expr.expr_list -> ('c, 'a) t -> ('c, 'a) t constraint 'a = [< `SELECT | `SELECT_CORE ]
('a,'b,'c) group_by_fun
defines the type of an SQL function that corresponds to SQL's GROUP BY clause.
type ('a, 'c) having_fun = bool Expr.t -> ('c, 'a) t -> ('c, 'a) t constraint 'a = [< `SELECT | `SELECT_CORE ]
('a,'b,'c) having_fun
defines the type of an SQL function that corresponds to SQL's HAVING clause.
type ('a, 'b, 'd, 'c) join_fun =
?op:join_op ->
on:bool Expr.t ->
('b, 'd) t ->
('c, 'a) t ->
('c, 'a) t constraint 'a = [< `SELECT_CORE ] constraint 'd = [< `SELECT_CORE | `SELECT ]
('a,'b,'c,'d) join_fun
defines the type of an SQL function that corresponds to SQL's JOIN clause.
type ('a, 'b, 'c) on_err_fun = 'b -> ('c, 'a) t -> ('c, 'a) t
constraint 'a = [> `INSERT | `UPDATE ]
constraint 'b = [< `ABORT | `FAIL | `IGNORE | `REPLACE | `ROLLBACK ]
('a,'b,'c) having_fun
defines the type of an SQL function that corresponds to SQL's HAVING clause ON ERR.
select fields ~from
corresponds to the SQL SELECT {fields} FROM {from}
.
update ~table ~set
corresponds to the SQL UPDATE {set} FROM {table}
.
insert ~table ~values
corresponds to the SQL INSERT {values} INTO {table}
.
delete ~from
corresponds to the SQL DELETE FROM {from}
.
where by expr
corresponds to the SQL {expr} WHERE {by}
.
group_by fields expr
corresponds to the SQL {expr} GROUP BY {fields}
.
having fields expr
corresponds to the SQL {expr} HAVING {fields}
.
join ?op ~on oexpr expr
corresponds to the SQL {expr} {op} JOIN {oexpr} ON {expr}
.
The ordering of the last two arguments has been chosen to allow easily piping this with another SQL query.
val on_err :
[ `ABORT | `FAIL | `IGNORE | `REPLACE | `ROLLBACK ] ->
(unit, 'a) t ->
(unit, 'a) t
on_err err expr
corresponds to the SQL {expr} ON ERR {err}
.
limit count expr
corresponds to the SQL {expr} LIMIT {count}
.
offset count expr
corresponds to the SQL {expr} OFFSET {fields}
.
val order_by :
?direction:[ `ASC | `DESC ] ->
'a Expr.t ->
('b, [< `SELECT | `SELECT_CORE ]) t ->
('b, [> `SELECT ]) t
order_by ?direction fields expr
corresponds to the SQL {expr} ORDER BY {direction} {fields}
.
val order_by_ :
?direction:[ `ASC | `DESC ] ->
'a Expr.expr_list ->
('b, [< `SELECT | `SELECT_CORE ]) t ->
('b, [> `SELECT ]) t
order_by_ ?direction fields expr
corresponds to the SQL {expr} ORDER BY {direction} {fields}
. (In contrast to Petrol.Query.order_by
, this function allows passing a list of elements to be ordered by)