Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)

# Default rule
default:
jbuilder build @install
dune build @install

install:
jbuilder install $(INSTALL_ARGS)
dune install $(INSTALL_ARGS)

uninstall:
jbuilder uninstall $(INSTALL_ARGS)
dune uninstall $(INSTALL_ARGS)

reinstall: uninstall install

test:
jbuilder build @runtest
dune build @runtest

example:
jbuilder build examples/server.exe
dune build examples/server.exe

clean:
rm -rf _build
Expand Down
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.0)
(name sequoia)
4 changes: 4 additions & 0 deletions mysql/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name sequoia_mysql)
(public_name sequoia-mysql)
(libraries sequoia unix))
8 changes: 0 additions & 8 deletions mysql/jbuild

This file was deleted.

48 changes: 24 additions & 24 deletions mysql/mysql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module Field = struct
| Null.Enum (_, t, _) -> t
| fld -> table fld

let to_string : type a b. (a, b) t -> string = function
(* let to_string : type a b. (a, b) t -> string = function
| Time (name, table) -> sprintf "%s.%s" (Table.name table) name
| Timestamp (name, table) -> sprintf "%s.%s" (Table.name table) name
| Date (name, table) -> sprintf "%s.%s" (Table.name table) name
Expand All @@ -117,7 +117,7 @@ module Field = struct
| Null.Date (name, table) -> sprintf "%s.%s" (Table.name table) name
| Null.Datetime (name, table) -> sprintf "%s.%s" (Table.name table) name
| Null.Enum (name, table, _) -> sprintf "%s.%s" (Table.name table) name
| other -> to_string other
| other -> to_string other *)

let to_string fld =
let t = table fld in
Expand Down Expand Up @@ -391,7 +391,7 @@ module Expr = struct
let date ?(year = 0) ?(month = 0) ?(day = 0) = fun _ ->
Lit (Lit.Date { base_time with year; month; day })
let datetime ?(year = 0) ?(month = 0) ?(day = 0)
?(hour = 0) ?(minute = 0) ?(second = 0) = fun _ ->
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you actually use that value in { base_time with ... instead of removing it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it because it was unused. Good point tho.

?(minute = 0) ?(second = 0) = fun _ ->
Lit (Lit.Datetime { base_time with year; month; day; minute; second })

let enum inst = fun _ ->
Expand Down Expand Up @@ -419,17 +419,17 @@ module Expr = struct
let compress f = fun src -> Compress (f src)
let concat f = fun src -> Concat (f src)
let concat_ws sep l = fun src -> Concat_ws (sep, List.map (fun f -> f src) l)
let connection_id () = fun src -> Connection_id
let connection_id () = fun _src -> Connection_id
let conv f i j = fun src -> Conv (f src, i, j)
let cos f = fun src -> Cos (f src)
let cot f = fun src -> Cot (f src)
let count ?(distinct = false) f = fun src -> Count (f src, distinct)
let crc32 f = fun src -> Crc32 (f src)
let current_date () = fun src -> Current_date
let current_time () = fun src -> Current_time
let current_timestamp () = fun src -> Current_timestamp
let current_user () = fun src -> Current_user
let database () = fun src -> Database
let current_date () = fun _src -> Current_date
let current_time () = fun _src -> Current_time
let current_timestamp () = fun _src -> Current_timestamp
let current_user () = fun _src -> Current_user
let database () = fun _src -> Database
let date_of : ('s M.Select.source -> [< `Date | `Datetime] time t) -> 's M.Select.source -> [`Date] time t = fun f src -> DateFn (f src)
let date_add f i u = fun src -> Date_add (f src, i, u)
let date_format f fmt = fun src -> Date_format (f src, fmt)
Expand All @@ -448,7 +448,7 @@ module Expr = struct
let ifnull f g = fun src -> Ifnull (f src, g src)
let last_day f = fun src -> Last_day (f src)
let length f = fun src -> Length (f src)
let localtime () = fun src -> Localtime
let localtime () = fun _src -> Localtime
let log f = fun src -> Log (f src)
let log10 f = fun src -> Log10 (f src)
let log2 f = fun src -> Log2 (f src)
Expand All @@ -460,7 +460,7 @@ module Expr = struct
let minute f = fun src -> Minute (f src)
let month f = fun src -> Month (f src)
let monthname f = fun src -> Monthname (f src)
let now () = fun src -> Now
let now () = fun _src -> Now
let nullif f g = fun src -> Nullif (f src, g src)
let ord f = fun src -> Ord (f src)
let pow f = fun src -> Pow (f src)
Expand Down Expand Up @@ -489,23 +489,23 @@ module Expr = struct
let timestampdiff u f g = fun src -> Timestampdiff (u, f src, g src)
let trim f = fun src -> Trim (f src)
let uncompress f = fun src -> Uncompress (f src)
let utc_date () = fun src -> Utc_date
let utc_time () = fun src -> Utc_time
let utc_timestamp () = fun src -> Utc_timestamp
let uuid () = fun src -> Uuid
let uuid_short () = fun src -> Uuid_short
let week () = fun src -> Week
let weekday () = fun src -> Weekday
let weekofyear () = fun src -> Weekofyear
let utc_date () = fun _src -> Utc_date
let utc_time () = fun _src -> Utc_time
let utc_timestamp () = fun _src -> Utc_timestamp
let uuid () = fun _src -> Uuid
let uuid_short () = fun _src -> Uuid_short
let week () = fun _src -> Week
let weekday () = fun _src -> Weekday
let weekofyear () = fun _src -> Weekofyear
let upper f = fun src -> Upper (f src)
let year () = fun src -> Year
let year () = fun _src -> Year

let as_time f = fun src -> Cast (f src, Time)
let as_timestamp f = fun src -> Cast (f src, Timestamp)
let as_date f = fun src -> Cast (f src, Date)
let as_datetime f = fun src -> Cast (f src, Datetime)

let rec build
let build
: type a. handover:handover -> build_step -> a t -> build_step =
fun ~handover st e ->
let build_param = build_param D.placeholder in
Expand Down Expand Up @@ -543,7 +543,7 @@ module Expr = struct
| Collation e -> fn "COLLATION(" [e] ")"
| Compress e -> fn "COMPRESS(" [e] ")"
| Concat l -> fn "CONCAT(" l ")"
| Concat_ws (s, l) -> fn "CONCAT_WS" l ")"
| Concat_ws (_s, l) -> fn "CONCAT_WS" l ")"
| Connection_id -> fn "CONNECTION_ID" [] ")"
| Conv (e1, i, j) -> fn "CONV(" [e1] (sprintf ", %d, %d)" i j)
| Cos e -> fn "COS(" [e] ")"
Expand Down Expand Up @@ -576,13 +576,13 @@ module Expr = struct
| If (b, t, f) ->
let st1 = fn "IF(" [b] "" in
let st2 = fn ~st:st1 (st1.repr ^ ", ") [t; f] ")" in
Sequoia.{ st2 with params = st1.params @ st2.params }
{ st2 with params = st1.params @ st2.params }
| From_days e -> fn "FROM_DAYS(" [e] ")"
| From_unixtime e -> fn "FROM_UNIXTIME(" [e] ")"
| Ifnull (e1, e2) ->
let st1 = fn "IFNULL(" [e1] "" in
let st2 = fn ~st:st1 (st1.repr ^ ", ") [e2] ")" in
Sequoia.{ st2 with params = st1.params @ st2.params }
{ st2 with params = st1.params @ st2.params }
| Last_day e -> fn "LAST_DAY(" [e] ")"
| Length e -> fn "LENGTH(" [e] ")"
| Localtime -> fn "LOCALTIME(" [] ")"
Expand Down
4 changes: 4 additions & 0 deletions postgresql/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name sequoia_postgresql)
(public_name sequoia-postgresql)
(libraries sequoia unix))
8 changes: 0 additions & 8 deletions postgresql/jbuild

This file was deleted.

48 changes: 24 additions & 24 deletions postgresql/postgresql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module Field = struct
| Null.Enum (_, t, _) -> t
| fld -> table fld

let to_string : type a b. (a, b) t -> string = function
(* let to_string : type a b. (a, b) t -> string = function
| Time (name, table) -> sprintf "%s.%s" (Table.name table) name
| Timestamp (name, table) -> sprintf "%s.%s" (Table.name table) name
| Date (name, table) -> sprintf "%s.%s" (Table.name table) name
Expand All @@ -117,7 +117,7 @@ module Field = struct
| Null.Date (name, table) -> sprintf "%s.%s" (Table.name table) name
| Null.Datetime (name, table) -> sprintf "%s.%s" (Table.name table) name
| Null.Enum (name, table, _) -> sprintf "%s.%s" (Table.name table) name
| other -> to_string other
| other -> to_string other *)

let to_string fld =
let t = table fld in
Expand Down Expand Up @@ -391,7 +391,7 @@ module Expr = struct
let date ?(year = 0) ?(month = 0) ?(day = 0) = fun _ ->
Lit (Lit.Date { base_time with year; month; day })
let datetime ?(year = 0) ?(month = 0) ?(day = 0)
?(hour = 0) ?(minute = 0) ?(second = 0) = fun _ ->
?(minute = 0) ?(second = 0) = fun _ ->
Lit (Lit.Datetime { base_time with year; month; day; minute; second })

let enum inst = fun _ ->
Expand Down Expand Up @@ -419,17 +419,17 @@ module Expr = struct
let compress f = fun src -> Compress (f src)
let concat f = fun src -> Concat (f src)
let concat_ws sep l = fun src -> Concat_ws (sep, List.map (fun f -> f src) l)
let connection_id () = fun src -> Connection_id
let connection_id () = fun _src -> Connection_id
let conv f i j = fun src -> Conv (f src, i, j)
let cos f = fun src -> Cos (f src)
let cot f = fun src -> Cot (f src)
let count ?(distinct = false) f = fun src -> Count (f src, distinct)
let crc32 f = fun src -> Crc32 (f src)
let current_date () = fun src -> Current_date
let current_time () = fun src -> Current_time
let current_timestamp () = fun src -> Current_timestamp
let current_user () = fun src -> Current_user
let database () = fun src -> Database
let current_date () = fun _src -> Current_date
let current_time () = fun _src -> Current_time
let current_timestamp () = fun _src -> Current_timestamp
let current_user () = fun _src -> Current_user
let database () = fun _src -> Database
let date_of : ('s M.Select.source -> [< `Date | `Datetime] time t) -> 's M.Select.source -> [`Date] time t = fun f src -> DateFn (f src)
let date_add f i u = fun src -> Date_add (f src, i, u)
let date_format f fmt = fun src -> Date_format (f src, fmt)
Expand All @@ -448,7 +448,7 @@ module Expr = struct
let ifnull f g = fun src -> Ifnull (f src, g src)
let last_day f = fun src -> Last_day (f src)
let length f = fun src -> Length (f src)
let localtime () = fun src -> Localtime
let localtime () = fun _src -> Localtime
let log f = fun src -> Log (f src)
let log10 f = fun src -> Log10 (f src)
let log2 f = fun src -> Log2 (f src)
Expand All @@ -460,7 +460,7 @@ module Expr = struct
let minute f = fun src -> Minute (f src)
let month f = fun src -> Month (f src)
let monthname f = fun src -> Monthname (f src)
let now () = fun src -> Now
let now () = fun _src -> Now
let nullif f g = fun src -> Nullif (f src, g src)
let ord f = fun src -> Ord (f src)
let pow f = fun src -> Pow (f src)
Expand Down Expand Up @@ -489,23 +489,23 @@ module Expr = struct
let timestampdiff u f g = fun src -> Timestampdiff (u, f src, g src)
let trim f = fun src -> Trim (f src)
let uncompress f = fun src -> Uncompress (f src)
let utc_date () = fun src -> Utc_date
let utc_time () = fun src -> Utc_time
let utc_timestamp () = fun src -> Utc_timestamp
let uuid () = fun src -> Uuid
let uuid_short () = fun src -> Uuid_short
let week () = fun src -> Week
let weekday () = fun src -> Weekday
let weekofyear () = fun src -> Weekofyear
let utc_date () = fun _src -> Utc_date
let utc_time () = fun _src -> Utc_time
let utc_timestamp () = fun _src -> Utc_timestamp
let uuid () = fun _src -> Uuid
let uuid_short () = fun _src -> Uuid_short
let week () = fun _src -> Week
let weekday () = fun _src -> Weekday
let weekofyear () = fun _src -> Weekofyear
let upper f = fun src -> Upper (f src)
let year () = fun src -> Year
let year () = fun _src -> Year

let as_time f = fun src -> Cast (f src, Time)
let as_timestamp f = fun src -> Cast (f src, Timestamp)
let as_date f = fun src -> Cast (f src, Date)
let as_datetime f = fun src -> Cast (f src, Datetime)

let rec build
let build
: type a. handover:handover -> build_step -> a t -> build_step =
fun ~handover st e ->
let build_param = build_param D.placeholder in
Expand Down Expand Up @@ -543,7 +543,7 @@ module Expr = struct
| Collation e -> fn "COLLATION(" [e] ")"
| Compress e -> fn "COMPRESS(" [e] ")"
| Concat l -> fn "CONCAT(" l ")"
| Concat_ws (s, l) -> fn "CONCAT_WS" l ")"
| Concat_ws (_s, l) -> fn "CONCAT_WS" l ")"
| Connection_id -> fn "CONNECTION_ID" [] ")"
| Conv (e1, i, j) -> fn "CONV(" [e1] (sprintf ", %d, %d)" i j)
| Cos e -> fn "COS(" [e] ")"
Expand Down Expand Up @@ -577,13 +577,13 @@ module Expr = struct
| If (b, t, f) ->
let st1 = fn "CASE WHEN " [b] " THEN " in
let st2 = fn ~st:st1 (st1.repr ^ " ELSE ") [t; f] " END " in
Sequoia.{ st2 with params = st1.params @ st2.params }
{ st2 with params = st1.params @ st2.params }
| From_days e -> fn "FROM_DAYS(" [e] ")"
| From_unixtime e -> fn "FROM_UNIXTIME(" [e] ")"
| Ifnull (e1, e2) ->
let st1 = fn "IFNULL(" [e1] "" in
let st2 = fn ~st:st1 (st1.repr ^ ", ") [e2] ")" in
Sequoia.{ st2 with params = st1.params @ st2.params }
{ st2 with params = st1.params @ st2.params }
| Last_day e -> fn "LAST_DAY(" [e] ")"
| Length e -> fn "LENGTH(" [e] ")"
| Localtime -> fn "LOCALTIME(" [] ")"
Expand Down
6 changes: 6 additions & 0 deletions ppx/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(library
(name sequoia_ppx)
(public_name sequoia-ppx)
(kind ppx_rewriter)
(libraries sequoia ppx_tools_versioned ocaml-migrate-parsetree)
(flags (:standard -w -9)))
11 changes: 0 additions & 11 deletions ppx/jbuild

This file was deleted.

14 changes: 7 additions & 7 deletions ppx/sequoia_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let rec map_expr_list loc f = function
let e = map_expr_list pexp_loc f e in
{ expr with pexp_desc = Pexp_open (ovr, loc, e) }

| e ->
| _e ->
error loc "unexpected element in select expression"

let add_table t u ts =
Expand Down Expand Up @@ -104,7 +104,7 @@ let rec map_query st loc = function
(* from MyTable.table *)
| { pexp_desc =
Pexp_apply ({ pexp_desc =
Pexp_ident { txt = Lident "from"; loc } },
Pexp_ident { txt = Lident "from" } },
[(_, { pexp_desc =
Pexp_ident { txt = Ldot (Lident t, _) } })]) } as e ->
st.tables := [t];
Expand Down Expand Up @@ -183,7 +183,7 @@ let rec map_query st loc = function
(([ (Nolabel,
{ pexp_desc =
Pexp_ident
{ txt = Ldot (Lident tbl, fld) ; loc } })
{ txt = Ldot (Lident tbl, _fld) ; loc } })
; _
]) as args)) } as join_args))]) } as e
when join_fun = "left_join"
Expand Down Expand Up @@ -261,7 +261,7 @@ let rec map_query st loc = function
Pexp_ident { txt = Lident fn; loc } } as fld),
([ (Nolabel,
{ pexp_desc =
Pexp_ident { txt = Ldot (Lident table, field) } })
Pexp_ident { txt = Ldot (Lident table, _field) } })
] as args)) } as e
when fn = "field"|| fn = "foreign_key" ->
let steps = build_steps (index loc table !(st.tables)) in
Expand All @@ -283,7 +283,7 @@ let rec map_query st loc = function
| e ->
e

and map_select st loc = function
and map_select st _loc = function
(* select [...; field|foreign_key|unwrap Table.field; ...] *)
| { pexp_desc =
Pexp_apply
Expand All @@ -298,7 +298,7 @@ and map_select st loc = function
(* select [...; subquery (from ...); ...] *)
| { pexp_desc =
Pexp_apply (({ pexp_desc =
Pexp_ident { txt = Lident "subquery"; loc } } as sub),
Pexp_ident { txt = Lident "subquery" } } as sub),
[(lbl, expr)]) } as e ->

let st' = { st with tables = ref [] } in
Expand All @@ -321,7 +321,7 @@ and map_select st loc = function
| e ->
e

let rec map_module table references loc = function
let rec map_module table references _loc = function
| [] -> ()

(* Field.foreign_key name ~references:Some.field *)
Expand Down
Loading