Skip to content

Commit

Permalink
Merge pull request #495 from metrico/fix/494_axios_error
Browse files Browse the repository at this point in the history
fix: axios error
  • Loading branch information
akvlad authored May 2, 2024
2 parents e8e01bd + f48d607 commit b6ca6c2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const path = require('path')
module.exports = {
setupFilesAfterEnv: [path.join(__dirname, '/test/jest.setup.js')]
setupFilesAfterEnv: [path.join(__dirname, '/test/jest.setup.js')],
moduleNameMapper: {
'^axios$': 'axios/dist/node/axios.cjs'
}
}
17 changes: 16 additions & 1 deletion lib/db/clickhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,12 +1363,27 @@ const samplesReadTable = {
*/
const rawRequest = async (query, data, database, config) => {
try {
if (data && !(Buffer.isBuffer(data) || data instanceof Uint8Array || typeof data === 'string')) {
throw new Error('data must be Buffer, Uint8Array or String: currently the data is: ' + typeof data)
}
if (typeof data === 'string') {
data = Buffer.from(data, 'utf8')
}
if (typeof query !== 'string') {
throw new Error('query must be String: currently the query is: ' + typeof query)
}
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)
config = {
...(config || {}),
method: 'post',
url: url,
data: data || query
}
return await axios(config)
} catch (e) {
logger.error('rawRequest error: ' + query)
e.response?.data && logger.error(e.response.data.toString())
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@qxip/influx-line-protocol-parser": "^0.2.1",
"@qxip/plugnplay": "^3.3.1",
"@stricjs/router": "^5.0.6",
"axios": "^0.28.0",
"axios": "^1.6.8",
"bnf": "^1.0.1",
"csv-writer": "^1.6.0",
"date-fns": "^2.27.0",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e
Submodule e2e updated from 85e344 to 8847ca
2 changes: 1 addition & 1 deletion traceql/traceql.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cmp ::= "="|"!="|"<="|">="|"<"|">"
cmp_val ::= <number> [<measurement>]
measurement ::= "ns"|"us"|"ms"|"s"|"m"|"h"|"d"

label_name ::= ("." | <ALPHA> | "_") *("." | <ALPHA> | "_" | <DIGITS>)
label_name ::= ("." | <ALPHA> | "-" | "_") *("." | <ALPHA> | "_" | "-" | <DIGITS>)
number ::= ["-"] <DIGITS> ["." <DIGITS>]

attr_selector ::= <label_name> <OWSP> <op> <OWSP> <value>
Expand Down

0 comments on commit b6ca6c2

Please sign in to comment.