Mercurial > hg > egg-tcls
changeset 517:894bc9632ece
quotedb: Check if any search parameters have been given, error out if not.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 02 May 2020 07:38:07 +0300 |
parents | 4995ee3a95db |
children | 7fdc069840cc |
files | config.quotedb.example quotedb.tcl |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/config.quotedb.example Sat May 02 07:17:17 2020 +0300 +++ b/config.quotedb.example Sat May 02 07:38:07 2020 +0300 @@ -70,6 +70,7 @@ "fmt_search" "#@1@: @2@ (@3@@@4@)" "no_matches" "@name@-haku ei tuottanut tuloksia." + "no_arguments" "Hakuparametreja ei annettu?" "you_voted" "Äänestit @name@ #@1@ -> @2@, arvosana nyt @3@" "vote_updated" "@name@-äänesi #@1@ päivitetty -> @2@, arvosana nyt @3@"
--- a/quotedb.tcl Sat May 02 07:17:17 2020 +0300 +++ b/quotedb.tcl Sat May 02 07:38:07 2020 +0300 @@ -414,12 +414,15 @@ lappend fpatlist "utext LIKE '%[utl_escape $ftoken]%'" } } - if {[llength $fpatlist] > 0} { - set fquery "WHERE [join $fpatlist " AND "]" - } else { - set fquery "" + + # Check if any arguments exist + if {[llength $fpatlist] == 0} { + qdb_msg $ucmd $utable $upublic $unick $uchan "no_arguments" + return 0 } + set fquery "WHERE [join $fpatlist " AND "]" + ### Query the database and output results set uresults 0 set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit"