Skip to content

Commit

Permalink
Always use db name explicitly
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Mangani <[email protected]>
  • Loading branch information
lmangani authored Oct 22, 2023
1 parent 0e898f5 commit f82c3dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/db/clickhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ const samplesReadTable = {
}
logger.info('checking last timestamp')
const v1EndTime = await axios.post(`${getClickhouseUrl()}/?database=${UTILS.DATABASE_NAME()}`,
`SELECT max(timestamp_ns) as ts FROM ${tableName} format JSON`)
`SELECT max(timestamp_ns) as ts FROM ${UTILS.DATABASE_NAME()}.${tableName} format JSON`)
if (!v1EndTime.data.rows) {
samplesReadTable.v1 = false
return
Expand All @@ -1319,7 +1319,7 @@ const samplesReadTable = {
settingsVersions: async function () {
const versions = await axios.post(`${getClickhouseUrl()}/?database=${UTILS.DATABASE_NAME()}`,
`SELECT argMax(name, inserted_at) as _name, argMax(value, inserted_at) as _value
FROM settings${dist} WHERE type == 'update' GROUP BY fingerprint HAVING _name != '' FORMAT JSON`)
FROM ${UTILS.DATABASE_NAME()}.settings${dist} WHERE type == 'update' GROUP BY fingerprint HAVING _name != '' FORMAT JSON`)
for (const version of versions.data.data) {
this.versions[version._name] = parseInt(version._value) * 1000
}
Expand Down Expand Up @@ -1355,7 +1355,7 @@ const getSettings = async (names, database) => {
'short-hash'))
const settings = await rawRequest(`SELECT argMax(name, inserted_at) as _name,
argMax(value, inserted_at) as _value
FROM settings${dist} WHERE fingerprint IN (${fps.join(',')}) GROUP BY fingerprint HAVING _name != '' FORMAT JSON`,
FROM ${UTILS.DATABASE_NAME()}.settings${dist} WHERE fingerprint IN (${fps.join(',')}) GROUP BY fingerprint HAVING _name != '' FORMAT JSON`,
null, database)
return settings.data.data.reduce((sum, cur) => {
sum[cur._name] = cur._value
Expand All @@ -1373,7 +1373,7 @@ const getSettings = async (names, database) => {
*/
const addSetting = async (type, name, value, database) => {
const fp = UTILS.fingerPrint(JSON.stringify({ type: type, name: name }), false, 'short-hash')
return rawRequest('INSERT INTO settings (fingerprint, type, name, value, inserted_at) FORMAT JSONEachRow',
return rawRequest('INSERT INTO ${UTILS.DATABASE_NAME()}.settings (fingerprint, type, name, value, inserted_at) FORMAT JSONEachRow',
JSON.stringify({
fingerprint: fp,
type: type,
Expand Down

0 comments on commit f82c3dc

Please sign in to comment.