From 8762eafbdfb31b21bfbcadbb59a41cded1a10b88 Mon Sep 17 00:00:00 2001 From: Bhargav Date: Mon, 20 Mar 2023 15:56:48 +0530 Subject: [PATCH] fix: loader error message and throw error when limit exist in query in sqlmode (#326) --- web/src/plugins/logs/Index.vue | 22 +++++++++++++++++++++- web/src/plugins/logs/SearchResult.vue | 18 ++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/web/src/plugins/logs/Index.vue b/web/src/plugins/logs/Index.vue index 15b950b7db..1e2a5a3a13 100644 --- a/web/src/plugins/logs/Index.vue +++ b/web/src/plugins/logs/Index.vue @@ -559,6 +559,18 @@ export default defineComponent({ } if (searchObj.meta.sqlMode == true) { + const parsedSQL = parser.astify(searchObj.data.query); + if (parsedSQL.limit != null) { + $q.notify({ + message: "Limit clause is not allowed in the query.", + color: "negative", + position: "top", + timeout: 2000, + }); + + return null; + } + req.query.sql = query + " limit " + req.query.size; req.query["sql_mode"] = "full"; delete req.aggs; @@ -623,7 +635,10 @@ export default defineComponent({ } req.query.sql = b64EncodeUnicode(req.query.sql); - if (!searchObj.meta.sqlMode) { + if ( + !searchObj.meta.sqlMode && + searchObj.data.resultGrid.currentPage == 0 + ) { req.aggs.histogram = b64EncodeUnicode(req.aggs.histogram); } @@ -665,6 +680,11 @@ export default defineComponent({ const queryReq = buildSearch(); + if (queryReq == null) { + dismiss(); + return false; + } + searchService .search({ org_identifier: searchObj.organizationIdetifier, diff --git a/web/src/plugins/logs/SearchResult.vue b/web/src/plugins/logs/SearchResult.vue index 85c8b9f8fc..b8694491e2 100644 --- a/web/src/plugins/logs/SearchResult.vue +++ b/web/src/plugins/logs/SearchResult.vue @@ -233,12 +233,18 @@ export default defineComponent({ const plotChart: any = ref(null); const reDrawChart = () => { - plotChart.value.reDraw( - searchObj.data.histogram.xData, - searchObj.data.histogram.yData, - searchObj.data.histogram.chartParams - ); - plotChart.value.forceReLayout(); + if ( + // eslint-disable-next-line no-prototype-builtins + searchObj.data.histogram.hasOwnProperty("xData") && + searchObj.data.histogram.xData.length > 0 + ) { + plotChart.value.reDraw( + searchObj.data.histogram.xData, + searchObj.data.histogram.yData, + searchObj.data.histogram.chartParams + ); + plotChart.value.forceReLayout(); + } }; const changeMaxRecordToReturn = (val: any) => {