From c28afa199c5a0264e2d0acff9e4f965e8dafe77c Mon Sep 17 00:00:00 2001 From: Riccardo Date: Wed, 3 Nov 2021 08:44:06 +0200 Subject: [PATCH] added option to use wildcard --- Apps/QueryLogsSqliteApp/App.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Apps/QueryLogsSqliteApp/App.cs b/Apps/QueryLogsSqliteApp/App.cs index 3f826903..4a093db6 100644 --- a/Apps/QueryLogsSqliteApp/App.cs +++ b/Apps/QueryLogsSqliteApp/App.cs @@ -420,7 +420,17 @@ CREATE TABLE IF NOT EXISTS dns_logs whereClause += "rcode = @rcode AND "; if (qname is not null) - whereClause += "qname like @qname AND "; + { + if (qname.Contains("*")) + { + whereClause += "qname like @qname AND "; + qname = qname.Replace("*", "%"); + } + else + { + whereClause += "qname = @qname AND "; + } + } if (qtype is not null) whereClause += "qtype = @qtype AND "; @@ -461,7 +471,7 @@ CREATE TABLE IF NOT EXISTS dns_logs command.Parameters.AddWithValue("@rcode", (byte)rcode); if (qname is not null) - command.Parameters.AddWithValue("@qname", "%"+qname+"%"); + command.Parameters.AddWithValue("@qname", qname); if (qtype is not null) command.Parameters.AddWithValue("@qtype", (ushort)qtype); @@ -540,7 +550,7 @@ ORDER BY row_num" + (descendingOrder ? " DESC" : ""); command.Parameters.AddWithValue("@rcode", (byte)rcode); if (qname is not null) - command.Parameters.AddWithValue("@qname", "%"+qname+"%"); + command.Parameters.AddWithValue("@qname", qname); if (qtype is not null) command.Parameters.AddWithValue("@qtype", (ushort)qtype);