From e57d880c44ad0dec90ee2183051a79c8df77a0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Thu, 18 Nov 2021 11:40:15 +0100 Subject: [PATCH] sql: use $N instead of ?N as numbered placeholder --- bin/migrations/m20210126.ml | 2 +- bin/migrations/m20210531.ml | 2 +- bin/migrations/m20210602.ml | 2 +- bin/migrations/m20210706.ml | 2 +- bin/migrations/m20210707b.ml | 2 +- bin/migrations/m20210707c.ml | 2 +- bin/migrations/m20210707d.ml | 2 +- bin/migrations/m20210712a.ml | 4 ++-- bin/migrations/m20210712c.ml | 4 ++-- bin/migrations/m20210910.ml | 2 +- bin/migrations/m20211105.ml | 2 +- db/builder_db.ml | 34 +++++++++++++++++----------------- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bin/migrations/m20210126.ml b/bin/migrations/m20210126.ml index 19a6f46..6c06c00 100644 --- a/bin/migrations/m20210126.ml +++ b/bin/migrations/m20210126.ml @@ -28,7 +28,7 @@ let bin_artifact = let set_main_binary = Caqti_request.exec ~oneshot:true 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 open Grej.Infix in diff --git a/bin/migrations/m20210531.ml b/bin/migrations/m20210531.ml index 359c719..6e15bbc 100644 --- a/bin/migrations/m20210531.ml +++ b/bin/migrations/m20210531.ml @@ -13,7 +13,7 @@ let build_artifacts = let build_artifact_update_localpath = Caqti_request.exec ~oneshot:true 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 *) diff --git a/bin/migrations/m20210602.ml b/bin/migrations/m20210602.ml index 808c5d4..e626b5e 100644 --- a/bin/migrations/m20210602.ml +++ b/bin/migrations/m20210602.ml @@ -85,7 +85,7 @@ let find_main_artifact_id = Caqti_request.find ~oneshot:true Caqti_type.(tup2 Builder_db.Rep.untyped_id string) 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 = Caqti_request.find ~oneshot:true diff --git a/bin/migrations/m20210706.ml b/bin/migrations/m20210706.ml index 1ca5867..7248ee9 100644 --- a/bin/migrations/m20210706.ml +++ b/bin/migrations/m20210706.ml @@ -75,7 +75,7 @@ let builds = let set_input_id = Caqti_request.exec (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 diff --git a/bin/migrations/m20210707b.ml b/bin/migrations/m20210707b.ml index 49978cc..cfde55d 100644 --- a/bin/migrations/m20210707b.ml +++ b/bin/migrations/m20210707b.ml @@ -21,7 +21,7 @@ let get_localpath = let update_paths = Caqti_request.exec (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 open Grej.Infix in diff --git a/bin/migrations/m20210707c.ml b/bin/migrations/m20210707c.ml index f31651a..8e4956e 100644 --- a/bin/migrations/m20210707c.ml +++ b/bin/migrations/m20210707c.ml @@ -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 = Caqti_request.exec (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 = Caqti_request.exec diff --git a/bin/migrations/m20210707d.ml b/bin/migrations/m20210707d.ml index 0561133..14b31bd 100644 --- a/bin/migrations/m20210707d.ml +++ b/bin/migrations/m20210707d.ml @@ -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 = Caqti_request.exec (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 open Grej.Infix in diff --git a/bin/migrations/m20210712a.ml b/bin/migrations/m20210712a.ml index e730d2f..7a50ed9 100644 --- a/bin/migrations/m20210712a.ml +++ b/bin/migrations/m20210712a.ml @@ -47,7 +47,7 @@ let old_build_execution_result = let update_new_build_execution_result = Caqti_request.exec 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 = Caqti_request.exec @@ -94,7 +94,7 @@ let new_build_execution_result = let update_old_build_execution_result = Caqti_request.exec 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 = Caqti_request.exec diff --git a/bin/migrations/m20210712c.ml b/bin/migrations/m20210712c.ml index 6fa84d9..7e36cee 100644 --- a/bin/migrations/m20210712c.ml +++ b/bin/migrations/m20210712c.ml @@ -107,7 +107,7 @@ let old_build_console_script = let update_new_build_console_script = Caqti_request.exec 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 = Caqti_request.collect @@ -118,7 +118,7 @@ let new_build_console_script = let update_old_build_console_script = Caqti_request.exec 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 = Caqti_request.exec diff --git a/bin/migrations/m20210910.ml b/bin/migrations/m20210910.ml index 191517f..f21478c 100644 --- a/bin/migrations/m20210910.ml +++ b/bin/migrations/m20210910.ml @@ -7,7 +7,7 @@ let mixups = let fixup = Caqti_request.exec ~oneshot:true (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 open Grej.Infix in diff --git a/bin/migrations/m20211105.ml b/bin/migrations/m20211105.ml index 9aa3f70..a270526 100644 --- a/bin/migrations/m20211105.ml +++ b/bin/migrations/m20211105.ml @@ -85,7 +85,7 @@ let build_id_and_user = let update_new_build_platform = Caqti_request.exec 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 = Caqti_request.exec diff --git a/db/builder_db.ml b/db/builder_db.ml index cf156e1..10f0dab 100644 --- a/db/builder_db.ml +++ b/db/builder_db.ml @@ -140,12 +140,12 @@ module Job_tag = struct let add = Caqti_request.exec 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 = Caqti_request.exec 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 = Caqti_request.find_opt @@ -326,8 +326,8 @@ module Build = struct INNER JOIN job ON job.id = b.job WHERE b.result_code <> 0 ORDER BY start_d DESC, start_ps DESC - LIMIT ?2 - OFFSET ?1 + LIMIT $2 + OFFSET $1 |} let get_all_failed_by_platform = @@ -339,10 +339,10 @@ module Build = struct b.main_binary, b.input_id, b.user, b.job FROM build b 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 - LIMIT ?2 - OFFSET ?1 + LIMIT $2 + OFFSET $1 |} let get_all_artifact_sha = @@ -404,7 +404,7 @@ module Build = struct FROM build b LEFT JOIN build_artifact a ON 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 LIMIT 1 |} @@ -432,7 +432,7 @@ module Build = struct b.result_code, b.result_msg, b.console, b.script, b.platform, b.main_binary, b.input_id, b.user, b.job 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 LIMIT 1 |} @@ -590,7 +590,7 @@ module Build = struct let set_main_binary = Caqti_request.exec (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 = Caqti_request.exec @@ -652,13 +652,13 @@ module User = struct Caqti_request.exec user_info {| UPDATE user - SET password_hash = ?2, - password_salt = ?3, - scrypt_n = ?4, - scrypt_r = ?5, - scrypt_p = ?6, - restricted = ?7 - WHERE username = ?1 + SET password_hash = $2, + password_salt = $3, + scrypt_n = $4, + scrypt_r = $5, + scrypt_p = $6, + restricted = $7 + WHERE username = $1 |} end