remove ';' from queries

This commit is contained in:
Swrup 2022-04-04 21:15:04 +02:00
parent 6b5bfcd144
commit 613d901bca
5 changed files with 77 additions and 78 deletions

View file

@ -47,150 +47,149 @@ module Q = struct
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_user (post_id TEXT, user_id TEXT, \
PRIMARY KEY(post_id), FOREIGN KEY(user_id) REFERENCES user(user_id) ON \
DELETE CASCADE);"
DELETE CASCADE)"
(* one row for each thread, with thread's data *)
let create_thread_info_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS thread_info (thread_id TEXT, subject TEXT, \
lat FLOAT, lng FLOAT, FOREIGN KEY(thread_id) REFERENCES \
post_user(post_id) ON DELETE CASCADE);"
post_user(post_id) ON DELETE CASCADE)"
(* map thread and reply to the thread *)
let create_thread_post_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS thread_post (thread_id TEXT, post_id TEXT, \
FOREIGN KEY(thread_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);"
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_replies_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_replies (post_id TEXT, reply_id TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \
FOREIGN KEY(reply_id) REFERENCES post_user(post_id) ON DELETE CASCADE);"
FOREIGN KEY(reply_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_citations_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_citations (post_id TEXT, cited_id TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE, \
FOREIGN KEY(cited_id) REFERENCES post_user(post_id) ON DELETE CASCADE);"
FOREIGN KEY(cited_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_date_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_date (post_id TEXT, date FLOAT, FOREIGN \
KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);"
KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_comment_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_comment (post_id TEXT, comment TEXT, \
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);"
FOREIGN KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_post_tags_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS post_tags (post_id TEXT, tag TEXT, FOREIGN \
KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE);"
KEY(post_id) REFERENCES post_user(post_id) ON DELETE CASCADE)"
let create_report_table =
(Caqti_type.unit ->. Caqti_type.unit)
"CREATE TABLE IF NOT EXISTS report (user_id TEXT, reason TEXT, date \
FLOAT,post_id TEXT, FOREIGN KEY(post_id) REFERENCES post_user(post_id) \
ON DELETE CASCADE, FOREIGN KEY(user_id) REFERENCES user(user_id) ON \
DELETE CASCADE);"
DELETE CASCADE)"
let upload_report =
(Caqti_type.(tup4 string string float string) ->. Caqti_type.unit)
"INSERT INTO report VALUES (?,?,?,?);"
"INSERT INTO report VALUES (?,?,?,?)"
let ignore_report =
(Caqti_type.string ->. Caqti_type.unit)
"DELETE FROM report WHERE post_id=?;"
(Caqti_type.string ->. Caqti_type.unit) "DELETE FROM report WHERE post_id=?"
let get_reports =
(Caqti_type.unit ->* Caqti_type.(tup4 string string float string))
"SELECT * FROM report;"
"SELECT * FROM report"
let upload_post_id =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_user VALUES (?,?);"
"INSERT INTO post_user VALUES (?,?)"
let upload_thread_info =
(Caqti_type.(tup4 string string float float) ->. Caqti_type.unit)
"INSERT INTO thread_info VALUES (?,?,?,?);"
"INSERT INTO thread_info VALUES (?,?,?,?)"
let upload_thread_post =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO thread_post VALUES (?,?);"
"INSERT INTO thread_post VALUES (?,?)"
let upload_post_reply =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_replies VALUES (?,?);"
"INSERT INTO post_replies VALUES (?,?)"
let upload_post_comment =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_comment VALUES (?,?);"
"INSERT INTO post_comment VALUES (?,?)"
let upload_post_tag =
(Caqti_type.(tup2 string string) ->. Caqti_type.unit)
"INSERT INTO post_tags VALUES (?,?);"
"INSERT INTO post_tags VALUES (?,?)"
let upload_post_date =
(Caqti_type.(tup2 string float) ->. Caqti_type.unit)
"INSERT INTO post_date VALUES (?,?);"
"INSERT INTO post_date VALUES (?,?)"
let get_post_user_id =
(Caqti_type.string ->! Caqti_type.string)
"SELECT user_id FROM post_user WHERE post_id=?;"
"SELECT user_id FROM post_user WHERE post_id=?"
let get_post_comment =
(Caqti_type.string ->! Caqti_type.string)
"SELECT comment FROM post_comment WHERE post_id=?;"
"SELECT comment FROM post_comment WHERE post_id=?"
let get_post_tags =
(Caqti_type.string ->* Caqti_type.string)
"SELECT tag FROM post_tags WHERE post_id=?;"
"SELECT tag FROM post_tags WHERE post_id=?"
let get_post_date =
(Caqti_type.string ->! Caqti_type.float)
"SELECT date FROM post_date WHERE post_id=?;"
"SELECT date FROM post_date WHERE post_id=?"
let get_post_citations =
(Caqti_type.string ->* Caqti_type.string)
"SELECT post_id FROM post_citations WHERE post_id=?;"
"SELECT post_id FROM post_citations WHERE post_id=?"
let get_post_replies =
(Caqti_type.string ->* Caqti_type.string)
"SELECT reply_id FROM post_replies WHERE post_id=?;"
"SELECT reply_id FROM post_replies WHERE post_id=?"
let get_thread_posts =
(Caqti_type.string ->* Caqti_type.string)
"SELECT post_id FROM thread_post WHERE thread_id=?;"
"SELECT post_id FROM thread_post WHERE thread_id=?"
let count_thread_posts =
(Caqti_type.string ->! Caqti_type.int)
"SELECT COUNT(post_id) FROM thread_post WHERE thread_id=?;"
"SELECT COUNT(post_id) FROM thread_post WHERE thread_id=?"
let get_is_thread =
(Caqti_type.string ->! Caqti_type.string)
"SELECT thread_id FROM thread_info WHERE thread_id=? LIMIT 1;"
"SELECT thread_id FROM thread_info WHERE thread_id=? LIMIT 1"
let get_is_post =
(Caqti_type.string ->! Caqti_type.string)
"SELECT post_id FROM post_user WHERE post_id=? LIMIT 1;"
"SELECT post_id FROM post_user WHERE post_id=? LIMIT 1"
let get_post_thread =
(Caqti_type.string ->! Caqti_type.string)
"SELECT thread_id FROM thread_post WHERE post_id=? LIMIT 1;"
"SELECT thread_id FROM thread_post WHERE post_id=? LIMIT 1"
let get_thread_info =
(Caqti_type.string ->! Caqti_type.(tup3 string float float))
"SELECT subject,lat,lng FROM thread_info WHERE thread_id=?;"
"SELECT subject,lat,lng FROM thread_info WHERE thread_id=?"
let get_threads =
(Caqti_type.unit ->* Caqti_type.string) "SELECT thread_id FROM thread_info;"
(Caqti_type.unit ->* Caqti_type.string) "SELECT thread_id FROM thread_info"
let delete_post =
(Caqti_type.string ->. Caqti_type.unit)
"DELETE FROM post_user WHERE post_id=?;"
"DELETE FROM post_user WHERE post_id=?"
end
let () =