diff --git a/scripts/generateTypes.ts b/scripts/generateTypes.ts index 0d23d2a..06ac216 100644 --- a/scripts/generateTypes.ts +++ b/scripts/generateTypes.ts @@ -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] @@ -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' diff --git a/src/lib/ast.ts b/src/lib/ast.ts index 6a0480c..5909708 100644 --- a/src/lib/ast.ts +++ b/src/lib/ast.ts @@ -6779,7 +6779,13 @@ export type QualifiedName = { String: String }[] export type List = { 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