Skip to content

Commit

Permalink
Merge pull request #402 from metrico/error_query_log
Browse files Browse the repository at this point in the history
fix: log erroneous queries
  • Loading branch information
akvlad authored Dec 5, 2023
2 parents d58c2ab + 129cf8b commit 7ab86f2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/db/clickhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1353,13 +1353,18 @@ const samplesReadTable = {
* @param config {Object?}
* @returns {Promise<AxiosResponse<any>>}
*/
const rawRequest = (query, data, database, config) => {
const getParams = [
(database ? `database=${encodeURIComponent(database)}` : null),
(data ? `query=${encodeURIComponent(query)}` : null)
].filter(p => p)
const url = `${getClickhouseUrl()}/${getParams.length ? `?${getParams.join('&')}` : ''}`
return axios.post(url, data || query, config)
const rawRequest = async (query, data, database, config) => {
try {
const getParams = [
(database ? `database=${encodeURIComponent(database)}` : null),
(data ? `query=${encodeURIComponent(query)}` : null)
].filter(p => p)
const url = `${getClickhouseUrl()}/${getParams.length ? `?${getParams.join('&')}` : ''}`
return await axios.post(url, data || query, config)
} catch (e) {
logger.error('rawRequest error: ' + query)
throw e
}
}

/**
Expand Down

0 comments on commit 7ab86f2

Please sign in to comment.