Skip to content

Commit

Permalink
🐝 remove ?? for indentifier names in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Feb 27, 2024
1 parent 07a36dd commit d1f180f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions db/model/Variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ export async function writeVariableCSV(
id as variableId,
name as variableName,
columnOrder
FROM ?? v
FROM variables v
WHERE id IN (?)`,
[VariablesTableName, variableIds],
[variableIds],
knex
)
).withColumn(pl.col("variableId").cast(pl.Int32))
Expand Down Expand Up @@ -260,11 +260,11 @@ export const getDataValue = async (
const unit = (
await knexRawFirst<Pick<DbRawVariable, "unit">>(
`-- sql
SELECT unit FROM ??
SELECT unit FROM variables
WHERE id = ?
`,
knex,
[VariablesTableName, variableId]
[variableId]
)
)?.unit

Expand Down Expand Up @@ -299,11 +299,11 @@ export const getOwidChartDimensionConfigForVariable = async (
const row = await db.knexRawFirst<{ dimensions: string }>(
`
SELECT config->"$.dimensions" AS dimensions
FROM ??
FROM charts
WHERE id = ?
`,
knex,
[ChartsTableName, chartId]
[chartId]
)
if (!row?.dimensions) return
const dimensions = JSON.parse(row.dimensions)
Expand Down
4 changes: 2 additions & 2 deletions db/tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ test("knex interface", async () => {
// Use raw queries, using ?? to specify the table name using the shared const value
// The pick type is used to type the result row
const usersFromRawQuery: Pick<DbPlainUser, "email">[] = await knexRaw(
"select email from ??",
"select email from users",
trx,
[UsersTableName]
[]
)
expect(usersFromRawQuery.length).toBe(2)
await deleteUser(trx, 2)
Expand Down

0 comments on commit d1f180f

Please sign in to comment.