Skip to content

Commit

Permalink
avoid more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Sep 12, 2024
1 parent 4aad9a8 commit 6c02898
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/typegen/src/query/column-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,10 @@ export const analyzeAST = async (
)

if (!matchingResult && formattedQueryAst.type === 'select') {
const columnNames = formattedQueryAst.columns?.map(({alias, expr}, i) => {
let name =
const columnNames = formattedQueryAst.columns?.map(({alias, expr}) => {
const name =
alias?.name || (expr.type === 'ref' ? expr.name : expr.type === 'call' ? expr.function.name : null)
if (name === null || name === '*') {
name = `column_${i}`
}
return name
return name && name !== '*' ? {name} : undefined
})

/** Create a new AST looking like
Expand All @@ -364,7 +361,7 @@ export const analyzeAST = async (
...formattedQueryAst,
columns: formattedQueryAst.columns?.map((c, i) => ({
...c,
alias: {name: columnNames![i]},
alias: columnNames![i],
})),
where: {type: 'boolean', value: false},
},
Expand All @@ -381,11 +378,11 @@ export const analyzeAST = async (
{
type: 'ref',
table: {name: 'temp_view'},
name: columnNames![i],
name: columnNames![i]?.name || '*',
},
],
},
alias: {name: columnNames![i]},
alias: columnNames![i],
})),

from: [
Expand Down

0 comments on commit 6c02898

Please sign in to comment.