Skip to content

Commit

Permalink
fix: handle view name (with/without extension)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurza committed Sep 24, 2023
1 parent de2b164 commit 5c5456c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/metadata/extractMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ async function processViews(directory: string, schema: Schema) {
viewsPath,
templatesPath
)) {
checkView(name, view) // FIXME: assuming checkView doesn't have side effects
const extension = path.extname(name)
const baseName = path.basename(name, extension)

checkView(baseName, view) // FIXME: assuming checkView doesn't have side effects

schema.set(`${QUERY}.${name}`, {
view,
name,
name: baseName,
cardinality: 'many',
mapping: []
})
}
}

const checkView = (name: string, str: string) => {
const extension = path.extname(name)
const baseName = path.basename(name, extension)

if (!str.includes(`$${baseName} `))
if (!str.includes(`$${name} `))
throw new Error(
`View ${name} should contain select expression assigned to $${baseName} so that target result set is distinguished from other expressions`
`View ${name} should contain select expression assigned to $${name} so that target result set is distinguished from other expressions`
)
}

Expand Down

0 comments on commit 5c5456c

Please sign in to comment.