Skip to content

Commit

Permalink
Merge pull request #3413 from owid/fix-gdocs-link-select
Browse files Browse the repository at this point in the history
🐛 fix link type clause being optional
  • Loading branch information
danyx23 authored Mar 26, 2024
2 parents 63b9627 + 670ae73 commit 753d99a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions db/model/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export async function getPublishedLinksTo(
ids: string[],
linkType?: OwidGdocLinkType
): Promise<(DbPlainPostGdocLink & { sourceSlug: string })[]> {
const linkTypeClause = linkType ? "AND linkType = ?" : ""
const params = linkType ? [ids, linkType] : [ids]
const rows = await knexRaw<DbPlainPostGdocLink & { sourceSlug: string }>(
knex,
`-- sql
Expand All @@ -25,10 +27,10 @@ export async function getPublishedLinksTo(
JOIN posts_gdocs ON posts_gdocs_links.source = posts_gdocs.id
WHERE
target IN (?)
AND linkType = ?
${linkTypeClause}
AND published = TRUE
`,
[ids, linkType]
params
)
return rows
}
Expand Down

0 comments on commit 753d99a

Please sign in to comment.