Skip to content

Commit c19b906

Browse files
committed
fix: force some fields to be nullable
These fields were incorrectly inferred from test cases.
1 parent 1fdb431 commit c19b906

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

scripts/typeMappings.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,23 @@ export const expressionFields = new Set([
6666
/**
6767
* If a field's nullability is incorrectly inferred, add it here.
6868
*/
69-
export const nullableFields = new Set(['Alias.colnames', 'Boolean.boolval'])
69+
export const nullableFields = new Set([
70+
'A_Expr.rexpr',
71+
'A_Indices.uidx',
72+
'AccessPriv.priv_name',
73+
'Aggref.aggdistinct',
74+
'Alias.colnames',
75+
'Boolean.boolval',
76+
'ClosePortalStmt.portalname',
77+
'ClusterStmt.relation',
78+
'CurrentOfExpr.cursor_name',
79+
'DeallocateStmt.name',
80+
'IntoClause.viewQuery',
81+
'OnConflictClause.infer',
82+
'SetOperationStmt.groupClauses',
83+
'SubPlan.testexpr',
84+
'VacuumRelation.relation',
85+
])
7086

7187
function Node(types: string) {
7288
return types

src/lib/ast.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ export type A_Expr = {
15301530
/** left argument, or NULL if none */
15311531
lexpr?: Expr
15321532
/** right argument, or NULL if none */
1533-
rexpr: Expr
1533+
rexpr?: Expr
15341534
/** token location, or -1 if unknown */
15351535
location: number
15361536
}
@@ -1627,7 +1627,7 @@ export type A_Indices = {
16271627
/** slice lower bound, if any */
16281628
lidx?: { A_Const: A_Const }
16291629
/** subscript, or slice upper bound if any */
1630-
uidx: { A_Const: A_Const } | { ColumnRef: ColumnRef }
1630+
uidx?: { A_Const: A_Const } | { ColumnRef: ColumnRef }
16311631
}
16321632

16331633
/**
@@ -2365,7 +2365,7 @@ export type OnConflictClause = {
23652365
/** DO NOTHING or UPDATE? */
23662366
action: OnConflictAction
23672367
/** Optional index inference clause */
2368-
infer: InferClause
2368+
infer?: InferClause
23692369
/** the target list (of ResTarget) */
23702370
targetList: any[]
23712371
/** qualifications */
@@ -2841,7 +2841,7 @@ export type SetOperationStmt = {
28412841
/** OID list of output column collation OIDs */
28422842
colCollations: any[]
28432843
/** a list of SortGroupClause's */
2844-
groupClauses: any[]
2844+
groupClauses?: any[]
28452845
/** groupClauses is NIL if UNION ALL, but must be set otherwise */
28462846
}
28472847

@@ -3049,7 +3049,7 @@ export type ObjectWithArgs = {
30493049
*/
30503050
export type AccessPriv = {
30513051
/** string name of privilege */
3052-
priv_name: string
3052+
priv_name?: string
30533053
/** list of String */
30543054
cols?: { String: String }[]
30553055
}
@@ -3871,7 +3871,7 @@ export type DeclareCursorStmt = {
38713871
*/
38723872
export type ClosePortalStmt = {
38733873
/** name of the portal (cursor) */
3874-
portalname: string
3874+
portalname?: string
38753875
/** NULL means CLOSE ALL */
38763876
}
38773877

@@ -4420,7 +4420,7 @@ export type AlterSystemStmt = {
44204420
*/
44214421
export type ClusterStmt = {
44224422
/** relation being indexed, or NULL if all */
4423-
relation: RangeVar
4423+
relation?: RangeVar
44244424
/** original index defined */
44254425
indexname?: string
44264426
/** list of DefElem nodes */
@@ -4452,7 +4452,7 @@ export type VacuumStmt = {
44524452
*/
44534453
export type VacuumRelation = {
44544454
/** table name to process, or NULL */
4455-
relation: RangeVar
4455+
relation?: RangeVar
44564456
/** table's OID; InvalidOid if not looked up */
44574457
oid?: Oid
44584458
/** list of column names, or NIL for all */
@@ -4644,7 +4644,7 @@ export type ExecuteStmt = {
46444644
*/
46454645
export type DeallocateStmt = {
46464646
/** The name of the plan to remove */
4647-
name: string
4647+
name?: string
46484648
/** NULL means DEALLOCATE ALL */
46494649
}
46504650

@@ -4841,7 +4841,7 @@ export type IntoClause = {
48414841
/** table space to use, or NULL */
48424842
tableSpaceName?: string
48434843
/** materialized view's SELECT query */
4844-
viewQuery: Node
4844+
viewQuery?: Node
48454845
/** true for WITH NO DATA */
48464846
skipData: boolean
48474847
}
@@ -5037,7 +5037,7 @@ export type Aggref = {
50375037
/** ORDER BY (list of SortGroupClause) */
50385038
aggorder: any[]
50395039
/** DISTINCT (list of SortGroupClause) */
5040-
aggdistinct: any[]
5040+
aggdistinct?: any[]
50415041
/** FILTER expression, if any */
50425042
aggfilter?: Expr
50435043
/** true if argument list was really '*' */
@@ -5445,7 +5445,7 @@ export type SubPlan = {
54455445
subLinkType: SubLinkType
54465446
/** The combining operators, transformed to an executable expression: */
54475447
/** OpExpr or RowCompareExpr expression tree */
5448-
testexpr: Expr
5448+
testexpr?: Expr
54495449
/** IDs of Params embedded in the above */
54505450
paramIds: any[]
54515451
/** Identification of the Plan tree to use: */
@@ -6128,7 +6128,7 @@ export type CurrentOfExpr = {
61286128
/** RT index of target relation */
61296129
cvarno?: Index
61306130
/** name of referenced cursor, or NULL */
6131-
cursor_name: string
6131+
cursor_name?: string
61326132
/** refcursor parameter number, or 0 */
61336133
cursor_param?: number
61346134
}

0 commit comments

Comments
 (0)