sql: use $N instead of ?N as numbered placeholder
This commit is contained in:
parent
088b55acc3
commit
e57d880c44
12 changed files with 30 additions and 30 deletions
|
@ -28,7 +28,7 @@ let bin_artifact =
|
||||||
let set_main_binary =
|
let set_main_binary =
|
||||||
Caqti_request.exec ~oneshot:true
|
Caqti_request.exec ~oneshot:true
|
||||||
Caqti_type.(tup2 int64 (option string))
|
Caqti_type.(tup2 int64 (option string))
|
||||||
"UPDATE build SET main_binary = ?2 WHERE id = ?1"
|
"UPDATE build SET main_binary = $2 WHERE id = $1"
|
||||||
|
|
||||||
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
|
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
|
||||||
let open Grej.Infix in
|
let open Grej.Infix in
|
||||||
|
|
|
@ -13,7 +13,7 @@ let build_artifacts =
|
||||||
let build_artifact_update_localpath =
|
let build_artifact_update_localpath =
|
||||||
Caqti_request.exec ~oneshot:true
|
Caqti_request.exec ~oneshot:true
|
||||||
Caqti_type.(tup2 Builder_db.Rep.untyped_id Builder_db.Rep.fpath)
|
Caqti_type.(tup2 Builder_db.Rep.untyped_id Builder_db.Rep.fpath)
|
||||||
"UPDATE build_artifact SET localpath = ?2 WHERE id = ?1"
|
"UPDATE build_artifact SET localpath = $2 WHERE id = $1"
|
||||||
|
|
||||||
(* We are not migrating build_file because it is unused *)
|
(* We are not migrating build_file because it is unused *)
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ let find_main_artifact_id =
|
||||||
Caqti_request.find ~oneshot:true
|
Caqti_request.find ~oneshot:true
|
||||||
Caqti_type.(tup2 Builder_db.Rep.untyped_id string)
|
Caqti_type.(tup2 Builder_db.Rep.untyped_id string)
|
||||||
Builder_db.Rep.untyped_id
|
Builder_db.Rep.untyped_id
|
||||||
"SELECT id FROM build_artifact WHERE build = ?1 AND filepath = ?2"
|
"SELECT id FROM build_artifact WHERE build = $1 AND filepath = $2"
|
||||||
|
|
||||||
let find_main_artifact_filepath =
|
let find_main_artifact_filepath =
|
||||||
Caqti_request.find ~oneshot:true
|
Caqti_request.find ~oneshot:true
|
||||||
|
|
|
@ -75,7 +75,7 @@ let builds =
|
||||||
let set_input_id =
|
let set_input_id =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
(Caqti_type.tup2 Builder_db.Rep.untyped_id Builder_db.Rep.cstruct)
|
(Caqti_type.tup2 Builder_db.Rep.untyped_id Builder_db.Rep.cstruct)
|
||||||
"UPDATE build SET input_id = ?2 WHERE id = ?1"
|
"UPDATE build SET input_id = $2 WHERE id = $1"
|
||||||
|
|
||||||
open Grej.Infix
|
open Grej.Infix
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ let get_localpath =
|
||||||
let update_paths =
|
let update_paths =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
(Caqti_type.tup3 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
(Caqti_type.tup3 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
||||||
"UPDATE build_artifact SET localpath = ?2, filepath = ?3 WHERE id = ?1"
|
"UPDATE build_artifact SET localpath = $2, filepath = $3 WHERE id = $1"
|
||||||
|
|
||||||
let fixup datadir (module Db : Caqti_blocking.CONNECTION) =
|
let fixup datadir (module Db : Caqti_blocking.CONNECTION) =
|
||||||
let open Grej.Infix in
|
let open Grej.Infix in
|
||||||
|
|
|
@ -14,7 +14,7 @@ let build_not_stripped : ([`build] Builder_db.Rep.id, [`build_artifact] Builder_
|
||||||
let update_paths : ([`build_artifact] Builder_db.Rep.id * Fpath.t * Fpath.t, unit, [< `Zero | `One | `Many > `Zero ]) Caqti_request.t =
|
let update_paths : ([`build_artifact] Builder_db.Rep.id * Fpath.t * Fpath.t, unit, [< `Zero | `One | `Many > `Zero ]) Caqti_request.t =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
(Caqti_type.tup3 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
(Caqti_type.tup3 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
||||||
"UPDATE build_artifact SET localpath = ?2, filepath = ?3 WHERE id = ?1"
|
"UPDATE build_artifact SET localpath = $2, filepath = $3 WHERE id = $1"
|
||||||
|
|
||||||
let add_artifact : ((Fpath.t * Fpath.t * Cstruct.t) * (int64 * [`build] Builder_db.Rep.id), unit, [< `Zero | `One | `Many > `Zero]) Caqti_request.t =
|
let add_artifact : ((Fpath.t * Fpath.t * Cstruct.t) * (int64 * [`build] Builder_db.Rep.id), unit, [< `Zero | `One | `Many > `Zero]) Caqti_request.t =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
|
|
|
@ -8,7 +8,7 @@ let all_build_artifacts_with_dot_slash : (unit, [`build_artifact] Builder_db.Rep
|
||||||
let update_path : ([`build_artifact] Builder_db.Rep.id * Fpath.t, unit, [< `Zero | `One | `Many > `Zero ]) Caqti_request.t =
|
let update_path : ([`build_artifact] Builder_db.Rep.id * Fpath.t, unit, [< `Zero | `One | `Many > `Zero ]) Caqti_request.t =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
(Caqti_type.tup2 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath)
|
(Caqti_type.tup2 (Builder_db.Rep.id `build_artifact) Builder_db.Rep.fpath)
|
||||||
"UPDATE build_artifact SET filepath = ?2 WHERE id = ?1"
|
"UPDATE build_artifact SET filepath = $2 WHERE id = $1"
|
||||||
|
|
||||||
let fixup _datadir (module Db : Caqti_blocking.CONNECTION) =
|
let fixup _datadir (module Db : Caqti_blocking.CONNECTION) =
|
||||||
let open Grej.Infix in
|
let open Grej.Infix in
|
||||||
|
|
|
@ -47,7 +47,7 @@ let old_build_execution_result =
|
||||||
let update_new_build_execution_result =
|
let update_new_build_execution_result =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup2 (Builder_db.Rep.id (`build : [ `build ])) int)
|
Caqti_type.(tup2 (Builder_db.Rep.id (`build : [ `build ])) int)
|
||||||
"UPDATE new_build SET result_code = ?2 WHERE id = ?1"
|
"UPDATE new_build SET result_code = $2 WHERE id = $1"
|
||||||
|
|
||||||
let old_build =
|
let old_build =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
|
@ -94,7 +94,7 @@ let new_build_execution_result =
|
||||||
let update_old_build_execution_result =
|
let update_old_build_execution_result =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup3 (Builder_db.Rep.id (`build : [ `build ])) int (option int))
|
Caqti_type.(tup3 (Builder_db.Rep.id (`build : [ `build ])) int (option int))
|
||||||
"UPDATE new_build SET result_kind = ?2, result_code = ?3 WHERE id = ?1"
|
"UPDATE new_build SET result_kind = $2, result_code = $3 WHERE id = $1"
|
||||||
|
|
||||||
let drop_build =
|
let drop_build =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
|
|
|
@ -107,7 +107,7 @@ let old_build_console_script =
|
||||||
let update_new_build_console_script =
|
let update_new_build_console_script =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup3 (Builder_db.Rep.id (`build : [ `build ])) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
Caqti_type.(tup3 (Builder_db.Rep.id (`build : [ `build ])) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
||||||
"UPDATE new_build SET console = ?2, script = ?3 WHERE id = ?1"
|
"UPDATE new_build SET console = $2, script = $3 WHERE id = $1"
|
||||||
|
|
||||||
let new_build_console_script =
|
let new_build_console_script =
|
||||||
Caqti_request.collect
|
Caqti_request.collect
|
||||||
|
@ -118,7 +118,7 @@ let new_build_console_script =
|
||||||
let update_old_build_console_script =
|
let update_old_build_console_script =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup3 (Builder_db.Rep.id (`build : [ `build ])) Builder_db.Rep.cstruct string)
|
Caqti_type.(tup3 (Builder_db.Rep.id (`build : [ `build ])) Builder_db.Rep.cstruct string)
|
||||||
"UPDATE new_build SET console = ?2, script = ?3 WHERE id = ?1"
|
"UPDATE new_build SET console = $2, script = $3 WHERE id = $1"
|
||||||
|
|
||||||
let drop_build =
|
let drop_build =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
|
|
|
@ -7,7 +7,7 @@ let mixups =
|
||||||
let fixup =
|
let fixup =
|
||||||
Caqti_request.exec ~oneshot:true
|
Caqti_request.exec ~oneshot:true
|
||||||
(Caqti_type.tup3 (Builder_db.Rep.id (`build : [`build])) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
(Caqti_type.tup3 (Builder_db.Rep.id (`build : [`build])) Builder_db.Rep.fpath Builder_db.Rep.fpath)
|
||||||
"UPDATE build SET console = ?2, script = ?3 WHERE id = ?1"
|
"UPDATE build SET console = $2, script = $3 WHERE id = $1"
|
||||||
|
|
||||||
let fixup _datadir (module Db : Caqti_blocking.CONNECTION) =
|
let fixup _datadir (module Db : Caqti_blocking.CONNECTION) =
|
||||||
let open Grej.Infix in
|
let open Grej.Infix in
|
||||||
|
|
|
@ -85,7 +85,7 @@ let build_id_and_user =
|
||||||
let update_new_build_platform =
|
let update_new_build_platform =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup2 (Builder_db.Rep.id (`build : [ `build ])) string)
|
Caqti_type.(tup2 (Builder_db.Rep.id (`build : [ `build ])) string)
|
||||||
"UPDATE new_build SET platform = ?2 WHERE id = ?1"
|
"UPDATE new_build SET platform = $2 WHERE id = $1"
|
||||||
|
|
||||||
let drop_build =
|
let drop_build =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
|
|
|
@ -140,12 +140,12 @@ module Job_tag = struct
|
||||||
let add =
|
let add =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup3 (id `tag) string (id `job))
|
Caqti_type.(tup3 (id `tag) string (id `job))
|
||||||
"INSERT INTO job_tag (tag, value, job) VALUES (?1, ?2, ?3)"
|
"INSERT INTO job_tag (tag, value, job) VALUES ($1, $2, $3)"
|
||||||
|
|
||||||
let update =
|
let update =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
Caqti_type.(tup3 (id `tag) string (id `job))
|
Caqti_type.(tup3 (id `tag) string (id `job))
|
||||||
"UPDATE job_tag SET value = ?2 WHERE tag = ?1 AND job = ?3"
|
"UPDATE job_tag SET value = $2 WHERE tag = $1 AND job = $3"
|
||||||
|
|
||||||
let get_value =
|
let get_value =
|
||||||
Caqti_request.find_opt
|
Caqti_request.find_opt
|
||||||
|
@ -326,8 +326,8 @@ module Build = struct
|
||||||
INNER JOIN job ON job.id = b.job
|
INNER JOIN job ON job.id = b.job
|
||||||
WHERE b.result_code <> 0
|
WHERE b.result_code <> 0
|
||||||
ORDER BY start_d DESC, start_ps DESC
|
ORDER BY start_d DESC, start_ps DESC
|
||||||
LIMIT ?2
|
LIMIT $2
|
||||||
OFFSET ?1
|
OFFSET $1
|
||||||
|}
|
|}
|
||||||
|
|
||||||
let get_all_failed_by_platform =
|
let get_all_failed_by_platform =
|
||||||
|
@ -339,10 +339,10 @@ module Build = struct
|
||||||
b.main_binary, b.input_id, b.user, b.job
|
b.main_binary, b.input_id, b.user, b.job
|
||||||
FROM build b
|
FROM build b
|
||||||
INNER JOIN job ON job.id = b.job
|
INNER JOIN job ON job.id = b.job
|
||||||
WHERE b.result_code <> 0 AND b.platform = ?3
|
WHERE b.result_code <> 0 AND b.platform = $3
|
||||||
ORDER BY start_d DESC, start_ps DESC
|
ORDER BY start_d DESC, start_ps DESC
|
||||||
LIMIT ?2
|
LIMIT $2
|
||||||
OFFSET ?1
|
OFFSET $1
|
||||||
|}
|
|}
|
||||||
|
|
||||||
let get_all_artifact_sha =
|
let get_all_artifact_sha =
|
||||||
|
@ -404,7 +404,7 @@ module Build = struct
|
||||||
FROM build b
|
FROM build b
|
||||||
LEFT JOIN build_artifact a ON
|
LEFT JOIN build_artifact a ON
|
||||||
b.main_binary = a.id
|
b.main_binary = a.id
|
||||||
WHERE b.job = ?1 AND b.platform = ?2 AND b.result_code = 0
|
WHERE b.job = $1 AND b.platform = $2 AND b.result_code = 0
|
||||||
ORDER BY b.start_d DESC, b.start_ps DESC
|
ORDER BY b.start_d DESC, b.start_ps DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
|}
|
|}
|
||||||
|
@ -432,7 +432,7 @@ module Build = struct
|
||||||
b.result_code, b.result_msg, b.console, b.script,
|
b.result_code, b.result_msg, b.console, b.script,
|
||||||
b.platform, b.main_binary, b.input_id, b.user, b.job
|
b.platform, b.main_binary, b.input_id, b.user, b.job
|
||||||
FROM build b
|
FROM build b
|
||||||
WHERE b.job = ?1 AND b.result_code = 0 AND b.platform = ?2
|
WHERE b.job = $1 AND b.result_code = 0 AND b.platform = $2
|
||||||
ORDER BY b.start_d DESC, b.start_ps DESC
|
ORDER BY b.start_d DESC, b.start_ps DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
|}
|
|}
|
||||||
|
@ -590,7 +590,7 @@ module Build = struct
|
||||||
let set_main_binary =
|
let set_main_binary =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
(Caqti_type.tup2 (id `build) (id `build_artifact))
|
(Caqti_type.tup2 (id `build) (id `build_artifact))
|
||||||
"UPDATE build SET main_binary = ?2 WHERE id = ?1"
|
"UPDATE build SET main_binary = $2 WHERE id = $1"
|
||||||
|
|
||||||
let remove =
|
let remove =
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
|
@ -652,13 +652,13 @@ module User = struct
|
||||||
Caqti_request.exec
|
Caqti_request.exec
|
||||||
user_info
|
user_info
|
||||||
{| UPDATE user
|
{| UPDATE user
|
||||||
SET password_hash = ?2,
|
SET password_hash = $2,
|
||||||
password_salt = ?3,
|
password_salt = $3,
|
||||||
scrypt_n = ?4,
|
scrypt_n = $4,
|
||||||
scrypt_r = ?5,
|
scrypt_r = $5,
|
||||||
scrypt_p = ?6,
|
scrypt_p = $6,
|
||||||
restricted = ?7
|
restricted = $7
|
||||||
WHERE username = ?1
|
WHERE username = $1
|
||||||
|}
|
|}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue