Skip to content

Commit

Permalink
fix: inaccurate A_Const type
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Oct 2, 2024
1 parent b5c890b commit b2a027f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion scripts/generateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ async function main() {
namedFields[0].name.endsWith('val') &&
namedFields[0].name.length > 3
) {
constTypes.push(typeName)
// A_Const double-wraps the value for some strange reason.
// https://github.com/pganalyze/libpg_query/issues/265
constTypes.push(`{ ${namedFields[0].name}: ${typeName} }`)
}

const fieldMetadata = nodeFieldsByTag[typeName]
Expand Down Expand Up @@ -428,6 +430,9 @@ async function main() {
}
})

// A_Const can represent a NULL value.
constTypes.push('{ isnull: true }')

code += '\n'
code += `/** A qualified name for referencing a database object, e.g. "public.my_table" */\n`
code += 'export type QualifiedName = { String: String }[]\n'
Expand Down
8 changes: 7 additions & 1 deletion src/lib/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6779,7 +6779,13 @@ export type QualifiedName = { String: String }[]

export type List<T = Node> = { items: T[] }

export type A_Const = BitString | Boolean | Float | Integer | String
export type A_Const =
| { boolval: Boolean }
| { bsval: BitString }
| { fval: Float }
| { isnull: true }
| { ival: Integer }
| { sval: String }

/**
* Expr - generic superclass for executable-expression nodes
Expand Down

0 comments on commit b2a027f

Please sign in to comment.