diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2023-03-06 13:10:52 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2023-03-06 13:10:52 +0900 |
commit | b7d361f211812e6aab73ef038b06563198611af0 (patch) | |
tree | 5406988fe7a081baae900b40d13c16d44f81b39e | |
parent | 85bb05cbd88a0021cfa5974d9dc15d3aae3814df (diff) | |
download | hybring-b7d361f211812e6aab73ef038b06563198611af0.tar.gz |
Correct uniqueness check
-rw-r--r-- | src/http.cr | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/http.cr b/src/http.cr index 192a398..ac688fb 100644 --- a/src/http.cr +++ b/src/http.cr @@ -93,10 +93,10 @@ class Server next http_error context, 400, "Invalid Parameter" if invalid_param next http_error context, 400, "Missing Parameter" unless params.size == 4 - - @db.exec "SELECT count(nick), count(opennic), count(icann) - FROM member - WHERE nick = %Q OR opennic = %Q OR icann = %Q", + @db.exec "SELECT count(CASE WHEN nick = %Q THEN 1 END), + count(CASE WHEN opennic = %Q THEN 1 END), + count(CASE WHEN icann = %Q THEN 1 END) + FROM member", params["nick"], params["opennic"], params["icann"] do |row| errors["nick"] = "Must be unique" if row[0].int > 0 errors["opennic"] = "Must be unique" if row[1].int > 0 @@ -122,7 +122,6 @@ class Server end end - getter db getter opennic_page getter icann_page |