diff --git a/docs/howto/analyze.md b/docs/howto/analyze.md index e7c2c66b41..87541d093e 100644 --- a/docs/howto/analyze.md +++ b/docs/howto/analyze.md @@ -106,4 +106,6 @@ reports the result columns and parameters: ] ``` -Pass `--ast` to also include each statement's parsed AST under an `ast` key. +Pass `--ast` to also include each statement's parsed AST under an `ast` key. It +has the same shape as the output of [`parse`](parse.md), with every node tagged +by type. diff --git a/docs/howto/parse.md b/docs/howto/parse.md index 2227c1f2b6..d46d35f394 100644 --- a/docs/howto/parse.md +++ b/docs/howto/parse.md @@ -48,15 +48,64 @@ The output is a JSON array with one object per statement: "name": "GetAuthor", "cmd": ":one", "ast": { - "Stmt": { + "tag": "RawStmt", + "stmt": { "...": "..." }, - "StmtLocation": 0, - "StmtLen": 42 + "stmt_location": 0, + "stmt_len": 42 } } ] ``` Statements without a `-- name:` annotation (for example schema DDL) omit the -`name` and `cmd` fields. +`name` and `cmd` fields. Field names are `snake_case` versions of the AST node +field names. + +## Node types + +Every node in the AST carries a `tag` naming its type. Some nodes have no +fields of their own, so without it a star, a null literal and an untranslated +clause would all print as `{}`. + +```json +"val": { + "tag": "ColumnRef", + "name": "", + "fields": { + "tag": "List", + "items": [ + { + "tag": "A_Star" + } + ] + }, + "location": 93 +} +``` + +A `tag` of `TODO` marks a clause the dialect's converter does not translate +yet. It means the clause was parsed but is not represented in the AST, not that +the clause was absent from the query. + +## Absent fields + +A field the statement does not use is left out rather than printed as `null`. +An `A_Const` carrying an integer reports only what it has: + +```json +"val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 + }, + "location": 30 +} +``` + +Only absent fields — and empty lists, which engines construct differently for +the same SQL — are omitted. A zero keeps its place, because zero is a value the +parser can find: `stmt_location` is 0 for the first statement in a file, and +`LIMIT 0` parses to an `ival` of 0. diff --git a/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt b/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt index b74264f687..1473a99cc5 100644 --- a/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt +++ b/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt @@ -24,99 +24,113 @@ } ], "ast": { - "Stmt": { - "DistinctClause": { - "Items": null + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "distinct_clause": { + "tag": "List" }, - "IntoClause": null, - "TargetList": { - "Items": [ + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": { - "Items": null + "tag": "ResTarget", + "indirection": { + "tag": "List" }, - "Val": { - "Name": "", - "Fields": { - "Items": [ + "val": { + "tag": "ColumnRef", + "name": "", + "fields": { + "tag": "List", + "items": [ { - "Str": "name" + "tag": "String", + "str": "name" } ] }, - "Location": 35 + "location": 35 }, - "Location": 35 + "location": 35 } ] }, - "FromClause": { - "Items": [ + "from_clause": { + "tag": "List", + "items": [ { - "Catalogname": null, - "Schemaname": null, - "Relname": "authors", - "Inh": true, - "Relpersistence": 112, - "Alias": null, - "Location": 45 + "tag": "RangeVar", + "relname": "authors", + "inh": true, + "relpersistence": 112, + "location": 45 } ] }, - "WhereClause": { - "Kind": 1, - "Name": { - "Items": [ + "where_clause": { + "tag": "A_Expr", + "kind": 1, + "name": { + "tag": "List", + "items": [ { - "Str": "=" + "tag": "String", + "str": "=" } ] }, - "Lexpr": { - "Name": "", - "Fields": { - "Items": [ + "lexpr": { + "tag": "ColumnRef", + "name": "", + "fields": { + "tag": "List", + "items": [ { - "Str": "id" + "tag": "String", + "str": "id" } ] }, - "Location": 59 + "location": 59 }, - "Rexpr": { - "Number": 1, - "Location": 64, - "Dollar": true + "rexpr": { + "tag": "ParamRef", + "number": 1, + "location": 64, + "dollar": true }, - "Location": 62 + "location": 62 }, - "GroupClause": { - "Items": null + "group_clause": { + "tag": "List" }, - "HavingClause": {}, - "WindowClause": { - "Items": null + "having_clause": { + "tag": "TODO" }, - "ValuesLists": { - "Items": null + "window_clause": { + "tag": "List" }, - "SortClause": { - "Items": null + "values_lists": { + "tag": "List" }, - "LimitOffset": {}, - "LimitCount": {}, - "LockingClause": { - "Items": null + "sort_clause": { + "tag": "List" }, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "limit_offset": { + "tag": "TODO" + }, + "limit_count": { + "tag": "TODO" + }, + "locking_clause": { + "tag": "List" + }, + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 66 + "stmt_location": 0, + "stmt_len": 66 } } ] diff --git a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt index 28a5ce7e1f..82c35f9819 100644 --- a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt @@ -3,42 +3,31 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": null, - "IntoClause": null, - "TargetList": { - "Items": [ + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": null, - "Val": { - "Val": { - "Ival": 1 + "tag": "ResTarget", + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 31 + "location": 31 }, - "Location": 31 + "location": 31 } ] }, - "FromClause": null, - "WhereClause": null, - "GroupClause": null, - "HavingClause": null, - "WindowClause": null, - "ValuesLists": null, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 32 + "stmt_location": 0, + "stmt_len": 32 } } ] diff --git a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt index ca847e616a..9c48f6b87e 100644 --- a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt @@ -3,42 +3,31 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": null, - "IntoClause": null, - "TargetList": { - "Items": [ + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": null, - "Val": { - "Val": { - "Ival": 1 + "tag": "ResTarget", + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": null, - "WhereClause": null, - "GroupClause": null, - "HavingClause": null, - "WindowClause": null, - "ValuesLists": null, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 33 + "stmt_location": 0, + "stmt_len": 33 } } ] diff --git a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt index 086f885402..f1d543432e 100644 --- a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt @@ -3,42 +3,31 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": null, - "IntoClause": null, - "TargetList": { - "Items": [ + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": null, - "Val": { - "Val": { - "Ival": 1 + "tag": "ResTarget", + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": null, - "WhereClause": null, - "GroupClause": null, - "HavingClause": null, - "WindowClause": null, - "ValuesLists": null, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 31 + "stmt_location": 0, + "stmt_len": 31 } } ] diff --git a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt index b20fbdcee5..a317604268 100644 --- a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt @@ -3,42 +3,31 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": null, - "IntoClause": null, - "TargetList": { - "Items": [ + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": null, - "Val": { - "Val": { - "Ival": 1 + "tag": "ResTarget", + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": null, - "WhereClause": null, - "GroupClause": null, - "HavingClause": null, - "WindowClause": null, - "ValuesLists": null, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 32 + "stmt_location": 0, + "stmt_len": 32 } } ] diff --git a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt index e9ed28784f..baad161901 100644 --- a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt @@ -3,48 +3,40 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": null, - "IntoClause": null, - "TargetList": { - "Items": [ + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": null, - "Val": { - "Val": { - "Ival": 1 + "tag": "ResTarget", + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": { - "Items": null + "from_clause": { + "tag": "List" }, - "WhereClause": null, - "GroupClause": { - "Items": null + "group_clause": { + "tag": "List" }, - "HavingClause": null, - "WindowClause": { - "Items": [] + "window_clause": { + "tag": "List" }, - "ValuesLists": null, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 31 + "stmt_location": 0, + "stmt_len": 31 } } ] diff --git a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt index fe35a664c7..da9c2f9040 100644 --- a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt @@ -3,58 +3,67 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": { - "Items": null + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "distinct_clause": { + "tag": "List" }, - "IntoClause": null, - "TargetList": { - "Items": [ + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": { - "Items": null + "tag": "ResTarget", + "indirection": { + "tag": "List" }, - "Val": { - "Val": { - "Ival": 1 + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": { - "Items": null + "from_clause": { + "tag": "List" }, - "WhereClause": {}, - "GroupClause": { - "Items": null + "where_clause": { + "tag": "TODO" }, - "HavingClause": {}, - "WindowClause": { - "Items": null + "group_clause": { + "tag": "List" }, - "ValuesLists": { - "Items": null + "having_clause": { + "tag": "TODO" }, - "SortClause": { - "Items": null + "window_clause": { + "tag": "List" }, - "LimitOffset": {}, - "LimitCount": {}, - "LockingClause": { - "Items": null + "values_lists": { + "tag": "List" }, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "sort_clause": { + "tag": "List" + }, + "limit_offset": { + "tag": "TODO" + }, + "limit_count": { + "tag": "TODO" + }, + "locking_clause": { + "tag": "List" + }, + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 31 + "stmt_location": 0, + "stmt_len": 31 } } ] diff --git a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt index c1303a9a1e..8cbf077101 100644 --- a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt @@ -3,50 +3,43 @@ "name": "GetValue", "cmd": ":one", "ast": { - "Stmt": { - "DistinctClause": null, - "IntoClause": null, - "TargetList": { - "Items": [ + "tag": "RawStmt", + "stmt": { + "tag": "SelectStmt", + "target_list": { + "tag": "List", + "items": [ { - "Name": null, - "Indirection": null, - "Val": { - "Val": { - "Ival": 1 + "tag": "ResTarget", + "val": { + "tag": "A_Const", + "val": { + "tag": "Integer", + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": { - "Items": null + "from_clause": { + "tag": "List" }, - "WhereClause": null, - "GroupClause": { - "Items": null + "group_clause": { + "tag": "List" }, - "HavingClause": null, - "WindowClause": { - "Items": null + "window_clause": { + "tag": "List" }, - "ValuesLists": { - "Items": null + "values_lists": { + "tag": "List" }, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, - "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "op": 0, + "all": false }, - "StmtLocation": 0, - "StmtLen": 31 + "stmt_location": 0, + "stmt_len": 31 } } ] diff --git a/internal/sql/ast/a_array_expr.go b/internal/sql/ast/a_array_expr.go index 0437dac84f..ed11abf998 100644 --- a/internal/sql/ast/a_array_expr.go +++ b/internal/sql/ast/a_array_expr.go @@ -3,8 +3,10 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_ArrayExpr struct { - Elements *List - Location int + Tag NodeTag[A_ArrayExpr] `json:"tag"` + + Elements *List `json:"elements,omitempty"` + Location int `json:"location"` } func (n *A_ArrayExpr) Pos() int { diff --git a/internal/sql/ast/a_const.go b/internal/sql/ast/a_const.go index a6b610e349..0f507d99e3 100644 --- a/internal/sql/ast/a_const.go +++ b/internal/sql/ast/a_const.go @@ -3,8 +3,10 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Const struct { - Val Node - Location int + Tag NodeTag[A_Const] `json:"tag"` + + Val Node `json:"val,omitempty"` + Location int `json:"location"` } func (n *A_Const) Pos() int { diff --git a/internal/sql/ast/a_expr.go b/internal/sql/ast/a_expr.go index ea3242337c..7501ff0eb6 100644 --- a/internal/sql/ast/a_expr.go +++ b/internal/sql/ast/a_expr.go @@ -7,7 +7,9 @@ import ( ) type A_Expr struct { - Kind A_Expr_Kind + Tag NodeTag[A_Expr] `json:"tag"` + + Kind A_Expr_Kind `json:"kind"` // Name is the operator, as a list of String nodes: PostgreSQL's // operator space is open (user-defined and schema-qualified operators), // so the shared tree keeps pg_query's shape rather than an enum. Each @@ -15,10 +17,10 @@ type A_Expr struct { // engine that accepts more than one spelling of the same operator // (SQLite's != for <>, == for =), that is the author's spelling, which // is how the printer preserves it. - Name *List - Lexpr Node - Rexpr Node - Location int + Name *List `json:"name,omitempty"` + Lexpr Node `json:"lexpr,omitempty"` + Rexpr Node `json:"rexpr,omitempty"` + Location int `json:"location"` } func (n *A_Expr) Pos() int { diff --git a/internal/sql/ast/a_indices.go b/internal/sql/ast/a_indices.go index 7180f220e7..2f7715e8c7 100644 --- a/internal/sql/ast/a_indices.go +++ b/internal/sql/ast/a_indices.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Indices struct { - IsSlice bool - Lidx Node - Uidx Node + Tag NodeTag[A_Indices] `json:"tag"` + + IsSlice bool `json:"is_slice"` + Lidx Node `json:"lidx,omitempty"` + Uidx Node `json:"uidx,omitempty"` } func (n *A_Indices) Pos() int { diff --git a/internal/sql/ast/a_indirection.go b/internal/sql/ast/a_indirection.go index b03b4621a9..df682bb285 100644 --- a/internal/sql/ast/a_indirection.go +++ b/internal/sql/ast/a_indirection.go @@ -1,8 +1,10 @@ package ast type A_Indirection struct { - Arg Node - Indirection *List + Tag NodeTag[A_Indirection] `json:"tag"` + + Arg Node `json:"arg,omitempty"` + Indirection *List `json:"indirection,omitempty"` } func (n *A_Indirection) Pos() int { diff --git a/internal/sql/ast/a_star.go b/internal/sql/ast/a_star.go index 7e5f07b96a..c95d7c0b51 100644 --- a/internal/sql/ast/a_star.go +++ b/internal/sql/ast/a_star.go @@ -3,6 +3,7 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Star struct { + Tag NodeTag[A_Star] `json:"tag"` } func (n *A_Star) Pos() int { diff --git a/internal/sql/ast/access_priv.go b/internal/sql/ast/access_priv.go index 8701adacdb..ab16946db3 100644 --- a/internal/sql/ast/access_priv.go +++ b/internal/sql/ast/access_priv.go @@ -1,8 +1,10 @@ package ast type AccessPriv struct { - PrivName *string - Cols *List + Tag NodeTag[AccessPriv] `json:"tag"` + + PrivName *string `json:"priv_name,omitempty"` + Cols *List `json:"cols,omitempty"` } func (n *AccessPriv) Pos() int { diff --git a/internal/sql/ast/aggref.go b/internal/sql/ast/aggref.go index 6642f4d9e3..f9c8a0833a 100644 --- a/internal/sql/ast/aggref.go +++ b/internal/sql/ast/aggref.go @@ -1,23 +1,25 @@ package ast type Aggref struct { - Xpr Node - Aggfnoid Oid - Aggtype Oid - Aggcollid Oid - Inputcollid Oid - Aggargtypes *List - Aggdirectargs *List - Args *List - Aggorder *List - Aggdistinct *List - Aggfilter Node - Aggstar bool - Aggvariadic bool - Aggkind byte - Agglevelsup Index - Aggsplit AggSplit - Location int + Tag NodeTag[Aggref] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Aggfnoid Oid `json:"aggfnoid"` + Aggtype Oid `json:"aggtype"` + Aggcollid Oid `json:"aggcollid"` + Inputcollid Oid `json:"inputcollid"` + Aggargtypes *List `json:"aggargtypes,omitempty"` + Aggdirectargs *List `json:"aggdirectargs,omitempty"` + Args *List `json:"args,omitempty"` + Aggorder *List `json:"aggorder,omitempty"` + Aggdistinct *List `json:"aggdistinct,omitempty"` + Aggfilter Node `json:"aggfilter,omitempty"` + Aggstar bool `json:"aggstar"` + Aggvariadic bool `json:"aggvariadic"` + Aggkind byte `json:"aggkind"` + Agglevelsup Index `json:"agglevelsup"` + Aggsplit AggSplit `json:"aggsplit"` + Location int `json:"location"` } func (n *Aggref) Pos() int { diff --git a/internal/sql/ast/alias.go b/internal/sql/ast/alias.go index 7123982305..198120f5d0 100644 --- a/internal/sql/ast/alias.go +++ b/internal/sql/ast/alias.go @@ -3,8 +3,10 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type Alias struct { - Aliasname *string - Colnames *List + Tag NodeTag[Alias] `json:"tag"` + + Aliasname *string `json:"aliasname,omitempty"` + Colnames *List `json:"colnames,omitempty"` } func (n *Alias) Pos() int { diff --git a/internal/sql/ast/alter_collation_stmt.go b/internal/sql/ast/alter_collation_stmt.go index fa78ed7bf1..fedcf5a9d1 100644 --- a/internal/sql/ast/alter_collation_stmt.go +++ b/internal/sql/ast/alter_collation_stmt.go @@ -1,7 +1,9 @@ package ast type AlterCollationStmt struct { - Collname *List + Tag NodeTag[AlterCollationStmt] `json:"tag"` + + Collname *List `json:"collname,omitempty"` } func (n *AlterCollationStmt) Pos() int { diff --git a/internal/sql/ast/alter_database_set_stmt.go b/internal/sql/ast/alter_database_set_stmt.go index ba9926bed1..14d485eb30 100644 --- a/internal/sql/ast/alter_database_set_stmt.go +++ b/internal/sql/ast/alter_database_set_stmt.go @@ -1,8 +1,10 @@ package ast type AlterDatabaseSetStmt struct { - Dbname *string - Setstmt *VariableSetStmt + Tag NodeTag[AlterDatabaseSetStmt] `json:"tag"` + + Dbname *string `json:"dbname,omitempty"` + Setstmt *VariableSetStmt `json:"setstmt,omitempty"` } func (n *AlterDatabaseSetStmt) Pos() int { diff --git a/internal/sql/ast/alter_database_stmt.go b/internal/sql/ast/alter_database_stmt.go index 84d91f089c..9eb3dae54d 100644 --- a/internal/sql/ast/alter_database_stmt.go +++ b/internal/sql/ast/alter_database_stmt.go @@ -1,8 +1,10 @@ package ast type AlterDatabaseStmt struct { - Dbname *string - Options *List + Tag NodeTag[AlterDatabaseStmt] `json:"tag"` + + Dbname *string `json:"dbname,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterDatabaseStmt) Pos() int { diff --git a/internal/sql/ast/alter_default_privileges_stmt.go b/internal/sql/ast/alter_default_privileges_stmt.go index 64632a726d..f72a412eb1 100644 --- a/internal/sql/ast/alter_default_privileges_stmt.go +++ b/internal/sql/ast/alter_default_privileges_stmt.go @@ -1,8 +1,10 @@ package ast type AlterDefaultPrivilegesStmt struct { - Options *List - Action *GrantStmt + Tag NodeTag[AlterDefaultPrivilegesStmt] `json:"tag"` + + Options *List `json:"options,omitempty"` + Action *GrantStmt `json:"action,omitempty"` } func (n *AlterDefaultPrivilegesStmt) Pos() int { diff --git a/internal/sql/ast/alter_domain_stmt.go b/internal/sql/ast/alter_domain_stmt.go index f9f419937f..669b7a5337 100644 --- a/internal/sql/ast/alter_domain_stmt.go +++ b/internal/sql/ast/alter_domain_stmt.go @@ -1,12 +1,14 @@ package ast type AlterDomainStmt struct { - Subtype byte - TypeName *List - Name *string - Def Node - Behavior DropBehavior - MissingOk bool + Tag NodeTag[AlterDomainStmt] `json:"tag"` + + Subtype byte `json:"subtype"` + TypeName *List `json:"type_name,omitempty"` + Name *string `json:"name,omitempty"` + Def Node `json:"def,omitempty"` + Behavior DropBehavior `json:"behavior"` + MissingOk bool `json:"missing_ok"` } func (n *AlterDomainStmt) Pos() int { diff --git a/internal/sql/ast/alter_enum_stmt.go b/internal/sql/ast/alter_enum_stmt.go index 1346b3c0d0..70a6a850bd 100644 --- a/internal/sql/ast/alter_enum_stmt.go +++ b/internal/sql/ast/alter_enum_stmt.go @@ -1,12 +1,14 @@ package ast type AlterEnumStmt struct { - TypeName *List - OldVal *string - NewVal *string - NewValNeighbor *string - NewValIsAfter bool - SkipIfNewValExists bool + Tag NodeTag[AlterEnumStmt] `json:"tag"` + + TypeName *List `json:"type_name,omitempty"` + OldVal *string `json:"old_val,omitempty"` + NewVal *string `json:"new_val,omitempty"` + NewValNeighbor *string `json:"new_val_neighbor,omitempty"` + NewValIsAfter bool `json:"new_val_is_after"` + SkipIfNewValExists bool `json:"skip_if_new_val_exists"` } func (n *AlterEnumStmt) Pos() int { diff --git a/internal/sql/ast/alter_event_trig_stmt.go b/internal/sql/ast/alter_event_trig_stmt.go index eeb5f75d42..14356fabe7 100644 --- a/internal/sql/ast/alter_event_trig_stmt.go +++ b/internal/sql/ast/alter_event_trig_stmt.go @@ -1,8 +1,10 @@ package ast type AlterEventTrigStmt struct { - Trigname *string - Tgenabled byte + Tag NodeTag[AlterEventTrigStmt] `json:"tag"` + + Trigname *string `json:"trigname,omitempty"` + Tgenabled byte `json:"tgenabled"` } func (n *AlterEventTrigStmt) Pos() int { diff --git a/internal/sql/ast/alter_extension_contents_stmt.go b/internal/sql/ast/alter_extension_contents_stmt.go index 27ad1c31d6..3821812720 100644 --- a/internal/sql/ast/alter_extension_contents_stmt.go +++ b/internal/sql/ast/alter_extension_contents_stmt.go @@ -1,10 +1,12 @@ package ast type AlterExtensionContentsStmt struct { - Extname *string - Action int - Objtype ObjectType - Object Node + Tag NodeTag[AlterExtensionContentsStmt] `json:"tag"` + + Extname *string `json:"extname,omitempty"` + Action int `json:"action"` + Objtype ObjectType `json:"objtype"` + Object Node `json:"object,omitempty"` } func (n *AlterExtensionContentsStmt) Pos() int { diff --git a/internal/sql/ast/alter_extension_stmt.go b/internal/sql/ast/alter_extension_stmt.go index 049e712c94..c1daf85e91 100644 --- a/internal/sql/ast/alter_extension_stmt.go +++ b/internal/sql/ast/alter_extension_stmt.go @@ -1,8 +1,10 @@ package ast type AlterExtensionStmt struct { - Extname *string - Options *List + Tag NodeTag[AlterExtensionStmt] `json:"tag"` + + Extname *string `json:"extname,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterExtensionStmt) Pos() int { diff --git a/internal/sql/ast/alter_fdw_stmt.go b/internal/sql/ast/alter_fdw_stmt.go index 12c6457d71..6a74137bfb 100644 --- a/internal/sql/ast/alter_fdw_stmt.go +++ b/internal/sql/ast/alter_fdw_stmt.go @@ -1,9 +1,11 @@ package ast type AlterFdwStmt struct { - Fdwname *string - FuncOptions *List - Options *List + Tag NodeTag[AlterFdwStmt] `json:"tag"` + + Fdwname *string `json:"fdwname,omitempty"` + FuncOptions *List `json:"func_options,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterFdwStmt) Pos() int { diff --git a/internal/sql/ast/alter_foreign_server_stmt.go b/internal/sql/ast/alter_foreign_server_stmt.go index 9f3e8dbe64..fcdbad116f 100644 --- a/internal/sql/ast/alter_foreign_server_stmt.go +++ b/internal/sql/ast/alter_foreign_server_stmt.go @@ -1,10 +1,12 @@ package ast type AlterForeignServerStmt struct { - Servername *string - Version *string - Options *List - HasVersion bool + Tag NodeTag[AlterForeignServerStmt] `json:"tag"` + + Servername *string `json:"servername,omitempty"` + Version *string `json:"version,omitempty"` + Options *List `json:"options,omitempty"` + HasVersion bool `json:"has_version"` } func (n *AlterForeignServerStmt) Pos() int { diff --git a/internal/sql/ast/alter_function_stmt.go b/internal/sql/ast/alter_function_stmt.go index 1193ab7656..93d393111d 100644 --- a/internal/sql/ast/alter_function_stmt.go +++ b/internal/sql/ast/alter_function_stmt.go @@ -1,8 +1,10 @@ package ast type AlterFunctionStmt struct { - Func *ObjectWithArgs - Actions *List + Tag NodeTag[AlterFunctionStmt] `json:"tag"` + + Func *ObjectWithArgs `json:"func,omitempty"` + Actions *List `json:"actions,omitempty"` } func (n *AlterFunctionStmt) Pos() int { diff --git a/internal/sql/ast/alter_object_depends_stmt.go b/internal/sql/ast/alter_object_depends_stmt.go index 83cc3c9641..f7b46aeeab 100644 --- a/internal/sql/ast/alter_object_depends_stmt.go +++ b/internal/sql/ast/alter_object_depends_stmt.go @@ -1,10 +1,12 @@ package ast type AlterObjectDependsStmt struct { - ObjectType ObjectType - Relation *RangeVar - Object Node - Extname Node + Tag NodeTag[AlterObjectDependsStmt] `json:"tag"` + + ObjectType ObjectType `json:"object_type"` + Relation *RangeVar `json:"relation,omitempty"` + Object Node `json:"object,omitempty"` + Extname Node `json:"extname,omitempty"` } func (n *AlterObjectDependsStmt) Pos() int { diff --git a/internal/sql/ast/alter_object_schema_stmt.go b/internal/sql/ast/alter_object_schema_stmt.go index 664e6f1495..3a5a5bd332 100644 --- a/internal/sql/ast/alter_object_schema_stmt.go +++ b/internal/sql/ast/alter_object_schema_stmt.go @@ -1,11 +1,13 @@ package ast type AlterObjectSchemaStmt struct { - ObjectType ObjectType - Relation *RangeVar - Object Node - Newschema *string - MissingOk bool + Tag NodeTag[AlterObjectSchemaStmt] `json:"tag"` + + ObjectType ObjectType `json:"object_type"` + Relation *RangeVar `json:"relation,omitempty"` + Object Node `json:"object,omitempty"` + Newschema *string `json:"newschema,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *AlterObjectSchemaStmt) Pos() int { diff --git a/internal/sql/ast/alter_op_family_stmt.go b/internal/sql/ast/alter_op_family_stmt.go index 60655d76b0..7d287d5a26 100644 --- a/internal/sql/ast/alter_op_family_stmt.go +++ b/internal/sql/ast/alter_op_family_stmt.go @@ -1,10 +1,12 @@ package ast type AlterOpFamilyStmt struct { - Opfamilyname *List - Amname *string - IsDrop bool - Items *List + Tag NodeTag[AlterOpFamilyStmt] `json:"tag"` + + Opfamilyname *List `json:"opfamilyname,omitempty"` + Amname *string `json:"amname,omitempty"` + IsDrop bool `json:"is_drop"` + Items *List `json:"items,omitempty"` } func (n *AlterOpFamilyStmt) Pos() int { diff --git a/internal/sql/ast/alter_operator_stmt.go b/internal/sql/ast/alter_operator_stmt.go index 11ef659a8c..0d61c657a6 100644 --- a/internal/sql/ast/alter_operator_stmt.go +++ b/internal/sql/ast/alter_operator_stmt.go @@ -1,8 +1,10 @@ package ast type AlterOperatorStmt struct { - Opername *ObjectWithArgs - Options *List + Tag NodeTag[AlterOperatorStmt] `json:"tag"` + + Opername *ObjectWithArgs `json:"opername,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterOperatorStmt) Pos() int { diff --git a/internal/sql/ast/alter_owner_stmt.go b/internal/sql/ast/alter_owner_stmt.go index 8a4be65183..041c0d4d67 100644 --- a/internal/sql/ast/alter_owner_stmt.go +++ b/internal/sql/ast/alter_owner_stmt.go @@ -1,10 +1,12 @@ package ast type AlterOwnerStmt struct { - ObjectType ObjectType - Relation *RangeVar - Object Node - Newowner *RoleSpec + Tag NodeTag[AlterOwnerStmt] `json:"tag"` + + ObjectType ObjectType `json:"object_type"` + Relation *RangeVar `json:"relation,omitempty"` + Object Node `json:"object,omitempty"` + Newowner *RoleSpec `json:"newowner,omitempty"` } func (n *AlterOwnerStmt) Pos() int { diff --git a/internal/sql/ast/alter_policy_stmt.go b/internal/sql/ast/alter_policy_stmt.go index 03e814328c..b7f9d7be4f 100644 --- a/internal/sql/ast/alter_policy_stmt.go +++ b/internal/sql/ast/alter_policy_stmt.go @@ -1,11 +1,13 @@ package ast type AlterPolicyStmt struct { - PolicyName *string - Table *RangeVar - Roles *List - Qual Node - WithCheck Node + Tag NodeTag[AlterPolicyStmt] `json:"tag"` + + PolicyName *string `json:"policy_name,omitempty"` + Table *RangeVar `json:"table,omitempty"` + Roles *List `json:"roles,omitempty"` + Qual Node `json:"qual,omitempty"` + WithCheck Node `json:"with_check,omitempty"` } func (n *AlterPolicyStmt) Pos() int { diff --git a/internal/sql/ast/alter_publication_stmt.go b/internal/sql/ast/alter_publication_stmt.go index c1288858eb..718368fd26 100644 --- a/internal/sql/ast/alter_publication_stmt.go +++ b/internal/sql/ast/alter_publication_stmt.go @@ -1,11 +1,13 @@ package ast type AlterPublicationStmt struct { - Pubname *string - Options *List - Tables *List - ForAllTables bool - TableAction DefElemAction + Tag NodeTag[AlterPublicationStmt] `json:"tag"` + + Pubname *string `json:"pubname,omitempty"` + Options *List `json:"options,omitempty"` + Tables *List `json:"tables,omitempty"` + ForAllTables bool `json:"for_all_tables"` + TableAction DefElemAction `json:"table_action"` } func (n *AlterPublicationStmt) Pos() int { diff --git a/internal/sql/ast/alter_role_set_stmt.go b/internal/sql/ast/alter_role_set_stmt.go index cda679017c..a973ccb4a4 100644 --- a/internal/sql/ast/alter_role_set_stmt.go +++ b/internal/sql/ast/alter_role_set_stmt.go @@ -1,9 +1,11 @@ package ast type AlterRoleSetStmt struct { - Role *RoleSpec - Database *string - Setstmt *VariableSetStmt + Tag NodeTag[AlterRoleSetStmt] `json:"tag"` + + Role *RoleSpec `json:"role,omitempty"` + Database *string `json:"database,omitempty"` + Setstmt *VariableSetStmt `json:"setstmt,omitempty"` } func (n *AlterRoleSetStmt) Pos() int { diff --git a/internal/sql/ast/alter_role_stmt.go b/internal/sql/ast/alter_role_stmt.go index e616f05917..3c7d60767c 100644 --- a/internal/sql/ast/alter_role_stmt.go +++ b/internal/sql/ast/alter_role_stmt.go @@ -1,9 +1,11 @@ package ast type AlterRoleStmt struct { - Role *RoleSpec - Options *List - Action int + Tag NodeTag[AlterRoleStmt] `json:"tag"` + + Role *RoleSpec `json:"role,omitempty"` + Options *List `json:"options,omitempty"` + Action int `json:"action"` } func (n *AlterRoleStmt) Pos() int { diff --git a/internal/sql/ast/alter_seq_stmt.go b/internal/sql/ast/alter_seq_stmt.go index ca4c86a413..53e46d47c4 100644 --- a/internal/sql/ast/alter_seq_stmt.go +++ b/internal/sql/ast/alter_seq_stmt.go @@ -1,10 +1,12 @@ package ast type AlterSeqStmt struct { - Sequence *RangeVar - Options *List - ForIdentity bool - MissingOk bool + Tag NodeTag[AlterSeqStmt] `json:"tag"` + + Sequence *RangeVar `json:"sequence,omitempty"` + Options *List `json:"options,omitempty"` + ForIdentity bool `json:"for_identity"` + MissingOk bool `json:"missing_ok"` } func (n *AlterSeqStmt) Pos() int { diff --git a/internal/sql/ast/alter_subscription_stmt.go b/internal/sql/ast/alter_subscription_stmt.go index 443fc7bfb8..3b54140fe7 100644 --- a/internal/sql/ast/alter_subscription_stmt.go +++ b/internal/sql/ast/alter_subscription_stmt.go @@ -1,11 +1,13 @@ package ast type AlterSubscriptionStmt struct { - Kind AlterSubscriptionType - Subname *string - Conninfo *string - Publication *List - Options *List + Tag NodeTag[AlterSubscriptionStmt] `json:"tag"` + + Kind AlterSubscriptionType `json:"kind"` + Subname *string `json:"subname,omitempty"` + Conninfo *string `json:"conninfo,omitempty"` + Publication *List `json:"publication,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterSubscriptionStmt) Pos() int { diff --git a/internal/sql/ast/alter_system_stmt.go b/internal/sql/ast/alter_system_stmt.go index c5657f9c1a..724ad8f3a7 100644 --- a/internal/sql/ast/alter_system_stmt.go +++ b/internal/sql/ast/alter_system_stmt.go @@ -1,7 +1,9 @@ package ast type AlterSystemStmt struct { - Setstmt *VariableSetStmt + Tag NodeTag[AlterSystemStmt] `json:"tag"` + + Setstmt *VariableSetStmt `json:"setstmt,omitempty"` } func (n *AlterSystemStmt) Pos() int { diff --git a/internal/sql/ast/alter_table_cmd.go b/internal/sql/ast/alter_table_cmd.go index 90ffd891eb..b357605dd8 100644 --- a/internal/sql/ast/alter_table_cmd.go +++ b/internal/sql/ast/alter_table_cmd.go @@ -30,12 +30,14 @@ func (t AlterTableType) String() string { } type AlterTableCmd struct { - Subtype AlterTableType - Name *string - Def *ColumnDef - Newowner *RoleSpec - Behavior DropBehavior - MissingOk bool + Tag NodeTag[AlterTableCmd] `json:"tag"` + + Subtype AlterTableType `json:"subtype"` + Name *string `json:"name,omitempty"` + Def *ColumnDef `json:"def,omitempty"` + Newowner *RoleSpec `json:"newowner,omitempty"` + Behavior DropBehavior `json:"behavior"` + MissingOk bool `json:"missing_ok"` } func (n *AlterTableCmd) Pos() int { diff --git a/internal/sql/ast/alter_table_move_all_stmt.go b/internal/sql/ast/alter_table_move_all_stmt.go index 39f1256083..ac028a06aa 100644 --- a/internal/sql/ast/alter_table_move_all_stmt.go +++ b/internal/sql/ast/alter_table_move_all_stmt.go @@ -1,11 +1,13 @@ package ast type AlterTableMoveAllStmt struct { - OrigTablespacename *string - Objtype ObjectType - Roles *List - NewTablespacename *string - Nowait bool + Tag NodeTag[AlterTableMoveAllStmt] `json:"tag"` + + OrigTablespacename *string `json:"orig_tablespacename,omitempty"` + Objtype ObjectType `json:"objtype"` + Roles *List `json:"roles,omitempty"` + NewTablespacename *string `json:"new_tablespacename,omitempty"` + Nowait bool `json:"nowait"` } func (n *AlterTableMoveAllStmt) Pos() int { diff --git a/internal/sql/ast/alter_table_set_schema_stmt.go b/internal/sql/ast/alter_table_set_schema_stmt.go index 890cb3e5e8..d7f62bf334 100644 --- a/internal/sql/ast/alter_table_set_schema_stmt.go +++ b/internal/sql/ast/alter_table_set_schema_stmt.go @@ -1,9 +1,11 @@ package ast type AlterTableSetSchemaStmt struct { - Table *TableName - NewSchema *string - MissingOk bool + Tag NodeTag[AlterTableSetSchemaStmt] `json:"tag"` + + Table *TableName `json:"table,omitempty"` + NewSchema *string `json:"new_schema,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *AlterTableSetSchemaStmt) Pos() int { diff --git a/internal/sql/ast/alter_table_space_options_stmt.go b/internal/sql/ast/alter_table_space_options_stmt.go index fc49cfe6b8..f9b97b2d2f 100644 --- a/internal/sql/ast/alter_table_space_options_stmt.go +++ b/internal/sql/ast/alter_table_space_options_stmt.go @@ -1,9 +1,11 @@ package ast type AlterTableSpaceOptionsStmt struct { - Tablespacename *string - Options *List - IsReset bool + Tag NodeTag[AlterTableSpaceOptionsStmt] `json:"tag"` + + Tablespacename *string `json:"tablespacename,omitempty"` + Options *List `json:"options,omitempty"` + IsReset bool `json:"is_reset"` } func (n *AlterTableSpaceOptionsStmt) Pos() int { diff --git a/internal/sql/ast/alter_table_stmt.go b/internal/sql/ast/alter_table_stmt.go index afbf014b07..5e541023f1 100644 --- a/internal/sql/ast/alter_table_stmt.go +++ b/internal/sql/ast/alter_table_stmt.go @@ -3,16 +3,18 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type AlterTableStmt struct { + Tag NodeTag[AlterTableStmt] `json:"tag"` + // TODO: Only TableName or Relation should be defined - Relation *RangeVar - Table *TableName - Cmds *List - MissingOk bool - Relkind ObjectType + Relation *RangeVar `json:"relation,omitempty"` + Table *TableName `json:"table,omitempty"` + Cmds *List `json:"cmds,omitempty"` + MissingOk bool `json:"missing_ok"` + Relkind ObjectType `json:"relkind"` // Incomplete marks a statement whose source carried syntax this node // does not model, such as column constraints beyond plain NOT NULL and // PRIMARY KEY on an added column. No faithful rendering exists for it. - Incomplete bool + Incomplete bool `json:"incomplete"` } func (n *AlterTableStmt) Pos() int { diff --git a/internal/sql/ast/alter_ts_configuration_stmt.go b/internal/sql/ast/alter_ts_configuration_stmt.go index 6b58ada4e6..9ecd8bc2bb 100644 --- a/internal/sql/ast/alter_ts_configuration_stmt.go +++ b/internal/sql/ast/alter_ts_configuration_stmt.go @@ -1,13 +1,15 @@ package ast type AlterTSConfigurationStmt struct { - Kind AlterTSConfigType - Cfgname *List - Tokentype *List - Dicts *List - Override bool - Replace bool - MissingOk bool + Tag NodeTag[AlterTSConfigurationStmt] `json:"tag"` + + Kind AlterTSConfigType `json:"kind"` + Cfgname *List `json:"cfgname,omitempty"` + Tokentype *List `json:"tokentype,omitempty"` + Dicts *List `json:"dicts,omitempty"` + Override bool `json:"override"` + Replace bool `json:"replace"` + MissingOk bool `json:"missing_ok"` } func (n *AlterTSConfigurationStmt) Pos() int { diff --git a/internal/sql/ast/alter_ts_dictionary_stmt.go b/internal/sql/ast/alter_ts_dictionary_stmt.go index 0506c49b34..6c89127cca 100644 --- a/internal/sql/ast/alter_ts_dictionary_stmt.go +++ b/internal/sql/ast/alter_ts_dictionary_stmt.go @@ -1,8 +1,10 @@ package ast type AlterTSDictionaryStmt struct { - Dictname *List - Options *List + Tag NodeTag[AlterTSDictionaryStmt] `json:"tag"` + + Dictname *List `json:"dictname,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterTSDictionaryStmt) Pos() int { diff --git a/internal/sql/ast/alter_type_add_value_stmt.go b/internal/sql/ast/alter_type_add_value_stmt.go index 56ae7dd9b7..a8878d6153 100644 --- a/internal/sql/ast/alter_type_add_value_stmt.go +++ b/internal/sql/ast/alter_type_add_value_stmt.go @@ -1,12 +1,14 @@ package ast type AlterTypeAddValueStmt struct { - Type *TypeName - NewValue *string - NewValHasNeighbor bool - NewValNeighbor *string - NewValIsAfter bool - SkipIfNewValExists bool + Tag NodeTag[AlterTypeAddValueStmt] `json:"tag"` + + Type *TypeName `json:"type,omitempty"` + NewValue *string `json:"new_value,omitempty"` + NewValHasNeighbor bool `json:"new_val_has_neighbor"` + NewValNeighbor *string `json:"new_val_neighbor,omitempty"` + NewValIsAfter bool `json:"new_val_is_after"` + SkipIfNewValExists bool `json:"skip_if_new_val_exists"` } func (n *AlterTypeAddValueStmt) Pos() int { diff --git a/internal/sql/ast/alter_type_rename_value_stmt.go b/internal/sql/ast/alter_type_rename_value_stmt.go index 376286511f..52e59d40d1 100644 --- a/internal/sql/ast/alter_type_rename_value_stmt.go +++ b/internal/sql/ast/alter_type_rename_value_stmt.go @@ -1,9 +1,11 @@ package ast type AlterTypeRenameValueStmt struct { - Type *TypeName - OldValue *string - NewValue *string + Tag NodeTag[AlterTypeRenameValueStmt] `json:"tag"` + + Type *TypeName `json:"type,omitempty"` + OldValue *string `json:"old_value,omitempty"` + NewValue *string `json:"new_value,omitempty"` } func (n *AlterTypeRenameValueStmt) Pos() int { diff --git a/internal/sql/ast/alter_type_set_schema_stmt.go b/internal/sql/ast/alter_type_set_schema_stmt.go index 22206d85cd..46d312beaa 100644 --- a/internal/sql/ast/alter_type_set_schema_stmt.go +++ b/internal/sql/ast/alter_type_set_schema_stmt.go @@ -1,8 +1,10 @@ package ast type AlterTypeSetSchemaStmt struct { - Type *TypeName - NewSchema *string + Tag NodeTag[AlterTypeSetSchemaStmt] `json:"tag"` + + Type *TypeName `json:"type,omitempty"` + NewSchema *string `json:"new_schema,omitempty"` } func (n *AlterTypeSetSchemaStmt) Pos() int { diff --git a/internal/sql/ast/alter_user_mapping_stmt.go b/internal/sql/ast/alter_user_mapping_stmt.go index aeeb0912ae..ab85751f10 100644 --- a/internal/sql/ast/alter_user_mapping_stmt.go +++ b/internal/sql/ast/alter_user_mapping_stmt.go @@ -1,9 +1,11 @@ package ast type AlterUserMappingStmt struct { - User *RoleSpec - Servername *string - Options *List + Tag NodeTag[AlterUserMappingStmt] `json:"tag"` + + User *RoleSpec `json:"user,omitempty"` + Servername *string `json:"servername,omitempty"` + Options *List `json:"options,omitempty"` } func (n *AlterUserMappingStmt) Pos() int { diff --git a/internal/sql/ast/alternative_sub_plan.go b/internal/sql/ast/alternative_sub_plan.go index 86031afd19..ad374d1d76 100644 --- a/internal/sql/ast/alternative_sub_plan.go +++ b/internal/sql/ast/alternative_sub_plan.go @@ -1,8 +1,10 @@ package ast type AlternativeSubPlan struct { - Xpr Node - Subplans *List + Tag NodeTag[AlternativeSubPlan] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Subplans *List `json:"subplans,omitempty"` } func (n *AlternativeSubPlan) Pos() int { diff --git a/internal/sql/ast/array_coerce_expr.go b/internal/sql/ast/array_coerce_expr.go index 314c6881bf..ce8c95200f 100644 --- a/internal/sql/ast/array_coerce_expr.go +++ b/internal/sql/ast/array_coerce_expr.go @@ -1,15 +1,17 @@ package ast type ArrayCoerceExpr struct { - Xpr Node - Arg Node - Elemfuncid Oid - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid - IsExplicit bool - Coerceformat CoercionForm - Location int + Tag NodeTag[ArrayCoerceExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Elemfuncid Oid `json:"elemfuncid"` + Resulttype Oid `json:"resulttype"` + Resulttypmod int32 `json:"resulttypmod"` + Resultcollid Oid `json:"resultcollid"` + IsExplicit bool `json:"is_explicit"` + Coerceformat CoercionForm `json:"coerceformat"` + Location int `json:"location"` } func (n *ArrayCoerceExpr) Pos() int { diff --git a/internal/sql/ast/array_expr.go b/internal/sql/ast/array_expr.go index c61aed8df7..753ed0f782 100644 --- a/internal/sql/ast/array_expr.go +++ b/internal/sql/ast/array_expr.go @@ -1,13 +1,15 @@ package ast type ArrayExpr struct { - Xpr Node - ArrayTypeid Oid - ArrayCollid Oid - ElementTypeid Oid - Elements *List - Multidims bool - Location int + Tag NodeTag[ArrayExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + ArrayTypeid Oid `json:"array_typeid"` + ArrayCollid Oid `json:"array_collid"` + ElementTypeid Oid `json:"element_typeid"` + Elements *List `json:"elements,omitempty"` + Multidims bool `json:"multidims"` + Location int `json:"location"` } func (n *ArrayExpr) Pos() int { diff --git a/internal/sql/ast/array_ref.go b/internal/sql/ast/array_ref.go index d94d800bb9..9fb4a35f5b 100644 --- a/internal/sql/ast/array_ref.go +++ b/internal/sql/ast/array_ref.go @@ -1,15 +1,17 @@ package ast type ArrayRef struct { - Xpr Node - Refarraytype Oid - Refelemtype Oid - Reftypmod int32 - Refcollid Oid - Refupperindexpr *List - Reflowerindexpr *List - Refexpr Node - Refassgnexpr Node + Tag NodeTag[ArrayRef] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Refarraytype Oid `json:"refarraytype"` + Refelemtype Oid `json:"refelemtype"` + Reftypmod int32 `json:"reftypmod"` + Refcollid Oid `json:"refcollid"` + Refupperindexpr *List `json:"refupperindexpr,omitempty"` + Reflowerindexpr *List `json:"reflowerindexpr,omitempty"` + Refexpr Node `json:"refexpr,omitempty"` + Refassgnexpr Node `json:"refassgnexpr,omitempty"` } func (n *ArrayRef) Pos() int { diff --git a/internal/sql/ast/between_expr.go b/internal/sql/ast/between_expr.go index a160f1892c..f1e4508006 100644 --- a/internal/sql/ast/between_expr.go +++ b/internal/sql/ast/between_expr.go @@ -3,15 +3,17 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type BetweenExpr struct { + Tag NodeTag[BetweenExpr] `json:"tag"` + // Expr is the value expression to be compared. - Expr Node + Expr Node `json:"expr,omitempty"` // Left is the left expression in the between statement. - Left Node + Left Node `json:"left,omitempty"` // Right is the right expression in the between statement. - Right Node + Right Node `json:"right,omitempty"` // Not is true, the expression is "not between". - Not bool - Location int + Not bool `json:"not"` + Location int `json:"location"` } func (n *BetweenExpr) Pos() int { diff --git a/internal/sql/ast/bit_string.go b/internal/sql/ast/bit_string.go index f1f069d079..fb53f2d765 100644 --- a/internal/sql/ast/bit_string.go +++ b/internal/sql/ast/bit_string.go @@ -1,7 +1,9 @@ package ast type BitString struct { - Str string + Tag NodeTag[BitString] `json:"tag"` + + Str string `json:"str"` } func (n *BitString) Pos() int { diff --git a/internal/sql/ast/block_id_data.go b/internal/sql/ast/block_id_data.go index ce5563f6bb..bcb5171924 100644 --- a/internal/sql/ast/block_id_data.go +++ b/internal/sql/ast/block_id_data.go @@ -1,8 +1,10 @@ package ast type BlockIdData struct { - BiHi uint16 - BiLo uint16 + Tag NodeTag[BlockIdData] `json:"tag"` + + BiHi uint16 `json:"bi_hi"` + BiLo uint16 `json:"bi_lo"` } func (n *BlockIdData) Pos() int { diff --git a/internal/sql/ast/bool_expr.go b/internal/sql/ast/bool_expr.go index 65b4af53d2..9efea3de12 100644 --- a/internal/sql/ast/bool_expr.go +++ b/internal/sql/ast/bool_expr.go @@ -3,10 +3,12 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type BoolExpr struct { - Xpr Node - Boolop BoolExprType - Args *List - Location int + Tag NodeTag[BoolExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Boolop BoolExprType `json:"boolop"` + Args *List `json:"args,omitempty"` + Location int `json:"location"` } func (n *BoolExpr) Pos() int { diff --git a/internal/sql/ast/boolean.go b/internal/sql/ast/boolean.go index 16a6db54da..b5a7502986 100644 --- a/internal/sql/ast/boolean.go +++ b/internal/sql/ast/boolean.go @@ -7,7 +7,9 @@ import ( ) type Boolean struct { - Boolval bool + Tag NodeTag[Boolean] `json:"tag"` + + Boolval bool `json:"boolval"` } func (n *Boolean) Pos() int { diff --git a/internal/sql/ast/boolean_test_expr.go b/internal/sql/ast/boolean_test_expr.go index 7efbb46462..f6f3d90680 100644 --- a/internal/sql/ast/boolean_test_expr.go +++ b/internal/sql/ast/boolean_test_expr.go @@ -1,10 +1,12 @@ package ast type BooleanTest struct { - Xpr Node - Arg Node - Booltesttype BoolTestType - Location int + Tag NodeTag[BooleanTest] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Booltesttype BoolTestType `json:"booltesttype"` + Location int `json:"location"` } func (n *BooleanTest) Pos() int { diff --git a/internal/sql/ast/call_stmt.go b/internal/sql/ast/call_stmt.go index 6cba39986e..c64b5a8aa4 100644 --- a/internal/sql/ast/call_stmt.go +++ b/internal/sql/ast/call_stmt.go @@ -3,7 +3,9 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CallStmt struct { - FuncCall *FuncCall + Tag NodeTag[CallStmt] `json:"tag"` + + FuncCall *FuncCall `json:"func_call,omitempty"` } func (n *CallStmt) Pos() int { diff --git a/internal/sql/ast/case_expr.go b/internal/sql/ast/case_expr.go index 52692b297b..4d9b6181a5 100644 --- a/internal/sql/ast/case_expr.go +++ b/internal/sql/ast/case_expr.go @@ -3,13 +3,15 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseExpr struct { - Xpr Node - Casetype Oid - Casecollid Oid - Arg Node - Args *List - Defresult Node - Location int + Tag NodeTag[CaseExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Casetype Oid `json:"casetype"` + Casecollid Oid `json:"casecollid"` + Arg Node `json:"arg,omitempty"` + Args *List `json:"args,omitempty"` + Defresult Node `json:"defresult,omitempty"` + Location int `json:"location"` } func (n *CaseExpr) Pos() int { diff --git a/internal/sql/ast/case_test_expr.go b/internal/sql/ast/case_test_expr.go index 8899985ca8..493293e93f 100644 --- a/internal/sql/ast/case_test_expr.go +++ b/internal/sql/ast/case_test_expr.go @@ -1,10 +1,12 @@ package ast type CaseTestExpr struct { - Xpr Node - TypeId Oid - TypeMod int32 - Collation Oid + Tag NodeTag[CaseTestExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + TypeId Oid `json:"type_id"` + TypeMod int32 `json:"type_mod"` + Collation Oid `json:"collation"` } func (n *CaseTestExpr) Pos() int { diff --git a/internal/sql/ast/case_when.go b/internal/sql/ast/case_when.go index 9636d24a97..fb39c4e269 100644 --- a/internal/sql/ast/case_when.go +++ b/internal/sql/ast/case_when.go @@ -3,10 +3,12 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseWhen struct { - Xpr Node - Expr Node - Result Node - Location int + Tag NodeTag[CaseWhen] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Expr Node `json:"expr,omitempty"` + Result Node `json:"result,omitempty"` + Location int `json:"location"` } func (n *CaseWhen) Pos() int { diff --git a/internal/sql/ast/check_point_stmt.go b/internal/sql/ast/check_point_stmt.go index b528fdc80b..55f6d13d67 100644 --- a/internal/sql/ast/check_point_stmt.go +++ b/internal/sql/ast/check_point_stmt.go @@ -1,6 +1,7 @@ package ast type CheckPointStmt struct { + Tag NodeTag[CheckPointStmt] `json:"tag"` } func (n *CheckPointStmt) Pos() int { diff --git a/internal/sql/ast/close_portal_stmt.go b/internal/sql/ast/close_portal_stmt.go index 0b5afddeeb..d690543df9 100644 --- a/internal/sql/ast/close_portal_stmt.go +++ b/internal/sql/ast/close_portal_stmt.go @@ -1,7 +1,9 @@ package ast type ClosePortalStmt struct { - Portalname *string + Tag NodeTag[ClosePortalStmt] `json:"tag"` + + Portalname *string `json:"portalname,omitempty"` } func (n *ClosePortalStmt) Pos() int { diff --git a/internal/sql/ast/cluster_stmt.go b/internal/sql/ast/cluster_stmt.go index 5e235eb482..f2b4588d51 100644 --- a/internal/sql/ast/cluster_stmt.go +++ b/internal/sql/ast/cluster_stmt.go @@ -1,9 +1,11 @@ package ast type ClusterStmt struct { - Relation *RangeVar - Indexname *string - Verbose bool + Tag NodeTag[ClusterStmt] `json:"tag"` + + Relation *RangeVar `json:"relation,omitempty"` + Indexname *string `json:"indexname,omitempty"` + Verbose bool `json:"verbose"` } func (n *ClusterStmt) Pos() int { diff --git a/internal/sql/ast/coalesce_expr.go b/internal/sql/ast/coalesce_expr.go index 6aadffd30c..f51c2c5c8e 100644 --- a/internal/sql/ast/coalesce_expr.go +++ b/internal/sql/ast/coalesce_expr.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CoalesceExpr struct { - Xpr Node - Coalescetype Oid - Coalescecollid Oid - Args *List - Location int + Tag NodeTag[CoalesceExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Coalescetype Oid `json:"coalescetype"` + Coalescecollid Oid `json:"coalescecollid"` + Args *List `json:"args,omitempty"` + Location int `json:"location"` } func (n *CoalesceExpr) Pos() int { diff --git a/internal/sql/ast/coerce_to_domain.go b/internal/sql/ast/coerce_to_domain.go index e81a83f15d..09e681b537 100644 --- a/internal/sql/ast/coerce_to_domain.go +++ b/internal/sql/ast/coerce_to_domain.go @@ -1,13 +1,15 @@ package ast type CoerceToDomain struct { - Xpr Node - Arg Node - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid - Coercionformat CoercionForm - Location int + Tag NodeTag[CoerceToDomain] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Resulttype Oid `json:"resulttype"` + Resulttypmod int32 `json:"resulttypmod"` + Resultcollid Oid `json:"resultcollid"` + Coercionformat CoercionForm `json:"coercionformat"` + Location int `json:"location"` } func (n *CoerceToDomain) Pos() int { diff --git a/internal/sql/ast/coerce_to_domain_value.go b/internal/sql/ast/coerce_to_domain_value.go index b2e26cb00c..d78b3bf89c 100644 --- a/internal/sql/ast/coerce_to_domain_value.go +++ b/internal/sql/ast/coerce_to_domain_value.go @@ -1,11 +1,13 @@ package ast type CoerceToDomainValue struct { - Xpr Node - TypeId Oid - TypeMod int32 - Collation Oid - Location int + Tag NodeTag[CoerceToDomainValue] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + TypeId Oid `json:"type_id"` + TypeMod int32 `json:"type_mod"` + Collation Oid `json:"collation"` + Location int `json:"location"` } func (n *CoerceToDomainValue) Pos() int { diff --git a/internal/sql/ast/coerce_via_io.go b/internal/sql/ast/coerce_via_io.go index 48aea6ce72..5c9f80970c 100644 --- a/internal/sql/ast/coerce_via_io.go +++ b/internal/sql/ast/coerce_via_io.go @@ -1,12 +1,14 @@ package ast type CoerceViaIO struct { - Xpr Node - Arg Node - Resulttype Oid - Resultcollid Oid - Coerceformat CoercionForm - Location int + Tag NodeTag[CoerceViaIO] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Resulttype Oid `json:"resulttype"` + Resultcollid Oid `json:"resultcollid"` + Coerceformat CoercionForm `json:"coerceformat"` + Location int `json:"location"` } func (n *CoerceViaIO) Pos() int { diff --git a/internal/sql/ast/collate_clause.go b/internal/sql/ast/collate_clause.go index 0c1629a05d..494b3e1f7b 100644 --- a/internal/sql/ast/collate_clause.go +++ b/internal/sql/ast/collate_clause.go @@ -1,9 +1,11 @@ package ast type CollateClause struct { - Arg Node - Collname *List - Location int + Tag NodeTag[CollateClause] `json:"tag"` + + Arg Node `json:"arg,omitempty"` + Collname *List `json:"collname,omitempty"` + Location int `json:"location"` } func (n *CollateClause) Pos() int { diff --git a/internal/sql/ast/collate_expr.go b/internal/sql/ast/collate_expr.go index 80483f75ce..c5643584b8 100644 --- a/internal/sql/ast/collate_expr.go +++ b/internal/sql/ast/collate_expr.go @@ -3,10 +3,12 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CollateExpr struct { - Xpr Node - Arg Node - CollOid Oid - Location int + Tag NodeTag[CollateExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + CollOid Oid `json:"coll_oid"` + Location int `json:"location"` } func (n *CollateExpr) Pos() int { diff --git a/internal/sql/ast/column_def.go b/internal/sql/ast/column_def.go index 6ac6a6e0c7..bc6687d4cb 100644 --- a/internal/sql/ast/column_def.go +++ b/internal/sql/ast/column_def.go @@ -3,40 +3,42 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ColumnDef struct { - Colname string + Tag NodeTag[ColumnDef] `json:"tag"` + + Colname string `json:"colname"` // TypeName is the column's type for the catalog. When Typeless is set // the author wrote no type at all — SQLite allows it — and the column // prints without one, whatever TypeName carries. - TypeName *TypeName - Typeless bool - IsNotNull bool - IsUnsigned bool - IsArray bool - ArrayDims int - Vals *List - Length *int - PrimaryKey bool + TypeName *TypeName `json:"type_name,omitempty"` + Typeless bool `json:"typeless"` + IsNotNull bool `json:"is_not_null"` + IsUnsigned bool `json:"is_unsigned"` + IsArray bool `json:"is_array"` + ArrayDims int `json:"array_dims"` + Vals *List `json:"vals,omitempty"` + Length *int `json:"length,omitempty"` + PrimaryKey bool `json:"primary_key"` // IsHidden marks a column a relation offers by name without listing it, // like the column an sqlite fts5 table names after itself. The legacy // catalog drops hidden columns; the core catalog keeps them out of star // expansions and models. - IsHidden bool + IsHidden bool `json:"is_hidden"` // From pg.ColumnDef - Inhcount int - IsLocal bool - IsFromType bool - IsFromParent bool - Storage byte - RawDefault Node - CookedDefault Node - Identity byte - CollClause *CollateClause - CollOid Oid - Constraints *List - Fdwoptions *List - Location int - Comment string + Inhcount int `json:"inhcount"` + IsLocal bool `json:"is_local"` + IsFromType bool `json:"is_from_type"` + IsFromParent bool `json:"is_from_parent"` + Storage byte `json:"storage"` + RawDefault Node `json:"raw_default,omitempty"` + CookedDefault Node `json:"cooked_default,omitempty"` + Identity byte `json:"identity"` + CollClause *CollateClause `json:"coll_clause,omitempty"` + CollOid Oid `json:"coll_oid"` + Constraints *List `json:"constraints,omitempty"` + Fdwoptions *List `json:"fdwoptions,omitempty"` + Location int `json:"location"` + Comment string `json:"comment"` } func (n *ColumnDef) Pos() int { diff --git a/internal/sql/ast/column_ref.go b/internal/sql/ast/column_ref.go index 943311799d..f04c7b406d 100644 --- a/internal/sql/ast/column_ref.go +++ b/internal/sql/ast/column_ref.go @@ -7,11 +7,13 @@ import ( ) type ColumnRef struct { - Name string + Tag NodeTag[ColumnRef] `json:"tag"` + + Name string `json:"name"` // From pg.ColumnRef - Fields *List - Location int + Fields *List `json:"fields,omitempty"` + Location int `json:"location"` } func (n *ColumnRef) Pos() int { diff --git a/internal/sql/ast/comment_on_column_stmt.go b/internal/sql/ast/comment_on_column_stmt.go index 6438b4ccc7..c35517ee27 100644 --- a/internal/sql/ast/comment_on_column_stmt.go +++ b/internal/sql/ast/comment_on_column_stmt.go @@ -1,9 +1,11 @@ package ast type CommentOnColumnStmt struct { - Table *TableName - Col *ColumnRef - Comment *string + Tag NodeTag[CommentOnColumnStmt] `json:"tag"` + + Table *TableName `json:"table,omitempty"` + Col *ColumnRef `json:"col,omitempty"` + Comment *string `json:"comment,omitempty"` } func (n *CommentOnColumnStmt) Pos() int { diff --git a/internal/sql/ast/comment_on_schema_stmt.go b/internal/sql/ast/comment_on_schema_stmt.go index edff162db0..aac64c4cac 100644 --- a/internal/sql/ast/comment_on_schema_stmt.go +++ b/internal/sql/ast/comment_on_schema_stmt.go @@ -1,8 +1,10 @@ package ast type CommentOnSchemaStmt struct { - Schema *String - Comment *string + Tag NodeTag[CommentOnSchemaStmt] `json:"tag"` + + Schema *String `json:"schema,omitempty"` + Comment *string `json:"comment,omitempty"` } func (n *CommentOnSchemaStmt) Pos() int { diff --git a/internal/sql/ast/comment_on_table_stmt.go b/internal/sql/ast/comment_on_table_stmt.go index efb158f94b..d6056fa170 100644 --- a/internal/sql/ast/comment_on_table_stmt.go +++ b/internal/sql/ast/comment_on_table_stmt.go @@ -1,8 +1,10 @@ package ast type CommentOnTableStmt struct { - Table *TableName - Comment *string + Tag NodeTag[CommentOnTableStmt] `json:"tag"` + + Table *TableName `json:"table,omitempty"` + Comment *string `json:"comment,omitempty"` } func (n *CommentOnTableStmt) Pos() int { diff --git a/internal/sql/ast/comment_on_type_stmt.go b/internal/sql/ast/comment_on_type_stmt.go index eb90bf5115..616fca31cc 100644 --- a/internal/sql/ast/comment_on_type_stmt.go +++ b/internal/sql/ast/comment_on_type_stmt.go @@ -1,8 +1,10 @@ package ast type CommentOnTypeStmt struct { - Type *TypeName - Comment *string + Tag NodeTag[CommentOnTypeStmt] `json:"tag"` + + Type *TypeName `json:"type,omitempty"` + Comment *string `json:"comment,omitempty"` } func (n *CommentOnTypeStmt) Pos() int { diff --git a/internal/sql/ast/comment_on_view_stmt.go b/internal/sql/ast/comment_on_view_stmt.go index 2648d87918..c857f77c4c 100644 --- a/internal/sql/ast/comment_on_view_stmt.go +++ b/internal/sql/ast/comment_on_view_stmt.go @@ -1,8 +1,10 @@ package ast type CommentOnViewStmt struct { - View *TableName - Comment *string + Tag NodeTag[CommentOnViewStmt] `json:"tag"` + + View *TableName `json:"view,omitempty"` + Comment *string `json:"comment,omitempty"` } func (n *CommentOnViewStmt) Pos() int { diff --git a/internal/sql/ast/comment_stmt.go b/internal/sql/ast/comment_stmt.go index 304827a294..61f6269ac1 100644 --- a/internal/sql/ast/comment_stmt.go +++ b/internal/sql/ast/comment_stmt.go @@ -1,9 +1,11 @@ package ast type CommentStmt struct { - Objtype ObjectType - Object Node - Comment *string + Tag NodeTag[CommentStmt] `json:"tag"` + + Objtype ObjectType `json:"objtype"` + Object Node `json:"object,omitempty"` + Comment *string `json:"comment,omitempty"` } func (n *CommentStmt) Pos() int { diff --git a/internal/sql/ast/common_table_expr.go b/internal/sql/ast/common_table_expr.go index a9cc9d5022..84f7db47af 100644 --- a/internal/sql/ast/common_table_expr.go +++ b/internal/sql/ast/common_table_expr.go @@ -3,16 +3,18 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CommonTableExpr struct { - Ctename *string - Aliascolnames *List - Ctequery Node - Location int - Cterecursive bool - Cterefcount int - Ctecolnames *List - Ctecoltypes *List - Ctecoltypmods *List - Ctecolcollations *List + Tag NodeTag[CommonTableExpr] `json:"tag"` + + Ctename *string `json:"ctename,omitempty"` + Aliascolnames *List `json:"aliascolnames,omitempty"` + Ctequery Node `json:"ctequery,omitempty"` + Location int `json:"location"` + Cterecursive bool `json:"cterecursive"` + Cterefcount int `json:"cterefcount"` + Ctecolnames *List `json:"ctecolnames,omitempty"` + Ctecoltypes *List `json:"ctecoltypes,omitempty"` + Ctecoltypmods *List `json:"ctecoltypmods,omitempty"` + Ctecolcollations *List `json:"ctecolcollations,omitempty"` } func (n *CommonTableExpr) Pos() int { diff --git a/internal/sql/ast/composite_type_stmt.go b/internal/sql/ast/composite_type_stmt.go index f9a19b2653..eab6f7f4cc 100644 --- a/internal/sql/ast/composite_type_stmt.go +++ b/internal/sql/ast/composite_type_stmt.go @@ -1,7 +1,9 @@ package ast type CompositeTypeStmt struct { - TypeName *TypeName + Tag NodeTag[CompositeTypeStmt] `json:"tag"` + + TypeName *TypeName `json:"type_name,omitempty"` } func (n *CompositeTypeStmt) Pos() int { diff --git a/internal/sql/ast/const.go b/internal/sql/ast/const.go index d33f0e84ed..58d33e9920 100644 --- a/internal/sql/ast/const.go +++ b/internal/sql/ast/const.go @@ -1,15 +1,17 @@ package ast type Const struct { - Xpr Node - Consttype Oid - Consttypmod int32 - Constcollid Oid - Constlen int - Constvalue Datum - Constisnull bool - Constbyval bool - Location int + Tag NodeTag[Const] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Consttype Oid `json:"consttype"` + Consttypmod int32 `json:"consttypmod"` + Constcollid Oid `json:"constcollid"` + Constlen int `json:"constlen"` + Constvalue Datum `json:"constvalue"` + Constisnull bool `json:"constisnull"` + Constbyval bool `json:"constbyval"` + Location int `json:"location"` } func (n *Const) Pos() int { diff --git a/internal/sql/ast/constraint.go b/internal/sql/ast/constraint.go index 5b628506af..bd9c7348f1 100644 --- a/internal/sql/ast/constraint.go +++ b/internal/sql/ast/constraint.go @@ -1,32 +1,34 @@ package ast type Constraint struct { - Contype ConstrType - Conname *string - Deferrable bool - Initdeferred bool - Location int - IsNoInherit bool - RawExpr Node - CookedExpr *string - GeneratedWhen byte - Keys *List - Exclusions *List - Options *List - Indexname *string - Indexspace *string - AccessMethod *string - WhereClause Node - Pktable *RangeVar - FkAttrs *List - PkAttrs *List - FkMatchtype byte - FkUpdAction byte - FkDelAction byte - OldConpfeqop *List - OldPktableOid Oid - SkipValidation bool - InitiallyValid bool + Tag NodeTag[Constraint] `json:"tag"` + + Contype ConstrType `json:"contype"` + Conname *string `json:"conname,omitempty"` + Deferrable bool `json:"deferrable"` + Initdeferred bool `json:"initdeferred"` + Location int `json:"location"` + IsNoInherit bool `json:"is_no_inherit"` + RawExpr Node `json:"raw_expr,omitempty"` + CookedExpr *string `json:"cooked_expr,omitempty"` + GeneratedWhen byte `json:"generated_when"` + Keys *List `json:"keys,omitempty"` + Exclusions *List `json:"exclusions,omitempty"` + Options *List `json:"options,omitempty"` + Indexname *string `json:"indexname,omitempty"` + Indexspace *string `json:"indexspace,omitempty"` + AccessMethod *string `json:"access_method,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + Pktable *RangeVar `json:"pktable,omitempty"` + FkAttrs *List `json:"fk_attrs,omitempty"` + PkAttrs *List `json:"pk_attrs,omitempty"` + FkMatchtype byte `json:"fk_matchtype"` + FkUpdAction byte `json:"fk_upd_action"` + FkDelAction byte `json:"fk_del_action"` + OldConpfeqop *List `json:"old_conpfeqop,omitempty"` + OldPktableOid Oid `json:"old_pktable_oid"` + SkipValidation bool `json:"skip_validation"` + InitiallyValid bool `json:"initially_valid"` } func (n *Constraint) Pos() int { diff --git a/internal/sql/ast/constraints_set_stmt.go b/internal/sql/ast/constraints_set_stmt.go index ca0a33323d..b677dca751 100644 --- a/internal/sql/ast/constraints_set_stmt.go +++ b/internal/sql/ast/constraints_set_stmt.go @@ -1,8 +1,10 @@ package ast type ConstraintsSetStmt struct { - Constraints *List - Deferred bool + Tag NodeTag[ConstraintsSetStmt] `json:"tag"` + + Constraints *List `json:"constraints,omitempty"` + Deferred bool `json:"deferred"` } func (n *ConstraintsSetStmt) Pos() int { diff --git a/internal/sql/ast/convert_rowtype_expr.go b/internal/sql/ast/convert_rowtype_expr.go index 9e72c0c5c5..60c3f12c1d 100644 --- a/internal/sql/ast/convert_rowtype_expr.go +++ b/internal/sql/ast/convert_rowtype_expr.go @@ -1,11 +1,13 @@ package ast type ConvertRowtypeExpr struct { - Xpr Node - Arg Node - Resulttype Oid - Convertformat CoercionForm - Location int + Tag NodeTag[ConvertRowtypeExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Resulttype Oid `json:"resulttype"` + Convertformat CoercionForm `json:"convertformat"` + Location int `json:"location"` } func (n *ConvertRowtypeExpr) Pos() int { diff --git a/internal/sql/ast/copy_stmt.go b/internal/sql/ast/copy_stmt.go index 65d4dc69cc..93d83d6fde 100644 --- a/internal/sql/ast/copy_stmt.go +++ b/internal/sql/ast/copy_stmt.go @@ -1,13 +1,15 @@ package ast type CopyStmt struct { - Relation *RangeVar - Query Node - Attlist *List - IsFrom bool - IsProgram bool - Filename *string - Options *List + Tag NodeTag[CopyStmt] `json:"tag"` + + Relation *RangeVar `json:"relation,omitempty"` + Query Node `json:"query,omitempty"` + Attlist *List `json:"attlist,omitempty"` + IsFrom bool `json:"is_from"` + IsProgram bool `json:"is_program"` + Filename *string `json:"filename,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CopyStmt) Pos() int { diff --git a/internal/sql/ast/create_am_stmt.go b/internal/sql/ast/create_am_stmt.go index 16fe6455c5..8f0859067b 100644 --- a/internal/sql/ast/create_am_stmt.go +++ b/internal/sql/ast/create_am_stmt.go @@ -1,9 +1,11 @@ package ast type CreateAmStmt struct { - Amname *string - HandlerName *List - Amtype byte + Tag NodeTag[CreateAmStmt] `json:"tag"` + + Amname *string `json:"amname,omitempty"` + HandlerName *List `json:"handler_name,omitempty"` + Amtype byte `json:"amtype"` } func (n *CreateAmStmt) Pos() int { diff --git a/internal/sql/ast/create_cast_stmt.go b/internal/sql/ast/create_cast_stmt.go index 7ae94d3c6b..188d633c8c 100644 --- a/internal/sql/ast/create_cast_stmt.go +++ b/internal/sql/ast/create_cast_stmt.go @@ -1,11 +1,13 @@ package ast type CreateCastStmt struct { - Sourcetype *TypeName - Targettype *TypeName - Func *ObjectWithArgs - Context CoercionContext - Inout bool + Tag NodeTag[CreateCastStmt] `json:"tag"` + + Sourcetype *TypeName `json:"sourcetype,omitempty"` + Targettype *TypeName `json:"targettype,omitempty"` + Func *ObjectWithArgs `json:"func,omitempty"` + Context CoercionContext `json:"context"` + Inout bool `json:"inout"` } func (n *CreateCastStmt) Pos() int { diff --git a/internal/sql/ast/create_conversion_stmt.go b/internal/sql/ast/create_conversion_stmt.go index c0f4de14b1..38be006520 100644 --- a/internal/sql/ast/create_conversion_stmt.go +++ b/internal/sql/ast/create_conversion_stmt.go @@ -1,11 +1,13 @@ package ast type CreateConversionStmt struct { - ConversionName *List - ForEncodingName *string - ToEncodingName *string - FuncName *List - Def bool + Tag NodeTag[CreateConversionStmt] `json:"tag"` + + ConversionName *List `json:"conversion_name,omitempty"` + ForEncodingName *string `json:"for_encoding_name,omitempty"` + ToEncodingName *string `json:"to_encoding_name,omitempty"` + FuncName *List `json:"func_name,omitempty"` + Def bool `json:"def"` } func (n *CreateConversionStmt) Pos() int { diff --git a/internal/sql/ast/create_domain_stmt.go b/internal/sql/ast/create_domain_stmt.go index 3c541c4b2e..8cc2324c35 100644 --- a/internal/sql/ast/create_domain_stmt.go +++ b/internal/sql/ast/create_domain_stmt.go @@ -1,10 +1,12 @@ package ast type CreateDomainStmt struct { - Domainname *List - TypeName *TypeName - CollClause *CollateClause - Constraints *List + Tag NodeTag[CreateDomainStmt] `json:"tag"` + + Domainname *List `json:"domainname,omitempty"` + TypeName *TypeName `json:"type_name,omitempty"` + CollClause *CollateClause `json:"coll_clause,omitempty"` + Constraints *List `json:"constraints,omitempty"` } func (n *CreateDomainStmt) Pos() int { diff --git a/internal/sql/ast/create_enum_stmt.go b/internal/sql/ast/create_enum_stmt.go index a7d2df0fc9..f38316b4aa 100644 --- a/internal/sql/ast/create_enum_stmt.go +++ b/internal/sql/ast/create_enum_stmt.go @@ -1,8 +1,10 @@ package ast type CreateEnumStmt struct { - TypeName *TypeName - Vals *List + Tag NodeTag[CreateEnumStmt] `json:"tag"` + + TypeName *TypeName `json:"type_name,omitempty"` + Vals *List `json:"vals,omitempty"` } func (n *CreateEnumStmt) Pos() int { diff --git a/internal/sql/ast/create_event_trig_stmt.go b/internal/sql/ast/create_event_trig_stmt.go index 276b32a6a0..eea8012286 100644 --- a/internal/sql/ast/create_event_trig_stmt.go +++ b/internal/sql/ast/create_event_trig_stmt.go @@ -1,10 +1,12 @@ package ast type CreateEventTrigStmt struct { - Trigname *string - Eventname *string - Whenclause *List - Funcname *List + Tag NodeTag[CreateEventTrigStmt] `json:"tag"` + + Trigname *string `json:"trigname,omitempty"` + Eventname *string `json:"eventname,omitempty"` + Whenclause *List `json:"whenclause,omitempty"` + Funcname *List `json:"funcname,omitempty"` } func (n *CreateEventTrigStmt) Pos() int { diff --git a/internal/sql/ast/create_extension_stmt.go b/internal/sql/ast/create_extension_stmt.go index 140a10da4c..d73aed8308 100644 --- a/internal/sql/ast/create_extension_stmt.go +++ b/internal/sql/ast/create_extension_stmt.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateExtensionStmt struct { - Extname *string - IfNotExists bool - Options *List + Tag NodeTag[CreateExtensionStmt] `json:"tag"` + + Extname *string `json:"extname,omitempty"` + IfNotExists bool `json:"if_not_exists"` + Options *List `json:"options,omitempty"` } func (n *CreateExtensionStmt) Pos() int { diff --git a/internal/sql/ast/create_fdw_stmt.go b/internal/sql/ast/create_fdw_stmt.go index fd97378308..74cb794294 100644 --- a/internal/sql/ast/create_fdw_stmt.go +++ b/internal/sql/ast/create_fdw_stmt.go @@ -1,9 +1,11 @@ package ast type CreateFdwStmt struct { - Fdwname *string - FuncOptions *List - Options *List + Tag NodeTag[CreateFdwStmt] `json:"tag"` + + Fdwname *string `json:"fdwname,omitempty"` + FuncOptions *List `json:"func_options,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CreateFdwStmt) Pos() int { diff --git a/internal/sql/ast/create_foreign_server_stmt.go b/internal/sql/ast/create_foreign_server_stmt.go index b7d24445b4..da9d78a58e 100644 --- a/internal/sql/ast/create_foreign_server_stmt.go +++ b/internal/sql/ast/create_foreign_server_stmt.go @@ -1,12 +1,14 @@ package ast type CreateForeignServerStmt struct { - Servername *string - Servertype *string - Version *string - Fdwname *string - IfNotExists bool - Options *List + Tag NodeTag[CreateForeignServerStmt] `json:"tag"` + + Servername *string `json:"servername,omitempty"` + Servertype *string `json:"servertype,omitempty"` + Version *string `json:"version,omitempty"` + Fdwname *string `json:"fdwname,omitempty"` + IfNotExists bool `json:"if_not_exists"` + Options *List `json:"options,omitempty"` } func (n *CreateForeignServerStmt) Pos() int { diff --git a/internal/sql/ast/create_foreign_table_stmt.go b/internal/sql/ast/create_foreign_table_stmt.go index 6661588786..764e72996d 100644 --- a/internal/sql/ast/create_foreign_table_stmt.go +++ b/internal/sql/ast/create_foreign_table_stmt.go @@ -1,9 +1,11 @@ package ast type CreateForeignTableStmt struct { - Base *CreateStmt - Servername *string - Options *List + Tag NodeTag[CreateForeignTableStmt] `json:"tag"` + + Base *CreateStmt `json:"base,omitempty"` + Servername *string `json:"servername,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CreateForeignTableStmt) Pos() int { diff --git a/internal/sql/ast/create_function_stmt.go b/internal/sql/ast/create_function_stmt.go index f5200085ee..3fb3bb79fa 100644 --- a/internal/sql/ast/create_function_stmt.go +++ b/internal/sql/ast/create_function_stmt.go @@ -3,13 +3,15 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateFunctionStmt struct { - Replace bool - Params *List - ReturnType *TypeName - Func *FuncName + Tag NodeTag[CreateFunctionStmt] `json:"tag"` + + Replace bool `json:"replace"` + Params *List `json:"params,omitempty"` + ReturnType *TypeName `json:"return_type,omitempty"` + Func *FuncName `json:"func,omitempty"` // TODO: Understand these two fields - Options *List - WithClause *List + Options *List `json:"options,omitempty"` + WithClause *List `json:"with_clause,omitempty"` } func (n *CreateFunctionStmt) Pos() int { diff --git a/internal/sql/ast/create_op_class_item.go b/internal/sql/ast/create_op_class_item.go index 09621bd0d8..0b1f4ad728 100644 --- a/internal/sql/ast/create_op_class_item.go +++ b/internal/sql/ast/create_op_class_item.go @@ -1,12 +1,14 @@ package ast type CreateOpClassItem struct { - Itemtype int - Name *ObjectWithArgs - Number int - OrderFamily *List - ClassArgs *List - Storedtype *TypeName + Tag NodeTag[CreateOpClassItem] `json:"tag"` + + Itemtype int `json:"itemtype"` + Name *ObjectWithArgs `json:"name,omitempty"` + Number int `json:"number"` + OrderFamily *List `json:"order_family,omitempty"` + ClassArgs *List `json:"class_args,omitempty"` + Storedtype *TypeName `json:"storedtype,omitempty"` } func (n *CreateOpClassItem) Pos() int { diff --git a/internal/sql/ast/create_op_class_stmt.go b/internal/sql/ast/create_op_class_stmt.go index a4ab7b067c..9b606c4610 100644 --- a/internal/sql/ast/create_op_class_stmt.go +++ b/internal/sql/ast/create_op_class_stmt.go @@ -1,12 +1,14 @@ package ast type CreateOpClassStmt struct { - Opclassname *List - Opfamilyname *List - Amname *string - Datatype *TypeName - Items *List - IsDefault bool + Tag NodeTag[CreateOpClassStmt] `json:"tag"` + + Opclassname *List `json:"opclassname,omitempty"` + Opfamilyname *List `json:"opfamilyname,omitempty"` + Amname *string `json:"amname,omitempty"` + Datatype *TypeName `json:"datatype,omitempty"` + Items *List `json:"items,omitempty"` + IsDefault bool `json:"is_default"` } func (n *CreateOpClassStmt) Pos() int { diff --git a/internal/sql/ast/create_op_family_stmt.go b/internal/sql/ast/create_op_family_stmt.go index b939625ed3..4db1cc411b 100644 --- a/internal/sql/ast/create_op_family_stmt.go +++ b/internal/sql/ast/create_op_family_stmt.go @@ -1,8 +1,10 @@ package ast type CreateOpFamilyStmt struct { - Opfamilyname *List - Amname *string + Tag NodeTag[CreateOpFamilyStmt] `json:"tag"` + + Opfamilyname *List `json:"opfamilyname,omitempty"` + Amname *string `json:"amname,omitempty"` } func (n *CreateOpFamilyStmt) Pos() int { diff --git a/internal/sql/ast/create_p_lang_stmt.go b/internal/sql/ast/create_p_lang_stmt.go index 5f11ce9eb1..f6d43980e9 100644 --- a/internal/sql/ast/create_p_lang_stmt.go +++ b/internal/sql/ast/create_p_lang_stmt.go @@ -1,12 +1,14 @@ package ast type CreatePLangStmt struct { - Replace bool - Plname *string - Plhandler *List - Plinline *List - Plvalidator *List - Pltrusted bool + Tag NodeTag[CreatePLangStmt] `json:"tag"` + + Replace bool `json:"replace"` + Plname *string `json:"plname,omitempty"` + Plhandler *List `json:"plhandler,omitempty"` + Plinline *List `json:"plinline,omitempty"` + Plvalidator *List `json:"plvalidator,omitempty"` + Pltrusted bool `json:"pltrusted"` } func (n *CreatePLangStmt) Pos() int { diff --git a/internal/sql/ast/create_policy_stmt.go b/internal/sql/ast/create_policy_stmt.go index 39e244f7a4..3d191a2480 100644 --- a/internal/sql/ast/create_policy_stmt.go +++ b/internal/sql/ast/create_policy_stmt.go @@ -1,13 +1,15 @@ package ast type CreatePolicyStmt struct { - PolicyName *string - Table *RangeVar - CmdName *string - Permissive bool - Roles *List - Qual Node - WithCheck Node + Tag NodeTag[CreatePolicyStmt] `json:"tag"` + + PolicyName *string `json:"policy_name,omitempty"` + Table *RangeVar `json:"table,omitempty"` + CmdName *string `json:"cmd_name,omitempty"` + Permissive bool `json:"permissive"` + Roles *List `json:"roles,omitempty"` + Qual Node `json:"qual,omitempty"` + WithCheck Node `json:"with_check,omitempty"` } func (n *CreatePolicyStmt) Pos() int { diff --git a/internal/sql/ast/create_publication_stmt.go b/internal/sql/ast/create_publication_stmt.go index 5d0b6a05f5..90e0c737af 100644 --- a/internal/sql/ast/create_publication_stmt.go +++ b/internal/sql/ast/create_publication_stmt.go @@ -1,10 +1,12 @@ package ast type CreatePublicationStmt struct { - Pubname *string - Options *List - Tables *List - ForAllTables bool + Tag NodeTag[CreatePublicationStmt] `json:"tag"` + + Pubname *string `json:"pubname,omitempty"` + Options *List `json:"options,omitempty"` + Tables *List `json:"tables,omitempty"` + ForAllTables bool `json:"for_all_tables"` } func (n *CreatePublicationStmt) Pos() int { diff --git a/internal/sql/ast/create_range_stmt.go b/internal/sql/ast/create_range_stmt.go index 6e0aaa5092..7ac3b8a353 100644 --- a/internal/sql/ast/create_range_stmt.go +++ b/internal/sql/ast/create_range_stmt.go @@ -1,8 +1,10 @@ package ast type CreateRangeStmt struct { - TypeName *List - Params *List + Tag NodeTag[CreateRangeStmt] `json:"tag"` + + TypeName *List `json:"type_name,omitempty"` + Params *List `json:"params,omitempty"` } func (n *CreateRangeStmt) Pos() int { diff --git a/internal/sql/ast/create_role_stmt.go b/internal/sql/ast/create_role_stmt.go index 144540863e..667d702dd9 100644 --- a/internal/sql/ast/create_role_stmt.go +++ b/internal/sql/ast/create_role_stmt.go @@ -1,9 +1,11 @@ package ast type CreateRoleStmt struct { - StmtType RoleStmtType - Role *string - Options *List + Tag NodeTag[CreateRoleStmt] `json:"tag"` + + StmtType RoleStmtType `json:"stmt_type"` + Role *string `json:"role,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CreateRoleStmt) Pos() int { diff --git a/internal/sql/ast/create_schema_stmt.go b/internal/sql/ast/create_schema_stmt.go index 522f404ec4..e07dafaffd 100644 --- a/internal/sql/ast/create_schema_stmt.go +++ b/internal/sql/ast/create_schema_stmt.go @@ -1,10 +1,12 @@ package ast type CreateSchemaStmt struct { - Name *string - SchemaElts *List - Authrole *RoleSpec - IfNotExists bool + Tag NodeTag[CreateSchemaStmt] `json:"tag"` + + Name *string `json:"name,omitempty"` + SchemaElts *List `json:"schema_elts,omitempty"` + Authrole *RoleSpec `json:"authrole,omitempty"` + IfNotExists bool `json:"if_not_exists"` } func (n *CreateSchemaStmt) Pos() int { diff --git a/internal/sql/ast/create_seq_stmt.go b/internal/sql/ast/create_seq_stmt.go index f7b9ef564d..66c35a7080 100644 --- a/internal/sql/ast/create_seq_stmt.go +++ b/internal/sql/ast/create_seq_stmt.go @@ -1,11 +1,13 @@ package ast type CreateSeqStmt struct { - Sequence *RangeVar - Options *List - OwnerId Oid - ForIdentity bool - IfNotExists bool + Tag NodeTag[CreateSeqStmt] `json:"tag"` + + Sequence *RangeVar `json:"sequence,omitempty"` + Options *List `json:"options,omitempty"` + OwnerId Oid `json:"owner_id"` + ForIdentity bool `json:"for_identity"` + IfNotExists bool `json:"if_not_exists"` } func (n *CreateSeqStmt) Pos() int { diff --git a/internal/sql/ast/create_stats_stmt.go b/internal/sql/ast/create_stats_stmt.go index 4bd64e162c..17b8af22a3 100644 --- a/internal/sql/ast/create_stats_stmt.go +++ b/internal/sql/ast/create_stats_stmt.go @@ -1,11 +1,13 @@ package ast type CreateStatsStmt struct { - Defnames *List - StatTypes *List - Exprs *List - Relations *List - IfNotExists bool + Tag NodeTag[CreateStatsStmt] `json:"tag"` + + Defnames *List `json:"defnames,omitempty"` + StatTypes *List `json:"stat_types,omitempty"` + Exprs *List `json:"exprs,omitempty"` + Relations *List `json:"relations,omitempty"` + IfNotExists bool `json:"if_not_exists"` } func (n *CreateStatsStmt) Pos() int { diff --git a/internal/sql/ast/create_stmt.go b/internal/sql/ast/create_stmt.go index 7982b690a2..5d69e7bb16 100644 --- a/internal/sql/ast/create_stmt.go +++ b/internal/sql/ast/create_stmt.go @@ -1,17 +1,19 @@ package ast type CreateStmt struct { - Relation *RangeVar - TableElts *List - InhRelations *List - Partbound *PartitionBoundSpec - Partspec *PartitionSpec - OfTypename *TypeName - Constraints *List - Options *List - Oncommit OnCommitAction - Tablespacename *string - IfNotExists bool + Tag NodeTag[CreateStmt] `json:"tag"` + + Relation *RangeVar `json:"relation,omitempty"` + TableElts *List `json:"table_elts,omitempty"` + InhRelations *List `json:"inh_relations,omitempty"` + Partbound *PartitionBoundSpec `json:"partbound,omitempty"` + Partspec *PartitionSpec `json:"partspec,omitempty"` + OfTypename *TypeName `json:"of_typename,omitempty"` + Constraints *List `json:"constraints,omitempty"` + Options *List `json:"options,omitempty"` + Oncommit OnCommitAction `json:"oncommit"` + Tablespacename *string `json:"tablespacename,omitempty"` + IfNotExists bool `json:"if_not_exists"` } func (n *CreateStmt) Pos() int { diff --git a/internal/sql/ast/create_subscription_stmt.go b/internal/sql/ast/create_subscription_stmt.go index 1d7d49c403..d4c3c678a4 100644 --- a/internal/sql/ast/create_subscription_stmt.go +++ b/internal/sql/ast/create_subscription_stmt.go @@ -1,10 +1,12 @@ package ast type CreateSubscriptionStmt struct { - Subname *string - Conninfo *string - Publication *List - Options *List + Tag NodeTag[CreateSubscriptionStmt] `json:"tag"` + + Subname *string `json:"subname,omitempty"` + Conninfo *string `json:"conninfo,omitempty"` + Publication *List `json:"publication,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CreateSubscriptionStmt) Pos() int { diff --git a/internal/sql/ast/create_table_as_stmt.go b/internal/sql/ast/create_table_as_stmt.go index 6dbf291de4..862d0c45d0 100644 --- a/internal/sql/ast/create_table_as_stmt.go +++ b/internal/sql/ast/create_table_as_stmt.go @@ -1,11 +1,13 @@ package ast type CreateTableAsStmt struct { - Query Node - Into *IntoClause - Relkind ObjectType - IsSelectInto bool - IfNotExists bool + Tag NodeTag[CreateTableAsStmt] `json:"tag"` + + Query Node `json:"query,omitempty"` + Into *IntoClause `json:"into,omitempty"` + Relkind ObjectType `json:"relkind"` + IsSelectInto bool `json:"is_select_into"` + IfNotExists bool `json:"if_not_exists"` } func (n *CreateTableAsStmt) Pos() int { diff --git a/internal/sql/ast/create_table_space_stmt.go b/internal/sql/ast/create_table_space_stmt.go index 92951572d3..7c55d5d86a 100644 --- a/internal/sql/ast/create_table_space_stmt.go +++ b/internal/sql/ast/create_table_space_stmt.go @@ -1,10 +1,12 @@ package ast type CreateTableSpaceStmt struct { - Tablespacename *string - Owner *RoleSpec - Location *string - Options *List + Tag NodeTag[CreateTableSpaceStmt] `json:"tag"` + + Tablespacename *string `json:"tablespacename,omitempty"` + Owner *RoleSpec `json:"owner,omitempty"` + Location *string `json:"location,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CreateTableSpaceStmt) Pos() int { diff --git a/internal/sql/ast/create_table_stmt.go b/internal/sql/ast/create_table_stmt.go index cd11c61fac..4abe5d09fb 100644 --- a/internal/sql/ast/create_table_stmt.go +++ b/internal/sql/ast/create_table_stmt.go @@ -3,12 +3,14 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateTableStmt struct { - IfNotExists bool - Name *TableName - Cols []*ColumnDef - ReferTable *TableName - Comment string - Inherits []*TableName + Tag NodeTag[CreateTableStmt] `json:"tag"` + + IfNotExists bool `json:"if_not_exists"` + Name *TableName `json:"name,omitempty"` + Cols []*ColumnDef `json:"cols,omitempty"` + ReferTable *TableName `json:"refer_table,omitempty"` + Comment string `json:"comment"` + Inherits []*TableName `json:"inherits,omitempty"` // Using names the module of a virtual table (SQLite's CREATE VIRTUAL // TABLE ... USING module(...)), and ModuleArgs carries the module's // argument list as written — its grammar belongs to the module, so the @@ -16,18 +18,18 @@ type CreateTableStmt struct { // argument list at all. Cols still holds the columns sqlc derives from // the arguments for the catalog; the statement prints as its // declaration, not as those columns. - Using string - ModuleArgs []string + Using string `json:"using"` + ModuleArgs []string `json:"module_args,omitempty"` // ModuleArgsMultiline records that the declaration was written across // lines. The arguments carry no positions, so the printer cannot keep // the author's exact breaks and prints the canonical broken form — one // argument per line — instead. - ModuleArgsMultiline bool + ModuleArgsMultiline bool `json:"module_args_multiline"` // Incomplete marks a statement whose source carried syntax this node // does not model — column or table constraints beyond plain NOT NULL // and PRIMARY KEY, table options, TEMP, or an AS SELECT body. No // faithful rendering exists for it. - Incomplete bool + Incomplete bool `json:"incomplete"` } func (n *CreateTableStmt) Pos() int { diff --git a/internal/sql/ast/create_transform_stmt.go b/internal/sql/ast/create_transform_stmt.go index ef83e2c49a..20b0c633fc 100644 --- a/internal/sql/ast/create_transform_stmt.go +++ b/internal/sql/ast/create_transform_stmt.go @@ -1,11 +1,13 @@ package ast type CreateTransformStmt struct { - Replace bool - TypeName *TypeName - Lang *string - Fromsql *ObjectWithArgs - Tosql *ObjectWithArgs + Tag NodeTag[CreateTransformStmt] `json:"tag"` + + Replace bool `json:"replace"` + TypeName *TypeName `json:"type_name,omitempty"` + Lang *string `json:"lang,omitempty"` + Fromsql *ObjectWithArgs `json:"fromsql,omitempty"` + Tosql *ObjectWithArgs `json:"tosql,omitempty"` } func (n *CreateTransformStmt) Pos() int { diff --git a/internal/sql/ast/create_trig_stmt.go b/internal/sql/ast/create_trig_stmt.go index acecce084c..b0c81d6891 100644 --- a/internal/sql/ast/create_trig_stmt.go +++ b/internal/sql/ast/create_trig_stmt.go @@ -1,20 +1,22 @@ package ast type CreateTrigStmt struct { - Trigname *string - Relation *RangeVar - Funcname *List - Args *List - Row bool - Timing int16 - Events int16 - Columns *List - WhenClause Node - Isconstraint bool - TransitionRels *List - Deferrable bool - Initdeferred bool - Constrrel *RangeVar + Tag NodeTag[CreateTrigStmt] `json:"tag"` + + Trigname *string `json:"trigname,omitempty"` + Relation *RangeVar `json:"relation,omitempty"` + Funcname *List `json:"funcname,omitempty"` + Args *List `json:"args,omitempty"` + Row bool `json:"row"` + Timing int16 `json:"timing"` + Events int16 `json:"events"` + Columns *List `json:"columns,omitempty"` + WhenClause Node `json:"when_clause,omitempty"` + Isconstraint bool `json:"isconstraint"` + TransitionRels *List `json:"transition_rels,omitempty"` + Deferrable bool `json:"deferrable"` + Initdeferred bool `json:"initdeferred"` + Constrrel *RangeVar `json:"constrrel,omitempty"` } func (n *CreateTrigStmt) Pos() int { diff --git a/internal/sql/ast/create_user_mapping_stmt.go b/internal/sql/ast/create_user_mapping_stmt.go index f5fd41f76c..e67bd62302 100644 --- a/internal/sql/ast/create_user_mapping_stmt.go +++ b/internal/sql/ast/create_user_mapping_stmt.go @@ -1,10 +1,12 @@ package ast type CreateUserMappingStmt struct { - User *RoleSpec - Servername *string - IfNotExists bool - Options *List + Tag NodeTag[CreateUserMappingStmt] `json:"tag"` + + User *RoleSpec `json:"user,omitempty"` + Servername *string `json:"servername,omitempty"` + IfNotExists bool `json:"if_not_exists"` + Options *List `json:"options,omitempty"` } func (n *CreateUserMappingStmt) Pos() int { diff --git a/internal/sql/ast/createdb_stmt.go b/internal/sql/ast/createdb_stmt.go index 114505862d..ee08567a07 100644 --- a/internal/sql/ast/createdb_stmt.go +++ b/internal/sql/ast/createdb_stmt.go @@ -1,8 +1,10 @@ package ast type CreatedbStmt struct { - Dbname *string - Options *List + Tag NodeTag[CreatedbStmt] `json:"tag"` + + Dbname *string `json:"dbname,omitempty"` + Options *List `json:"options,omitempty"` } func (n *CreatedbStmt) Pos() int { diff --git a/internal/sql/ast/current_of_expr.go b/internal/sql/ast/current_of_expr.go index 88b457f8d2..ac9eb35b3f 100644 --- a/internal/sql/ast/current_of_expr.go +++ b/internal/sql/ast/current_of_expr.go @@ -1,10 +1,12 @@ package ast type CurrentOfExpr struct { - Xpr Node - Cvarno Index - CursorName *string - CursorParam int + Tag NodeTag[CurrentOfExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Cvarno Index `json:"cvarno"` + CursorName *string `json:"cursor_name,omitempty"` + CursorParam int `json:"cursor_param"` } func (n *CurrentOfExpr) Pos() int { diff --git a/internal/sql/ast/deallocate_stmt.go b/internal/sql/ast/deallocate_stmt.go index b11807b57b..c51908fb82 100644 --- a/internal/sql/ast/deallocate_stmt.go +++ b/internal/sql/ast/deallocate_stmt.go @@ -1,7 +1,9 @@ package ast type DeallocateStmt struct { - Name *string + Tag NodeTag[DeallocateStmt] `json:"tag"` + + Name *string `json:"name,omitempty"` } func (n *DeallocateStmt) Pos() int { diff --git a/internal/sql/ast/declare_cursor_stmt.go b/internal/sql/ast/declare_cursor_stmt.go index 82b0e6a2e0..52c8a226d5 100644 --- a/internal/sql/ast/declare_cursor_stmt.go +++ b/internal/sql/ast/declare_cursor_stmt.go @@ -1,9 +1,11 @@ package ast type DeclareCursorStmt struct { - Portalname *string - Options int - Query Node + Tag NodeTag[DeclareCursorStmt] `json:"tag"` + + Portalname *string `json:"portalname,omitempty"` + Options int `json:"options"` + Query Node `json:"query,omitempty"` } func (n *DeclareCursorStmt) Pos() int { diff --git a/internal/sql/ast/def_elem.go b/internal/sql/ast/def_elem.go index 33aacaaa03..9ccf44366a 100644 --- a/internal/sql/ast/def_elem.go +++ b/internal/sql/ast/def_elem.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type DefElem struct { - Defnamespace *string - Defname *string - Arg Node - Defaction DefElemAction - Location int + Tag NodeTag[DefElem] `json:"tag"` + + Defnamespace *string `json:"defnamespace,omitempty"` + Defname *string `json:"defname,omitempty"` + Arg Node `json:"arg,omitempty"` + Defaction DefElemAction `json:"defaction"` + Location int `json:"location"` } func (n *DefElem) Pos() int { diff --git a/internal/sql/ast/define_stmt.go b/internal/sql/ast/define_stmt.go index 3860183d7e..9ac5e7a1e8 100644 --- a/internal/sql/ast/define_stmt.go +++ b/internal/sql/ast/define_stmt.go @@ -1,12 +1,14 @@ package ast type DefineStmt struct { - Kind ObjectType - Oldstyle bool - Defnames *List - Args *List - Definition *List - IfNotExists bool + Tag NodeTag[DefineStmt] `json:"tag"` + + Kind ObjectType `json:"kind"` + Oldstyle bool `json:"oldstyle"` + Defnames *List `json:"defnames,omitempty"` + Args *List `json:"args,omitempty"` + Definition *List `json:"definition,omitempty"` + IfNotExists bool `json:"if_not_exists"` } func (n *DefineStmt) Pos() int { diff --git a/internal/sql/ast/delete_stmt.go b/internal/sql/ast/delete_stmt.go index 318713ad6c..5d584b6d0c 100644 --- a/internal/sql/ast/delete_stmt.go +++ b/internal/sql/ast/delete_stmt.go @@ -3,18 +3,20 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type DeleteStmt struct { - Relations *List - UsingClause *List - WhereClause Node - LimitCount Node - ReturningList *List - WithClause *WithClause + Tag NodeTag[DeleteStmt] `json:"tag"` + + Relations *List `json:"relations,omitempty"` + UsingClause *List `json:"using_clause,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + LimitCount Node `json:"limit_count,omitempty"` + ReturningList *List `json:"returning_list,omitempty"` + WithClause *WithClause `json:"with_clause,omitempty"` // MySQL multi-table DELETE support - Targets *List // Tables to delete from (e.g., jt.*, pt.*) - FromClause Node // FROM clause with JOINs (Node to support JoinExpr) + Targets *List `json:"targets,omitempty"` // Tables to delete from (e.g., jt.*, pt.*) + FromClause Node `json:"from_clause,omitempty"` // FROM clause with JOINs (Node to support JoinExpr) // PostgreSQL 18 RETURNING WITH (OLD AS ..., NEW AS ...) aliases - ReturningOldAlias string - ReturningNewAlias string + ReturningOldAlias string `json:"returning_old_alias"` + ReturningNewAlias string `json:"returning_new_alias"` } func (n *DeleteStmt) Pos() int { diff --git a/internal/sql/ast/discard_stmt.go b/internal/sql/ast/discard_stmt.go index 9c731df1fb..6831f7df81 100644 --- a/internal/sql/ast/discard_stmt.go +++ b/internal/sql/ast/discard_stmt.go @@ -1,7 +1,9 @@ package ast type DiscardStmt struct { - Target DiscardMode + Tag NodeTag[DiscardStmt] `json:"tag"` + + Target DiscardMode `json:"target"` } func (n *DiscardStmt) Pos() int { diff --git a/internal/sql/ast/do_stmt.go b/internal/sql/ast/do_stmt.go index 9becfb8e64..f21bafe8c5 100644 --- a/internal/sql/ast/do_stmt.go +++ b/internal/sql/ast/do_stmt.go @@ -3,7 +3,9 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type DoStmt struct { - Args *List + Tag NodeTag[DoStmt] `json:"tag"` + + Args *List `json:"args,omitempty"` } func (n *DoStmt) Pos() int { diff --git a/internal/sql/ast/drop_function_stmt.go b/internal/sql/ast/drop_function_stmt.go index c1b10b95c1..e5fec40469 100644 --- a/internal/sql/ast/drop_function_stmt.go +++ b/internal/sql/ast/drop_function_stmt.go @@ -1,8 +1,10 @@ package ast type DropFunctionStmt struct { - Funcs []*FuncSpec - MissingOk bool + Tag NodeTag[DropFunctionStmt] `json:"tag"` + + Funcs []*FuncSpec `json:"funcs,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *DropFunctionStmt) Pos() int { diff --git a/internal/sql/ast/drop_owned_stmt.go b/internal/sql/ast/drop_owned_stmt.go index 5826c33bbc..ab988187a0 100644 --- a/internal/sql/ast/drop_owned_stmt.go +++ b/internal/sql/ast/drop_owned_stmt.go @@ -1,8 +1,10 @@ package ast type DropOwnedStmt struct { - Roles *List - Behavior DropBehavior + Tag NodeTag[DropOwnedStmt] `json:"tag"` + + Roles *List `json:"roles,omitempty"` + Behavior DropBehavior `json:"behavior"` } func (n *DropOwnedStmt) Pos() int { diff --git a/internal/sql/ast/drop_role_stmt.go b/internal/sql/ast/drop_role_stmt.go index 95bd26a671..2bdcffd2ab 100644 --- a/internal/sql/ast/drop_role_stmt.go +++ b/internal/sql/ast/drop_role_stmt.go @@ -1,8 +1,10 @@ package ast type DropRoleStmt struct { - Roles *List - MissingOk bool + Tag NodeTag[DropRoleStmt] `json:"tag"` + + Roles *List `json:"roles,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *DropRoleStmt) Pos() int { diff --git a/internal/sql/ast/drop_schema_stmt.go b/internal/sql/ast/drop_schema_stmt.go index 8b7bad5180..f5d9f1e7ca 100644 --- a/internal/sql/ast/drop_schema_stmt.go +++ b/internal/sql/ast/drop_schema_stmt.go @@ -1,8 +1,10 @@ package ast type DropSchemaStmt struct { - Schemas []*String - MissingOk bool + Tag NodeTag[DropSchemaStmt] `json:"tag"` + + Schemas []*String `json:"schemas,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *DropSchemaStmt) Pos() int { diff --git a/internal/sql/ast/drop_stmt.go b/internal/sql/ast/drop_stmt.go index 9bb7d649a0..3305e16bf5 100644 --- a/internal/sql/ast/drop_stmt.go +++ b/internal/sql/ast/drop_stmt.go @@ -1,11 +1,13 @@ package ast type DropStmt struct { - Objects *List - RemoveType ObjectType - Behavior DropBehavior - MissingOk bool - Concurrent bool + Tag NodeTag[DropStmt] `json:"tag"` + + Objects *List `json:"objects,omitempty"` + RemoveType ObjectType `json:"remove_type"` + Behavior DropBehavior `json:"behavior"` + MissingOk bool `json:"missing_ok"` + Concurrent bool `json:"concurrent"` } func (n *DropStmt) Pos() int { diff --git a/internal/sql/ast/drop_subscription_stmt.go b/internal/sql/ast/drop_subscription_stmt.go index 7b8b025ac6..3fbd8528e4 100644 --- a/internal/sql/ast/drop_subscription_stmt.go +++ b/internal/sql/ast/drop_subscription_stmt.go @@ -1,9 +1,11 @@ package ast type DropSubscriptionStmt struct { - Subname *string - MissingOk bool - Behavior DropBehavior + Tag NodeTag[DropSubscriptionStmt] `json:"tag"` + + Subname *string `json:"subname,omitempty"` + MissingOk bool `json:"missing_ok"` + Behavior DropBehavior `json:"behavior"` } func (n *DropSubscriptionStmt) Pos() int { diff --git a/internal/sql/ast/drop_table_space_stmt.go b/internal/sql/ast/drop_table_space_stmt.go index bf96094d80..8093e7331c 100644 --- a/internal/sql/ast/drop_table_space_stmt.go +++ b/internal/sql/ast/drop_table_space_stmt.go @@ -1,8 +1,10 @@ package ast type DropTableSpaceStmt struct { - Tablespacename *string - MissingOk bool + Tag NodeTag[DropTableSpaceStmt] `json:"tag"` + + Tablespacename *string `json:"tablespacename,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *DropTableSpaceStmt) Pos() int { diff --git a/internal/sql/ast/drop_table_stmt.go b/internal/sql/ast/drop_table_stmt.go index 7485ceb887..4687b7cbe3 100644 --- a/internal/sql/ast/drop_table_stmt.go +++ b/internal/sql/ast/drop_table_stmt.go @@ -1,8 +1,10 @@ package ast type DropTableStmt struct { - IfExists bool - Tables []*TableName + Tag NodeTag[DropTableStmt] `json:"tag"` + + IfExists bool `json:"if_exists"` + Tables []*TableName `json:"tables,omitempty"` } func (n *DropTableStmt) Pos() int { diff --git a/internal/sql/ast/drop_type_stmt.go b/internal/sql/ast/drop_type_stmt.go index 3aa0401b19..dcef895f1b 100644 --- a/internal/sql/ast/drop_type_stmt.go +++ b/internal/sql/ast/drop_type_stmt.go @@ -1,8 +1,10 @@ package ast type DropTypeStmt struct { - IfExists bool - Types []*TypeName + Tag NodeTag[DropTypeStmt] `json:"tag"` + + IfExists bool `json:"if_exists"` + Types []*TypeName `json:"types,omitempty"` } func (n *DropTypeStmt) Pos() int { diff --git a/internal/sql/ast/drop_user_mapping_stmt.go b/internal/sql/ast/drop_user_mapping_stmt.go index f5852c708f..9503d8a259 100644 --- a/internal/sql/ast/drop_user_mapping_stmt.go +++ b/internal/sql/ast/drop_user_mapping_stmt.go @@ -1,9 +1,11 @@ package ast type DropUserMappingStmt struct { - User *RoleSpec - Servername *string - MissingOk bool + Tag NodeTag[DropUserMappingStmt] `json:"tag"` + + User *RoleSpec `json:"user,omitempty"` + Servername *string `json:"servername,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *DropUserMappingStmt) Pos() int { diff --git a/internal/sql/ast/dropdb_stmt.go b/internal/sql/ast/dropdb_stmt.go index 62a0c47346..da6eb860bb 100644 --- a/internal/sql/ast/dropdb_stmt.go +++ b/internal/sql/ast/dropdb_stmt.go @@ -1,8 +1,10 @@ package ast type DropdbStmt struct { - Dbname *string - MissingOk bool + Tag NodeTag[DropdbStmt] `json:"tag"` + + Dbname *string `json:"dbname,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *DropdbStmt) Pos() int { diff --git a/internal/sql/ast/execute_stmt.go b/internal/sql/ast/execute_stmt.go index 92a237141d..4ede4f42ca 100644 --- a/internal/sql/ast/execute_stmt.go +++ b/internal/sql/ast/execute_stmt.go @@ -1,8 +1,10 @@ package ast type ExecuteStmt struct { - Name *string - Params *List + Tag NodeTag[ExecuteStmt] `json:"tag"` + + Name *string `json:"name,omitempty"` + Params *List `json:"params,omitempty"` } func (n *ExecuteStmt) Pos() int { diff --git a/internal/sql/ast/explain_stmt.go b/internal/sql/ast/explain_stmt.go index 1d78aa815a..66c5608035 100644 --- a/internal/sql/ast/explain_stmt.go +++ b/internal/sql/ast/explain_stmt.go @@ -1,8 +1,10 @@ package ast type ExplainStmt struct { - Query Node - Options *List + Tag NodeTag[ExplainStmt] `json:"tag"` + + Query Node `json:"query,omitempty"` + Options *List `json:"options,omitempty"` } func (n *ExplainStmt) Pos() int { diff --git a/internal/sql/ast/expr.go b/internal/sql/ast/expr.go index a054970ccf..4de58b5214 100644 --- a/internal/sql/ast/expr.go +++ b/internal/sql/ast/expr.go @@ -1,6 +1,7 @@ package ast type Expr struct { + Tag NodeTag[Expr] `json:"tag"` } func (n *Expr) Pos() int { diff --git a/internal/sql/ast/fetch_stmt.go b/internal/sql/ast/fetch_stmt.go index cd43ef19ed..7a59569e37 100644 --- a/internal/sql/ast/fetch_stmt.go +++ b/internal/sql/ast/fetch_stmt.go @@ -1,10 +1,12 @@ package ast type FetchStmt struct { - Direction FetchDirection - HowMany int64 - Portalname *string - Ismove bool + Tag NodeTag[FetchStmt] `json:"tag"` + + Direction FetchDirection `json:"direction"` + HowMany int64 `json:"how_many"` + Portalname *string `json:"portalname,omitempty"` + Ismove bool `json:"ismove"` } func (n *FetchStmt) Pos() int { diff --git a/internal/sql/ast/field_select.go b/internal/sql/ast/field_select.go index 347abd44bf..57f77a6794 100644 --- a/internal/sql/ast/field_select.go +++ b/internal/sql/ast/field_select.go @@ -1,12 +1,14 @@ package ast type FieldSelect struct { - Xpr Node - Arg Node - Fieldnum AttrNumber - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid + Tag NodeTag[FieldSelect] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Fieldnum AttrNumber `json:"fieldnum"` + Resulttype Oid `json:"resulttype"` + Resulttypmod int32 `json:"resulttypmod"` + Resultcollid Oid `json:"resultcollid"` } func (n *FieldSelect) Pos() int { diff --git a/internal/sql/ast/field_store.go b/internal/sql/ast/field_store.go index 6c2cfc230c..505c924a9c 100644 --- a/internal/sql/ast/field_store.go +++ b/internal/sql/ast/field_store.go @@ -1,11 +1,13 @@ package ast type FieldStore struct { - Xpr Node - Arg Node - Newvals *List - Fieldnums *List - Resulttype Oid + Tag NodeTag[FieldStore] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Newvals *List `json:"newvals,omitempty"` + Fieldnums *List `json:"fieldnums,omitempty"` + Resulttype Oid `json:"resulttype"` } func (n *FieldStore) Pos() int { diff --git a/internal/sql/ast/float.go b/internal/sql/ast/float.go index 94e8c2652f..a91b89a273 100644 --- a/internal/sql/ast/float.go +++ b/internal/sql/ast/float.go @@ -3,7 +3,9 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type Float struct { - Str string + Tag NodeTag[Float] `json:"tag"` + + Str string `json:"str"` } func (n *Float) Pos() int { diff --git a/internal/sql/ast/from_expr.go b/internal/sql/ast/from_expr.go index deb93da4a4..021ac30cf8 100644 --- a/internal/sql/ast/from_expr.go +++ b/internal/sql/ast/from_expr.go @@ -1,8 +1,10 @@ package ast type FromExpr struct { - Fromlist *List - Quals Node + Tag NodeTag[FromExpr] `json:"tag"` + + Fromlist *List `json:"fromlist,omitempty"` + Quals Node `json:"quals,omitempty"` } func (n *FromExpr) Pos() int { diff --git a/internal/sql/ast/func_call.go b/internal/sql/ast/func_call.go index cb4f210fe4..f7e041f3cd 100644 --- a/internal/sql/ast/func_call.go +++ b/internal/sql/ast/func_call.go @@ -3,18 +3,20 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncCall struct { - Func *FuncName - Funcname *List - Args *List - AggOrder *List - AggFilter Node - AggWithinGroup bool - AggStar bool - AggDistinct bool - FuncVariadic bool - Over *WindowDef - Separator *string // MySQL GROUP_CONCAT SEPARATOR - Location int + Tag NodeTag[FuncCall] `json:"tag"` + + Func *FuncName `json:"func,omitempty"` + Funcname *List `json:"funcname,omitempty"` + Args *List `json:"args,omitempty"` + AggOrder *List `json:"agg_order,omitempty"` + AggFilter Node `json:"agg_filter,omitempty"` + AggWithinGroup bool `json:"agg_within_group"` + AggStar bool `json:"agg_star"` + AggDistinct bool `json:"agg_distinct"` + FuncVariadic bool `json:"func_variadic"` + Over *WindowDef `json:"over,omitempty"` + Separator *string `json:"separator,omitempty"` // MySQL GROUP_CONCAT SEPARATOR + Location int `json:"location"` } func (n *FuncCall) Pos() int { diff --git a/internal/sql/ast/func_expr.go b/internal/sql/ast/func_expr.go index e571a63049..39dee6f0ae 100644 --- a/internal/sql/ast/func_expr.go +++ b/internal/sql/ast/func_expr.go @@ -1,16 +1,18 @@ package ast type FuncExpr struct { - Xpr Node - Funcid Oid - Funcresulttype Oid - Funcretset bool - Funcvariadic bool - Funcformat CoercionForm - Funccollid Oid - Inputcollid Oid - Args *List - Location int + Tag NodeTag[FuncExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Funcid Oid `json:"funcid"` + Funcresulttype Oid `json:"funcresulttype"` + Funcretset bool `json:"funcretset"` + Funcvariadic bool `json:"funcvariadic"` + Funcformat CoercionForm `json:"funcformat"` + Funccollid Oid `json:"funccollid"` + Inputcollid Oid `json:"inputcollid"` + Args *List `json:"args,omitempty"` + Location int `json:"location"` } func (n *FuncExpr) Pos() int { diff --git a/internal/sql/ast/func_name.go b/internal/sql/ast/func_name.go index cdf3e23d33..0c1d6fb7a3 100644 --- a/internal/sql/ast/func_name.go +++ b/internal/sql/ast/func_name.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncName struct { - Catalog string - Schema string - Name string + Tag NodeTag[FuncName] `json:"tag"` + + Catalog string `json:"catalog"` + Schema string `json:"schema"` + Name string `json:"name"` } func (n *FuncName) Pos() int { diff --git a/internal/sql/ast/func_param.go b/internal/sql/ast/func_param.go index 5881a1441f..ae353f36d9 100644 --- a/internal/sql/ast/func_param.go +++ b/internal/sql/ast/func_param.go @@ -14,10 +14,12 @@ const ( ) type FuncParam struct { - Name *string - Type *TypeName - DefExpr Node // Will always be &ast.TODO - Mode FuncParamMode + Tag NodeTag[FuncParam] `json:"tag"` + + Name *string `json:"name,omitempty"` + Type *TypeName `json:"type,omitempty"` + DefExpr Node `json:"def_expr,omitempty"` // Will always be &ast.TODO + Mode FuncParamMode `json:"mode"` } func (n *FuncParam) Pos() int { diff --git a/internal/sql/ast/func_spec.go b/internal/sql/ast/func_spec.go index f9d4bb40c6..019bac9218 100644 --- a/internal/sql/ast/func_spec.go +++ b/internal/sql/ast/func_spec.go @@ -1,9 +1,11 @@ package ast type FuncSpec struct { - Name *FuncName - Args []*TypeName - HasArgs bool + Tag NodeTag[FuncSpec] `json:"tag"` + + Name *FuncName `json:"name,omitempty"` + Args []*TypeName `json:"args,omitempty"` + HasArgs bool `json:"has_args"` } func (n *FuncSpec) Pos() int { diff --git a/internal/sql/ast/function_parameter.go b/internal/sql/ast/function_parameter.go index 54262f6130..3bbb086713 100644 --- a/internal/sql/ast/function_parameter.go +++ b/internal/sql/ast/function_parameter.go @@ -1,10 +1,12 @@ package ast type FunctionParameter struct { - Name *string - ArgType *TypeName - Mode FunctionParameterMode - Defexpr Node + Tag NodeTag[FunctionParameter] `json:"tag"` + + Name *string `json:"name,omitempty"` + ArgType *TypeName `json:"arg_type,omitempty"` + Mode FunctionParameterMode `json:"mode"` + Defexpr Node `json:"defexpr,omitempty"` } func (n *FunctionParameter) Pos() int { diff --git a/internal/sql/ast/grant_role_stmt.go b/internal/sql/ast/grant_role_stmt.go index 5e0b2a8e87..0dd26f9cc3 100644 --- a/internal/sql/ast/grant_role_stmt.go +++ b/internal/sql/ast/grant_role_stmt.go @@ -1,11 +1,13 @@ package ast type GrantRoleStmt struct { - GrantedRoles *List - GranteeRoles *List - IsGrant bool - Grantor *RoleSpec - Behavior DropBehavior + Tag NodeTag[GrantRoleStmt] `json:"tag"` + + GrantedRoles *List `json:"granted_roles,omitempty"` + GranteeRoles *List `json:"grantee_roles,omitempty"` + IsGrant bool `json:"is_grant"` + Grantor *RoleSpec `json:"grantor,omitempty"` + Behavior DropBehavior `json:"behavior"` } func (n *GrantRoleStmt) Pos() int { diff --git a/internal/sql/ast/grant_stmt.go b/internal/sql/ast/grant_stmt.go index cbed7911ac..964395c146 100644 --- a/internal/sql/ast/grant_stmt.go +++ b/internal/sql/ast/grant_stmt.go @@ -1,14 +1,16 @@ package ast type GrantStmt struct { - IsGrant bool - Targtype GrantTargetType - Objtype GrantObjectType - Objects *List - Privileges *List - Grantees *List - GrantOption bool - Behavior DropBehavior + Tag NodeTag[GrantStmt] `json:"tag"` + + IsGrant bool `json:"is_grant"` + Targtype GrantTargetType `json:"targtype"` + Objtype GrantObjectType `json:"objtype"` + Objects *List `json:"objects,omitempty"` + Privileges *List `json:"privileges,omitempty"` + Grantees *List `json:"grantees,omitempty"` + GrantOption bool `json:"grant_option"` + Behavior DropBehavior `json:"behavior"` } func (n *GrantStmt) Pos() int { diff --git a/internal/sql/ast/grouping_func.go b/internal/sql/ast/grouping_func.go index 059bfb9dec..80f8471560 100644 --- a/internal/sql/ast/grouping_func.go +++ b/internal/sql/ast/grouping_func.go @@ -1,12 +1,14 @@ package ast type GroupingFunc struct { - Xpr Node - Args *List - Refs *List - Cols *List - Agglevelsup Index - Location int + Tag NodeTag[GroupingFunc] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Args *List `json:"args,omitempty"` + Refs *List `json:"refs,omitempty"` + Cols *List `json:"cols,omitempty"` + Agglevelsup Index `json:"agglevelsup"` + Location int `json:"location"` } func (n *GroupingFunc) Pos() int { diff --git a/internal/sql/ast/grouping_set.go b/internal/sql/ast/grouping_set.go index 32db38a607..10c5098f82 100644 --- a/internal/sql/ast/grouping_set.go +++ b/internal/sql/ast/grouping_set.go @@ -1,9 +1,11 @@ package ast type GroupingSet struct { - Kind GroupingSetKind - Content *List - Location int + Tag NodeTag[GroupingSet] `json:"tag"` + + Kind GroupingSetKind `json:"kind"` + Content *List `json:"content,omitempty"` + Location int `json:"location"` } func (n *GroupingSet) Pos() int { diff --git a/internal/sql/ast/import_foreign_schema_stmt.go b/internal/sql/ast/import_foreign_schema_stmt.go index 6b333f665b..7d824bdbf3 100644 --- a/internal/sql/ast/import_foreign_schema_stmt.go +++ b/internal/sql/ast/import_foreign_schema_stmt.go @@ -1,12 +1,14 @@ package ast type ImportForeignSchemaStmt struct { - ServerName *string - RemoteSchema *string - LocalSchema *string - ListType ImportForeignSchemaType - TableList *List - Options *List + Tag NodeTag[ImportForeignSchemaStmt] `json:"tag"` + + ServerName *string `json:"server_name,omitempty"` + RemoteSchema *string `json:"remote_schema,omitempty"` + LocalSchema *string `json:"local_schema,omitempty"` + ListType ImportForeignSchemaType `json:"list_type"` + TableList *List `json:"table_list,omitempty"` + Options *List `json:"options,omitempty"` } func (n *ImportForeignSchemaStmt) Pos() int { diff --git a/internal/sql/ast/in.go b/internal/sql/ast/in.go index 9bdad67eeb..6afa9fcaf0 100644 --- a/internal/sql/ast/in.go +++ b/internal/sql/ast/in.go @@ -4,15 +4,17 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // In describes a 'select foo in (bar, baz)' type statement, though there are multiple important variants handled. type In struct { + Tag NodeTag[In] `json:"tag"` + // Expr is the value expression to be compared. - Expr Node + Expr Node `json:"expr,omitempty"` // List is the list expression in compare list. - List []Node + List []Node `json:"list,omitempty"` // Not is true, the expression is "not in". - Not bool + Not bool `json:"not"` // Sel is the subquery, may be rewritten to other type of expression. - Sel Node - Location int + Sel Node `json:"sel,omitempty"` + Location int `json:"location"` } // Pos returns the location. diff --git a/internal/sql/ast/index_elem.go b/internal/sql/ast/index_elem.go index acc2a7fc23..e49ea05c28 100644 --- a/internal/sql/ast/index_elem.go +++ b/internal/sql/ast/index_elem.go @@ -3,13 +3,15 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type IndexElem struct { - Name *string - Expr Node - Indexcolname *string - Collation *List - Opclass *List - Ordering SortByDir - NullsOrdering SortByNulls + Tag NodeTag[IndexElem] `json:"tag"` + + Name *string `json:"name,omitempty"` + Expr Node `json:"expr,omitempty"` + Indexcolname *string `json:"indexcolname,omitempty"` + Collation *List `json:"collation,omitempty"` + Opclass *List `json:"opclass,omitempty"` + Ordering SortByDir `json:"ordering"` + NullsOrdering SortByNulls `json:"nulls_ordering"` } func (n *IndexElem) Pos() int { diff --git a/internal/sql/ast/index_stmt.go b/internal/sql/ast/index_stmt.go index fe0f03593c..5eafbcb95f 100644 --- a/internal/sql/ast/index_stmt.go +++ b/internal/sql/ast/index_stmt.go @@ -1,24 +1,26 @@ package ast type IndexStmt struct { - Idxname *string - Relation *RangeVar - AccessMethod *string - TableSpace *string - IndexParams *List - Options *List - WhereClause Node - ExcludeOpNames *List - Idxcomment *string - IndexOid Oid - Unique bool - Primary bool - Isconstraint bool - Deferrable bool - Initdeferred bool - Transformed bool - Concurrent bool - IfNotExists bool + Tag NodeTag[IndexStmt] `json:"tag"` + + Idxname *string `json:"idxname,omitempty"` + Relation *RangeVar `json:"relation,omitempty"` + AccessMethod *string `json:"access_method,omitempty"` + TableSpace *string `json:"table_space,omitempty"` + IndexParams *List `json:"index_params,omitempty"` + Options *List `json:"options,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + ExcludeOpNames *List `json:"exclude_op_names,omitempty"` + Idxcomment *string `json:"idxcomment,omitempty"` + IndexOid Oid `json:"index_oid"` + Unique bool `json:"unique"` + Primary bool `json:"primary"` + Isconstraint bool `json:"isconstraint"` + Deferrable bool `json:"deferrable"` + Initdeferred bool `json:"initdeferred"` + Transformed bool `json:"transformed"` + Concurrent bool `json:"concurrent"` + IfNotExists bool `json:"if_not_exists"` } func (n *IndexStmt) Pos() int { diff --git a/internal/sql/ast/infer_clause.go b/internal/sql/ast/infer_clause.go index 6df0db4a86..f4dc4bc46d 100644 --- a/internal/sql/ast/infer_clause.go +++ b/internal/sql/ast/infer_clause.go @@ -3,10 +3,12 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type InferClause struct { - IndexElems *List - WhereClause Node - Conname *string - Location int + Tag NodeTag[InferClause] `json:"tag"` + + IndexElems *List `json:"index_elems,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + Conname *string `json:"conname,omitempty"` + Location int `json:"location"` } func (n *InferClause) Pos() int { diff --git a/internal/sql/ast/inference_elem.go b/internal/sql/ast/inference_elem.go index d7b4e091c2..be27eb88a8 100644 --- a/internal/sql/ast/inference_elem.go +++ b/internal/sql/ast/inference_elem.go @@ -1,10 +1,12 @@ package ast type InferenceElem struct { - Xpr Node - Expr Node - Infercollid Oid - Inferopclass Oid + Tag NodeTag[InferenceElem] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Expr Node `json:"expr,omitempty"` + Infercollid Oid `json:"infercollid"` + Inferopclass Oid `json:"inferopclass"` } func (n *InferenceElem) Pos() int { diff --git a/internal/sql/ast/inline_code_block.go b/internal/sql/ast/inline_code_block.go index 91aebcc2e8..6698334d1e 100644 --- a/internal/sql/ast/inline_code_block.go +++ b/internal/sql/ast/inline_code_block.go @@ -1,9 +1,11 @@ package ast type InlineCodeBlock struct { - SourceText *string - LangOid Oid - LangIsTrusted bool + Tag NodeTag[InlineCodeBlock] `json:"tag"` + + SourceText *string `json:"source_text,omitempty"` + LangOid Oid `json:"lang_oid"` + LangIsTrusted bool `json:"lang_is_trusted"` } func (n *InlineCodeBlock) Pos() int { diff --git a/internal/sql/ast/insert_stmt.go b/internal/sql/ast/insert_stmt.go index 6ba9988413..e6d3d3a190 100644 --- a/internal/sql/ast/insert_stmt.go +++ b/internal/sql/ast/insert_stmt.go @@ -3,18 +3,20 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type InsertStmt struct { - Relation *RangeVar - Cols *List - SelectStmt Node - OnConflictClause *OnConflictClause - OnDuplicateKeyUpdate *OnDuplicateKeyUpdate // MySQL-specific - ReturningList *List - WithClause *WithClause - Override OverridingKind - DefaultValues bool // SQLite-specific: INSERT INTO ... DEFAULT VALUES + Tag NodeTag[InsertStmt] `json:"tag"` + + Relation *RangeVar `json:"relation,omitempty"` + Cols *List `json:"cols,omitempty"` + SelectStmt Node `json:"select_stmt,omitempty"` + OnConflictClause *OnConflictClause `json:"on_conflict_clause,omitempty"` + OnDuplicateKeyUpdate *OnDuplicateKeyUpdate `json:"on_duplicate_key_update,omitempty"` // MySQL-specific + ReturningList *List `json:"returning_list,omitempty"` + WithClause *WithClause `json:"with_clause,omitempty"` + Override OverridingKind `json:"override"` + DefaultValues bool `json:"default_values"` // SQLite-specific: INSERT INTO ... DEFAULT VALUES // PostgreSQL 18 RETURNING WITH (OLD AS ..., NEW AS ...) aliases - ReturningOldAlias string - ReturningNewAlias string + ReturningOldAlias string `json:"returning_old_alias"` + ReturningNewAlias string `json:"returning_new_alias"` } func (n *InsertStmt) Pos() int { diff --git a/internal/sql/ast/integer.go b/internal/sql/ast/integer.go index c0c360f2f2..30c270572b 100644 --- a/internal/sql/ast/integer.go +++ b/internal/sql/ast/integer.go @@ -7,7 +7,9 @@ import ( ) type Integer struct { - Ival int64 + Tag NodeTag[Integer] `json:"tag"` + + Ival int64 `json:"ival"` } func (n *Integer) Pos() int { diff --git a/internal/sql/ast/interval_expr.go b/internal/sql/ast/interval_expr.go index dac73a0557..f89ceed80c 100644 --- a/internal/sql/ast/interval_expr.go +++ b/internal/sql/ast/interval_expr.go @@ -4,9 +4,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // IntervalExpr represents a MySQL INTERVAL expression like "INTERVAL 1 DAY" type IntervalExpr struct { - Value Node - Unit string - Location int + Tag NodeTag[IntervalExpr] `json:"tag"` + + Value Node `json:"value,omitempty"` + Unit string `json:"unit"` + Location int `json:"location"` } func (n *IntervalExpr) Pos() int { diff --git a/internal/sql/ast/into_clause.go b/internal/sql/ast/into_clause.go index e460b65ea0..1a74d37bf4 100644 --- a/internal/sql/ast/into_clause.go +++ b/internal/sql/ast/into_clause.go @@ -1,13 +1,15 @@ package ast type IntoClause struct { - Rel *RangeVar - ColNames *List - Options *List - OnCommit OnCommitAction - TableSpaceName *string - ViewQuery Node - SkipData bool + Tag NodeTag[IntoClause] `json:"tag"` + + Rel *RangeVar `json:"rel,omitempty"` + ColNames *List `json:"col_names,omitempty"` + Options *List `json:"options,omitempty"` + OnCommit OnCommitAction `json:"on_commit"` + TableSpaceName *string `json:"table_space_name,omitempty"` + ViewQuery Node `json:"view_query,omitempty"` + SkipData bool `json:"skip_data"` } func (n *IntoClause) Pos() int { diff --git a/internal/sql/ast/join_expr.go b/internal/sql/ast/join_expr.go index a6bd132d7c..59df9b3aee 100644 --- a/internal/sql/ast/join_expr.go +++ b/internal/sql/ast/join_expr.go @@ -3,14 +3,16 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type JoinExpr struct { - Jointype JoinType - IsNatural bool - Larg Node - Rarg Node - UsingClause *List - Quals Node - Alias *Alias - Rtindex int + Tag NodeTag[JoinExpr] `json:"tag"` + + Jointype JoinType `json:"jointype"` + IsNatural bool `json:"is_natural"` + Larg Node `json:"larg,omitempty"` + Rarg Node `json:"rarg,omitempty"` + UsingClause *List `json:"using_clause,omitempty"` + Quals Node `json:"quals,omitempty"` + Alias *Alias `json:"alias,omitempty"` + Rtindex int `json:"rtindex"` } func (n *JoinExpr) Pos() int { diff --git a/internal/sql/ast/list.go b/internal/sql/ast/list.go index 3bb9d90dcd..86a3fe00dc 100644 --- a/internal/sql/ast/list.go +++ b/internal/sql/ast/list.go @@ -3,7 +3,9 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type List struct { - Items []Node + Tag NodeTag[List] `json:"tag"` + + Items []Node `json:"items,omitempty"` } func (n *List) Pos() int { diff --git a/internal/sql/ast/listen_stmt.go b/internal/sql/ast/listen_stmt.go index 48c38419a8..3989225754 100644 --- a/internal/sql/ast/listen_stmt.go +++ b/internal/sql/ast/listen_stmt.go @@ -3,7 +3,9 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ListenStmt struct { - Conditionname *string + Tag NodeTag[ListenStmt] `json:"tag"` + + Conditionname *string `json:"conditionname,omitempty"` } func (n *ListenStmt) Pos() int { diff --git a/internal/sql/ast/load_stmt.go b/internal/sql/ast/load_stmt.go index 1a211fc11a..276f05a134 100644 --- a/internal/sql/ast/load_stmt.go +++ b/internal/sql/ast/load_stmt.go @@ -1,7 +1,9 @@ package ast type LoadStmt struct { - Filename *string + Tag NodeTag[LoadStmt] `json:"tag"` + + Filename *string `json:"filename,omitempty"` } func (n *LoadStmt) Pos() int { diff --git a/internal/sql/ast/lock_stmt.go b/internal/sql/ast/lock_stmt.go index 70ec64dce3..82f2481640 100644 --- a/internal/sql/ast/lock_stmt.go +++ b/internal/sql/ast/lock_stmt.go @@ -1,9 +1,11 @@ package ast type LockStmt struct { - Relations *List - Mode int - Nowait bool + Tag NodeTag[LockStmt] `json:"tag"` + + Relations *List `json:"relations,omitempty"` + Mode int `json:"mode"` + Nowait bool `json:"nowait"` } func (n *LockStmt) Pos() int { diff --git a/internal/sql/ast/locking_clause.go b/internal/sql/ast/locking_clause.go index 6202b4ae02..00a3848f03 100644 --- a/internal/sql/ast/locking_clause.go +++ b/internal/sql/ast/locking_clause.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type LockingClause struct { - LockedRels *List - Strength LockClauseStrength - WaitPolicy LockWaitPolicy + Tag NodeTag[LockingClause] `json:"tag"` + + LockedRels *List `json:"locked_rels,omitempty"` + Strength LockClauseStrength `json:"strength"` + WaitPolicy LockWaitPolicy `json:"wait_policy"` } func (n *LockingClause) Pos() int { diff --git a/internal/sql/ast/min_max_expr.go b/internal/sql/ast/min_max_expr.go index 8f0f7ea578..56da82aed1 100644 --- a/internal/sql/ast/min_max_expr.go +++ b/internal/sql/ast/min_max_expr.go @@ -1,13 +1,15 @@ package ast type MinMaxExpr struct { - Xpr Node - Minmaxtype Oid - Minmaxcollid Oid - Inputcollid Oid - Op MinMaxOp - Args *List - Location int + Tag NodeTag[MinMaxExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Minmaxtype Oid `json:"minmaxtype"` + Minmaxcollid Oid `json:"minmaxcollid"` + Inputcollid Oid `json:"inputcollid"` + Op MinMaxOp `json:"op"` + Args *List `json:"args,omitempty"` + Location int `json:"location"` } func (n *MinMaxExpr) Pos() int { diff --git a/internal/sql/ast/multi_assign_ref.go b/internal/sql/ast/multi_assign_ref.go index 94b783bcc1..c1a7e30fc6 100644 --- a/internal/sql/ast/multi_assign_ref.go +++ b/internal/sql/ast/multi_assign_ref.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type MultiAssignRef struct { - Source Node - Colno int - Ncolumns int + Tag NodeTag[MultiAssignRef] `json:"tag"` + + Source Node `json:"source,omitempty"` + Colno int `json:"colno"` + Ncolumns int `json:"ncolumns"` } func (n *MultiAssignRef) Pos() int { diff --git a/internal/sql/ast/named_arg_expr.go b/internal/sql/ast/named_arg_expr.go index a711fd2712..ec3d5a187e 100644 --- a/internal/sql/ast/named_arg_expr.go +++ b/internal/sql/ast/named_arg_expr.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type NamedArgExpr struct { - Xpr Node - Arg Node - Name *string - Argnumber int - Location int + Tag NodeTag[NamedArgExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Name *string `json:"name,omitempty"` + Argnumber int `json:"argnumber"` + Location int `json:"location"` } func (n *NamedArgExpr) Pos() int { diff --git a/internal/sql/ast/next_value_expr.go b/internal/sql/ast/next_value_expr.go index 050c090368..6832e40449 100644 --- a/internal/sql/ast/next_value_expr.go +++ b/internal/sql/ast/next_value_expr.go @@ -1,9 +1,11 @@ package ast type NextValueExpr struct { - Xpr Node - Seqid Oid - TypeId Oid + Tag NodeTag[NextValueExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Seqid Oid `json:"seqid"` + TypeId Oid `json:"type_id"` } func (n *NextValueExpr) Pos() int { diff --git a/internal/sql/ast/node_tag.go b/internal/sql/ast/node_tag.go new file mode 100644 index 0000000000..5b3f43b90a --- /dev/null +++ b/internal/sql/ast/node_tag.go @@ -0,0 +1,40 @@ +package ast + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// NodeTag names its containing node type in JSON. +// +// Node is an interface, so the JSON encoding of an AST would otherwise carry no +// record of which node a given object is. Nodes with no fields of their own +// (A_Star, Null, TODO) would all encode as "{}", and an empty List would be +// indistinguishable from them. Every node struct instead declares +// +// Tag NodeTag[T] `json:"tag"` +// +// as its first field, with T the node's own type. The field is zero-sized and +// its zero value is valid, so constructing nodes as struct literals is +// unaffected; encoding/json calls MarshalJSON on the field, and the type +// parameter carries the node's identity to it at compile time. +type NodeTag[T any] struct{} + +func (NodeTag[T]) MarshalJSON() ([]byte, error) { + return json.Marshal(reflect.TypeFor[T]().Name()) +} + +// UnmarshalJSON accepts only the containing node's own name, so a document +// decoded into the wrong node type is an error rather than a silently +// misfielded tree. +func (*NodeTag[T]) UnmarshalJSON(data []byte) error { + var name string + if err := json.Unmarshal(data, &name); err != nil { + return err + } + if want := reflect.TypeFor[T]().Name(); name != want { + return fmt.Errorf("node tagged %q decoded into %s", name, want) + } + return nil +} diff --git a/internal/sql/ast/notify_stmt.go b/internal/sql/ast/notify_stmt.go index abecb94360..1f2df47a9f 100644 --- a/internal/sql/ast/notify_stmt.go +++ b/internal/sql/ast/notify_stmt.go @@ -3,8 +3,10 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type NotifyStmt struct { - Conditionname *string - Payload *string + Tag NodeTag[NotifyStmt] `json:"tag"` + + Conditionname *string `json:"conditionname,omitempty"` + Payload *string `json:"payload,omitempty"` } func (n *NotifyStmt) Pos() int { diff --git a/internal/sql/ast/null.go b/internal/sql/ast/null.go index e3606e2d7f..4fbba22f15 100644 --- a/internal/sql/ast/null.go +++ b/internal/sql/ast/null.go @@ -3,6 +3,7 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type Null struct { + Tag NodeTag[Null] `json:"tag"` } func (n *Null) Pos() int { diff --git a/internal/sql/ast/null_test_expr.go b/internal/sql/ast/null_test_expr.go index 3436bff0a5..ed0d1fddaf 100644 --- a/internal/sql/ast/null_test_expr.go +++ b/internal/sql/ast/null_test_expr.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type NullTest struct { - Xpr Node - Arg Node - Nulltesttype NullTestType - Argisrow bool - Location int + Tag NodeTag[NullTest] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Nulltesttype NullTestType `json:"nulltesttype"` + Argisrow bool `json:"argisrow"` + Location int `json:"location"` } func (n *NullTest) Pos() int { diff --git a/internal/sql/ast/object_with_args.go b/internal/sql/ast/object_with_args.go index 5b5a1a8bd9..05b0a0ce07 100644 --- a/internal/sql/ast/object_with_args.go +++ b/internal/sql/ast/object_with_args.go @@ -1,9 +1,11 @@ package ast type ObjectWithArgs struct { - Objname *List - Objargs *List - ArgsUnspecified bool + Tag NodeTag[ObjectWithArgs] `json:"tag"` + + Objname *List `json:"objname,omitempty"` + Objargs *List `json:"objargs,omitempty"` + ArgsUnspecified bool `json:"args_unspecified"` } func (n *ObjectWithArgs) Pos() int { diff --git a/internal/sql/ast/on_conflict_clause.go b/internal/sql/ast/on_conflict_clause.go index 7e04c7ff52..bbf01d6a82 100644 --- a/internal/sql/ast/on_conflict_clause.go +++ b/internal/sql/ast/on_conflict_clause.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type OnConflictClause struct { - Action OnConflictAction - Infer *InferClause - TargetList *List - WhereClause Node - Location int + Tag NodeTag[OnConflictClause] `json:"tag"` + + Action OnConflictAction `json:"action"` + Infer *InferClause `json:"infer,omitempty"` + TargetList *List `json:"target_list,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + Location int `json:"location"` } func (n *OnConflictClause) Pos() int { diff --git a/internal/sql/ast/on_conflict_expr.go b/internal/sql/ast/on_conflict_expr.go index ae9659c754..5bd559e1c8 100644 --- a/internal/sql/ast/on_conflict_expr.go +++ b/internal/sql/ast/on_conflict_expr.go @@ -1,14 +1,16 @@ package ast type OnConflictExpr struct { - Action OnConflictAction - ArbiterElems *List - ArbiterWhere Node - Constraint Oid - OnConflictSet *List - OnConflictWhere Node - ExclRelIndex int - ExclRelTlist *List + Tag NodeTag[OnConflictExpr] `json:"tag"` + + Action OnConflictAction `json:"action"` + ArbiterElems *List `json:"arbiter_elems,omitempty"` + ArbiterWhere Node `json:"arbiter_where,omitempty"` + Constraint Oid `json:"constraint"` + OnConflictSet *List `json:"on_conflict_set,omitempty"` + OnConflictWhere Node `json:"on_conflict_where,omitempty"` + ExclRelIndex int `json:"excl_rel_index"` + ExclRelTlist *List `json:"excl_rel_tlist,omitempty"` } func (n *OnConflictExpr) Pos() int { diff --git a/internal/sql/ast/on_duplicate_key_update.go b/internal/sql/ast/on_duplicate_key_update.go index a11ce1ab18..bc1dbf4d13 100644 --- a/internal/sql/ast/on_duplicate_key_update.go +++ b/internal/sql/ast/on_duplicate_key_update.go @@ -4,9 +4,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // OnDuplicateKeyUpdate represents MySQL's ON DUPLICATE KEY UPDATE clause type OnDuplicateKeyUpdate struct { + Tag NodeTag[OnDuplicateKeyUpdate] `json:"tag"` + // TargetList contains the assignments (column = value pairs) - TargetList *List - Location int + TargetList *List `json:"target_list,omitempty"` + Location int `json:"location"` } func (n *OnDuplicateKeyUpdate) Pos() int { diff --git a/internal/sql/ast/op_expr.go b/internal/sql/ast/op_expr.go index 0c7c21726e..0d81af54ab 100644 --- a/internal/sql/ast/op_expr.go +++ b/internal/sql/ast/op_expr.go @@ -1,14 +1,16 @@ package ast type OpExpr struct { - Xpr Node - Opno Oid - Opresulttype Oid - Opretset bool - Opcollid Oid - Inputcollid Oid - Args *List - Location int + Tag NodeTag[OpExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Opno Oid `json:"opno"` + Opresulttype Oid `json:"opresulttype"` + Opretset bool `json:"opretset"` + Opcollid Oid `json:"opcollid"` + Inputcollid Oid `json:"inputcollid"` + Args *List `json:"args,omitempty"` + Location int `json:"location"` } func (n *OpExpr) Pos() int { diff --git a/internal/sql/ast/param.go b/internal/sql/ast/param.go index 33220800bb..d9121de50e 100644 --- a/internal/sql/ast/param.go +++ b/internal/sql/ast/param.go @@ -1,13 +1,15 @@ package ast type Param struct { - Xpr Node - Paramkind ParamKind - Paramid int - Paramtype Oid - Paramtypmod int32 - Paramcollid Oid - Location int + Tag NodeTag[Param] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Paramkind ParamKind `json:"paramkind"` + Paramid int `json:"paramid"` + Paramtype Oid `json:"paramtype"` + Paramtypmod int32 `json:"paramtypmod"` + Paramcollid Oid `json:"paramcollid"` + Location int `json:"location"` } func (n *Param) Pos() int { diff --git a/internal/sql/ast/param_exec_data.go b/internal/sql/ast/param_exec_data.go index 0d8c3db9bf..6f151ea20a 100644 --- a/internal/sql/ast/param_exec_data.go +++ b/internal/sql/ast/param_exec_data.go @@ -1,9 +1,11 @@ package ast type ParamExecData struct { - ExecPlan any - Value Datum - Isnull bool + Tag NodeTag[ParamExecData] `json:"tag"` + + ExecPlan any `json:"exec_plan,omitempty"` + Value Datum `json:"value"` + Isnull bool `json:"isnull"` } func (n *ParamExecData) Pos() int { diff --git a/internal/sql/ast/param_extern_data.go b/internal/sql/ast/param_extern_data.go index a5d9bfcd49..4da009ff3f 100644 --- a/internal/sql/ast/param_extern_data.go +++ b/internal/sql/ast/param_extern_data.go @@ -1,10 +1,12 @@ package ast type ParamExternData struct { - Value Datum - Isnull bool - Pflags uint16 - Ptype Oid + Tag NodeTag[ParamExternData] `json:"tag"` + + Value Datum `json:"value"` + Isnull bool `json:"isnull"` + Pflags uint16 `json:"pflags"` + Ptype Oid `json:"ptype"` } func (n *ParamExternData) Pos() int { diff --git a/internal/sql/ast/param_list_info_data.go b/internal/sql/ast/param_list_info_data.go index a3fa0796e2..30e34d0bed 100644 --- a/internal/sql/ast/param_list_info_data.go +++ b/internal/sql/ast/param_list_info_data.go @@ -1,10 +1,12 @@ package ast type ParamListInfoData struct { - ParamFetchArg any - ParserSetupArg any - NumParams int - ParamMask []uint32 + Tag NodeTag[ParamListInfoData] `json:"tag"` + + ParamFetchArg any `json:"param_fetch_arg,omitempty"` + ParserSetupArg any `json:"parser_setup_arg,omitempty"` + NumParams int `json:"num_params"` + ParamMask []uint32 `json:"param_mask,omitempty"` } func (n *ParamListInfoData) Pos() int { diff --git a/internal/sql/ast/param_ref.go b/internal/sql/ast/param_ref.go index 02c98f3dfb..2b7ec5c527 100644 --- a/internal/sql/ast/param_ref.go +++ b/internal/sql/ast/param_ref.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ParamRef struct { - Number int - Location int - Dollar bool + Tag NodeTag[ParamRef] `json:"tag"` + + Number int `json:"number"` + Location int `json:"location"` + Dollar bool `json:"dollar"` } func (n *ParamRef) Pos() int { diff --git a/internal/sql/ast/paren_expr.go b/internal/sql/ast/paren_expr.go index 831d461f3e..79cb15b42b 100644 --- a/internal/sql/ast/paren_expr.go +++ b/internal/sql/ast/paren_expr.go @@ -4,8 +4,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // ParenExpr represents a parenthesized expression type ParenExpr struct { - Expr Node - Location int + Tag NodeTag[ParenExpr] `json:"tag"` + + Expr Node `json:"expr,omitempty"` + Location int `json:"location"` } func (n *ParenExpr) Pos() int { diff --git a/internal/sql/ast/partition_bound_spec.go b/internal/sql/ast/partition_bound_spec.go index fb4ada70af..6f45517835 100644 --- a/internal/sql/ast/partition_bound_spec.go +++ b/internal/sql/ast/partition_bound_spec.go @@ -1,11 +1,13 @@ package ast type PartitionBoundSpec struct { - Strategy byte - Listdatums *List - Lowerdatums *List - Upperdatums *List - Location int + Tag NodeTag[PartitionBoundSpec] `json:"tag"` + + Strategy byte `json:"strategy"` + Listdatums *List `json:"listdatums,omitempty"` + Lowerdatums *List `json:"lowerdatums,omitempty"` + Upperdatums *List `json:"upperdatums,omitempty"` + Location int `json:"location"` } func (n *PartitionBoundSpec) Pos() int { diff --git a/internal/sql/ast/partition_cmd.go b/internal/sql/ast/partition_cmd.go index 2deb30e998..931b809172 100644 --- a/internal/sql/ast/partition_cmd.go +++ b/internal/sql/ast/partition_cmd.go @@ -1,8 +1,10 @@ package ast type PartitionCmd struct { - Name *RangeVar - Bound *PartitionBoundSpec + Tag NodeTag[PartitionCmd] `json:"tag"` + + Name *RangeVar `json:"name,omitempty"` + Bound *PartitionBoundSpec `json:"bound,omitempty"` } func (n *PartitionCmd) Pos() int { diff --git a/internal/sql/ast/partition_elem.go b/internal/sql/ast/partition_elem.go index b4be165d36..1fe38fccb2 100644 --- a/internal/sql/ast/partition_elem.go +++ b/internal/sql/ast/partition_elem.go @@ -1,11 +1,13 @@ package ast type PartitionElem struct { - Name *string - Expr Node - Collation *List - Opclass *List - Location int + Tag NodeTag[PartitionElem] `json:"tag"` + + Name *string `json:"name,omitempty"` + Expr Node `json:"expr,omitempty"` + Collation *List `json:"collation,omitempty"` + Opclass *List `json:"opclass,omitempty"` + Location int `json:"location"` } func (n *PartitionElem) Pos() int { diff --git a/internal/sql/ast/partition_range_datum.go b/internal/sql/ast/partition_range_datum.go index 312437dd32..d827ced496 100644 --- a/internal/sql/ast/partition_range_datum.go +++ b/internal/sql/ast/partition_range_datum.go @@ -1,9 +1,11 @@ package ast type PartitionRangeDatum struct { - Kind PartitionRangeDatumKind - Value Node - Location int + Tag NodeTag[PartitionRangeDatum] `json:"tag"` + + Kind PartitionRangeDatumKind `json:"kind"` + Value Node `json:"value,omitempty"` + Location int `json:"location"` } func (n *PartitionRangeDatum) Pos() int { diff --git a/internal/sql/ast/partition_spec.go b/internal/sql/ast/partition_spec.go index 2918119e68..1d0b17400d 100644 --- a/internal/sql/ast/partition_spec.go +++ b/internal/sql/ast/partition_spec.go @@ -1,9 +1,11 @@ package ast type PartitionSpec struct { - Strategy *string - PartParams *List - Location int + Tag NodeTag[PartitionSpec] `json:"tag"` + + Strategy *string `json:"strategy,omitempty"` + PartParams *List `json:"part_params,omitempty"` + Location int `json:"location"` } func (n *PartitionSpec) Pos() int { diff --git a/internal/sql/ast/prepare_stmt.go b/internal/sql/ast/prepare_stmt.go index a088ac29b1..a31633d1c8 100644 --- a/internal/sql/ast/prepare_stmt.go +++ b/internal/sql/ast/prepare_stmt.go @@ -1,9 +1,11 @@ package ast type PrepareStmt struct { - Name *string - Argtypes *List - Query Node + Tag NodeTag[PrepareStmt] `json:"tag"` + + Name *string `json:"name,omitempty"` + Argtypes *List `json:"argtypes,omitempty"` + Query Node `json:"query,omitempty"` } func (n *PrepareStmt) Pos() int { diff --git a/internal/sql/ast/query.go b/internal/sql/ast/query.go index db25dfeb5d..7ace8aa9d9 100644 --- a/internal/sql/ast/query.go +++ b/internal/sql/ast/query.go @@ -1,42 +1,44 @@ package ast type Query struct { - CommandType CmdType - QuerySource QuerySource - QueryId uint32 - CanSetTag bool - UtilityStmt Node - ResultRelation int - HasAggs bool - HasWindowFuncs bool - HasTargetSrfs bool - HasSubLinks bool - HasDistinctOn bool - HasRecursive bool - HasModifyingCte bool - HasForUpdate bool - HasRowSecurity bool - CteList *List - Rtable *List - Jointree *FromExpr - TargetList *List - Override OverridingKind - OnConflict *OnConflictExpr - ReturningList *List - GroupClause *List - GroupingSets *List - HavingQual Node - WindowClause *List - DistinctClause *List - SortClause *List - LimitOffset Node - LimitCount Node - RowMarks *List - SetOperations Node - ConstraintDeps *List - WithCheckOptions *List - StmtLocation int - StmtLen int + Tag NodeTag[Query] `json:"tag"` + + CommandType CmdType `json:"command_type"` + QuerySource QuerySource `json:"query_source"` + QueryId uint32 `json:"query_id"` + CanSetTag bool `json:"can_set_tag"` + UtilityStmt Node `json:"utility_stmt,omitempty"` + ResultRelation int `json:"result_relation"` + HasAggs bool `json:"has_aggs"` + HasWindowFuncs bool `json:"has_window_funcs"` + HasTargetSrfs bool `json:"has_target_srfs"` + HasSubLinks bool `json:"has_sub_links"` + HasDistinctOn bool `json:"has_distinct_on"` + HasRecursive bool `json:"has_recursive"` + HasModifyingCte bool `json:"has_modifying_cte"` + HasForUpdate bool `json:"has_for_update"` + HasRowSecurity bool `json:"has_row_security"` + CteList *List `json:"cte_list,omitempty"` + Rtable *List `json:"rtable,omitempty"` + Jointree *FromExpr `json:"jointree,omitempty"` + TargetList *List `json:"target_list,omitempty"` + Override OverridingKind `json:"override"` + OnConflict *OnConflictExpr `json:"on_conflict,omitempty"` + ReturningList *List `json:"returning_list,omitempty"` + GroupClause *List `json:"group_clause,omitempty"` + GroupingSets *List `json:"grouping_sets,omitempty"` + HavingQual Node `json:"having_qual,omitempty"` + WindowClause *List `json:"window_clause,omitempty"` + DistinctClause *List `json:"distinct_clause,omitempty"` + SortClause *List `json:"sort_clause,omitempty"` + LimitOffset Node `json:"limit_offset,omitempty"` + LimitCount Node `json:"limit_count,omitempty"` + RowMarks *List `json:"row_marks,omitempty"` + SetOperations Node `json:"set_operations,omitempty"` + ConstraintDeps *List `json:"constraint_deps,omitempty"` + WithCheckOptions *List `json:"with_check_options,omitempty"` + StmtLocation int `json:"stmt_location"` + StmtLen int `json:"stmt_len"` } func (n *Query) Pos() int { diff --git a/internal/sql/ast/range_function.go b/internal/sql/ast/range_function.go index dca63595d8..3d1b6d0c30 100644 --- a/internal/sql/ast/range_function.go +++ b/internal/sql/ast/range_function.go @@ -3,12 +3,14 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeFunction struct { - Lateral bool - Ordinality bool - IsRowsfrom bool - Functions *List - Alias *Alias - Coldeflist *List + Tag NodeTag[RangeFunction] `json:"tag"` + + Lateral bool `json:"lateral"` + Ordinality bool `json:"ordinality"` + IsRowsfrom bool `json:"is_rowsfrom"` + Functions *List `json:"functions,omitempty"` + Alias *Alias `json:"alias,omitempty"` + Coldeflist *List `json:"coldeflist,omitempty"` } func (n *RangeFunction) Pos() int { diff --git a/internal/sql/ast/range_subselect.go b/internal/sql/ast/range_subselect.go index 51a8825e2b..8f2efe9b1e 100644 --- a/internal/sql/ast/range_subselect.go +++ b/internal/sql/ast/range_subselect.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeSubselect struct { - Lateral bool - Subquery Node - Alias *Alias + Tag NodeTag[RangeSubselect] `json:"tag"` + + Lateral bool `json:"lateral"` + Subquery Node `json:"subquery,omitempty"` + Alias *Alias `json:"alias,omitempty"` } func (n *RangeSubselect) Pos() int { diff --git a/internal/sql/ast/range_table_func.go b/internal/sql/ast/range_table_func.go index e53992edab..7758339c96 100644 --- a/internal/sql/ast/range_table_func.go +++ b/internal/sql/ast/range_table_func.go @@ -1,13 +1,15 @@ package ast type RangeTableFunc struct { - Lateral bool - Docexpr Node - Rowexpr Node - Namespaces *List - Columns *List - Alias *Alias - Location int + Tag NodeTag[RangeTableFunc] `json:"tag"` + + Lateral bool `json:"lateral"` + Docexpr Node `json:"docexpr,omitempty"` + Rowexpr Node `json:"rowexpr,omitempty"` + Namespaces *List `json:"namespaces,omitempty"` + Columns *List `json:"columns,omitempty"` + Alias *Alias `json:"alias,omitempty"` + Location int `json:"location"` } func (n *RangeTableFunc) Pos() int { diff --git a/internal/sql/ast/range_table_func_col.go b/internal/sql/ast/range_table_func_col.go index 2c06db1c08..d3fc620f3b 100644 --- a/internal/sql/ast/range_table_func_col.go +++ b/internal/sql/ast/range_table_func_col.go @@ -1,13 +1,15 @@ package ast type RangeTableFuncCol struct { - Colname *string - TypeName *TypeName - ForOrdinality bool - IsNotNull bool - Colexpr Node - Coldefexpr Node - Location int + Tag NodeTag[RangeTableFuncCol] `json:"tag"` + + Colname *string `json:"colname,omitempty"` + TypeName *TypeName `json:"type_name,omitempty"` + ForOrdinality bool `json:"for_ordinality"` + IsNotNull bool `json:"is_not_null"` + Colexpr Node `json:"colexpr,omitempty"` + Coldefexpr Node `json:"coldefexpr,omitempty"` + Location int `json:"location"` } func (n *RangeTableFuncCol) Pos() int { diff --git a/internal/sql/ast/range_table_sample.go b/internal/sql/ast/range_table_sample.go index c5fa2a2880..cf4c41f5b8 100644 --- a/internal/sql/ast/range_table_sample.go +++ b/internal/sql/ast/range_table_sample.go @@ -1,11 +1,13 @@ package ast type RangeTableSample struct { - Relation Node - Method *List - Args *List - Repeatable Node - Location int + Tag NodeTag[RangeTableSample] `json:"tag"` + + Relation Node `json:"relation,omitempty"` + Method *List `json:"method,omitempty"` + Args *List `json:"args,omitempty"` + Repeatable Node `json:"repeatable,omitempty"` + Location int `json:"location"` } func (n *RangeTableSample) Pos() int { diff --git a/internal/sql/ast/range_tbl_entry.go b/internal/sql/ast/range_tbl_entry.go index be40e619b4..e3dbf2b39f 100644 --- a/internal/sql/ast/range_tbl_entry.go +++ b/internal/sql/ast/range_tbl_entry.go @@ -1,37 +1,39 @@ package ast type RangeTblEntry struct { - Rtekind RTEKind - Relid Oid - Relkind byte - Tablesample *TableSampleClause - Subquery *Query - SecurityBarrier bool - Jointype JoinType - Joinaliasvars *List - Functions *List - Funcordinality bool - Tablefunc *TableFunc - ValuesLists *List - Ctename *string - Ctelevelsup Index - SelfReference bool - Coltypes *List - Coltypmods *List - Colcollations *List - Enrname *string - Enrtuples float64 - Alias *Alias - Eref *Alias - Lateral bool - Inh bool - InFromCl bool - RequiredPerms AclMode - CheckAsUser Oid - SelectedCols []uint32 - InsertedCols []uint32 - UpdatedCols []uint32 - SecurityQuals *List + Tag NodeTag[RangeTblEntry] `json:"tag"` + + Rtekind RTEKind `json:"rtekind"` + Relid Oid `json:"relid"` + Relkind byte `json:"relkind"` + Tablesample *TableSampleClause `json:"tablesample,omitempty"` + Subquery *Query `json:"subquery,omitempty"` + SecurityBarrier bool `json:"security_barrier"` + Jointype JoinType `json:"jointype"` + Joinaliasvars *List `json:"joinaliasvars,omitempty"` + Functions *List `json:"functions,omitempty"` + Funcordinality bool `json:"funcordinality"` + Tablefunc *TableFunc `json:"tablefunc,omitempty"` + ValuesLists *List `json:"values_lists,omitempty"` + Ctename *string `json:"ctename,omitempty"` + Ctelevelsup Index `json:"ctelevelsup"` + SelfReference bool `json:"self_reference"` + Coltypes *List `json:"coltypes,omitempty"` + Coltypmods *List `json:"coltypmods,omitempty"` + Colcollations *List `json:"colcollations,omitempty"` + Enrname *string `json:"enrname,omitempty"` + Enrtuples float64 `json:"enrtuples"` + Alias *Alias `json:"alias,omitempty"` + Eref *Alias `json:"eref,omitempty"` + Lateral bool `json:"lateral"` + Inh bool `json:"inh"` + InFromCl bool `json:"in_from_cl"` + RequiredPerms AclMode `json:"required_perms"` + CheckAsUser Oid `json:"check_as_user"` + SelectedCols []uint32 `json:"selected_cols,omitempty"` + InsertedCols []uint32 `json:"inserted_cols,omitempty"` + UpdatedCols []uint32 `json:"updated_cols,omitempty"` + SecurityQuals *List `json:"security_quals,omitempty"` } func (n *RangeTblEntry) Pos() int { diff --git a/internal/sql/ast/range_tbl_function.go b/internal/sql/ast/range_tbl_function.go index ee0e609f74..c4f54e1d55 100644 --- a/internal/sql/ast/range_tbl_function.go +++ b/internal/sql/ast/range_tbl_function.go @@ -1,13 +1,15 @@ package ast type RangeTblFunction struct { - Funcexpr Node - Funccolcount int - Funccolnames *List - Funccoltypes *List - Funccoltypmods *List - Funccolcollations *List - Funcparams []uint32 + Tag NodeTag[RangeTblFunction] `json:"tag"` + + Funcexpr Node `json:"funcexpr,omitempty"` + Funccolcount int `json:"funccolcount"` + Funccolnames *List `json:"funccolnames,omitempty"` + Funccoltypes *List `json:"funccoltypes,omitempty"` + Funccoltypmods *List `json:"funccoltypmods,omitempty"` + Funccolcollations *List `json:"funccolcollations,omitempty"` + Funcparams []uint32 `json:"funcparams,omitempty"` } func (n *RangeTblFunction) Pos() int { diff --git a/internal/sql/ast/range_tbl_ref.go b/internal/sql/ast/range_tbl_ref.go index de537568de..e3e1cc2a22 100644 --- a/internal/sql/ast/range_tbl_ref.go +++ b/internal/sql/ast/range_tbl_ref.go @@ -1,7 +1,9 @@ package ast type RangeTblRef struct { - Rtindex int + Tag NodeTag[RangeTblRef] `json:"tag"` + + Rtindex int `json:"rtindex"` } func (n *RangeTblRef) Pos() int { diff --git a/internal/sql/ast/range_var.go b/internal/sql/ast/range_var.go index 250b2b3bbf..ce70c97114 100644 --- a/internal/sql/ast/range_var.go +++ b/internal/sql/ast/range_var.go @@ -3,13 +3,15 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeVar struct { - Catalogname *string - Schemaname *string - Relname *string - Inh bool - Relpersistence byte - Alias *Alias - Location int + Tag NodeTag[RangeVar] `json:"tag"` + + Catalogname *string `json:"catalogname,omitempty"` + Schemaname *string `json:"schemaname,omitempty"` + Relname *string `json:"relname,omitempty"` + Inh bool `json:"inh"` + Relpersistence byte `json:"relpersistence"` + Alias *Alias `json:"alias,omitempty"` + Location int `json:"location"` } func (n *RangeVar) Pos() int { diff --git a/internal/sql/ast/raw_stmt.go b/internal/sql/ast/raw_stmt.go index 619b844244..73e50d508e 100644 --- a/internal/sql/ast/raw_stmt.go +++ b/internal/sql/ast/raw_stmt.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RawStmt struct { - Stmt Node - StmtLocation int - StmtLen int + Tag NodeTag[RawStmt] `json:"tag"` + + Stmt Node `json:"stmt,omitempty"` + StmtLocation int `json:"stmt_location"` + StmtLen int `json:"stmt_len"` } func (n *RawStmt) Pos() int { diff --git a/internal/sql/ast/reassign_owned_stmt.go b/internal/sql/ast/reassign_owned_stmt.go index 9162131f46..d062e7826c 100644 --- a/internal/sql/ast/reassign_owned_stmt.go +++ b/internal/sql/ast/reassign_owned_stmt.go @@ -1,8 +1,10 @@ package ast type ReassignOwnedStmt struct { - Roles *List - Newrole *RoleSpec + Tag NodeTag[ReassignOwnedStmt] `json:"tag"` + + Roles *List `json:"roles,omitempty"` + Newrole *RoleSpec `json:"newrole,omitempty"` } func (n *ReassignOwnedStmt) Pos() int { diff --git a/internal/sql/ast/refresh_mat_view_stmt.go b/internal/sql/ast/refresh_mat_view_stmt.go index f627e7bf21..d8c76e55f7 100644 --- a/internal/sql/ast/refresh_mat_view_stmt.go +++ b/internal/sql/ast/refresh_mat_view_stmt.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RefreshMatViewStmt struct { - Concurrent bool - SkipData bool - Relation *RangeVar + Tag NodeTag[RefreshMatViewStmt] `json:"tag"` + + Concurrent bool `json:"concurrent"` + SkipData bool `json:"skip_data"` + Relation *RangeVar `json:"relation,omitempty"` } func (n *RefreshMatViewStmt) Pos() int { diff --git a/internal/sql/ast/reindex_stmt.go b/internal/sql/ast/reindex_stmt.go index 9d33d490fe..7261134655 100644 --- a/internal/sql/ast/reindex_stmt.go +++ b/internal/sql/ast/reindex_stmt.go @@ -1,10 +1,12 @@ package ast type ReindexStmt struct { - Kind ReindexObjectType - Relation *RangeVar - Name *string - Options int + Tag NodeTag[ReindexStmt] `json:"tag"` + + Kind ReindexObjectType `json:"kind"` + Relation *RangeVar `json:"relation,omitempty"` + Name *string `json:"name,omitempty"` + Options int `json:"options"` } func (n *ReindexStmt) Pos() int { diff --git a/internal/sql/ast/relabel_type.go b/internal/sql/ast/relabel_type.go index e30e93184e..efaf74250c 100644 --- a/internal/sql/ast/relabel_type.go +++ b/internal/sql/ast/relabel_type.go @@ -1,13 +1,15 @@ package ast type RelabelType struct { - Xpr Node - Arg Node - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid - Relabelformat CoercionForm - Location int + Tag NodeTag[RelabelType] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Arg Node `json:"arg,omitempty"` + Resulttype Oid `json:"resulttype"` + Resulttypmod int32 `json:"resulttypmod"` + Resultcollid Oid `json:"resultcollid"` + Relabelformat CoercionForm `json:"relabelformat"` + Location int `json:"location"` } func (n *RelabelType) Pos() int { diff --git a/internal/sql/ast/rename_column_stmt.go b/internal/sql/ast/rename_column_stmt.go index 498b89d6ef..e677ce4661 100644 --- a/internal/sql/ast/rename_column_stmt.go +++ b/internal/sql/ast/rename_column_stmt.go @@ -1,10 +1,12 @@ package ast type RenameColumnStmt struct { - Table *TableName - Col *ColumnRef - NewName *string - MissingOk bool + Tag NodeTag[RenameColumnStmt] `json:"tag"` + + Table *TableName `json:"table,omitempty"` + Col *ColumnRef `json:"col,omitempty"` + NewName *string `json:"new_name,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *RenameColumnStmt) Pos() int { diff --git a/internal/sql/ast/rename_stmt.go b/internal/sql/ast/rename_stmt.go index cb9c176324..47865132c8 100644 --- a/internal/sql/ast/rename_stmt.go +++ b/internal/sql/ast/rename_stmt.go @@ -1,14 +1,16 @@ package ast type RenameStmt struct { - RenameType ObjectType - RelationType ObjectType - Relation *RangeVar - Object Node - Subname *string - Newname *string - Behavior DropBehavior - MissingOk bool + Tag NodeTag[RenameStmt] `json:"tag"` + + RenameType ObjectType `json:"rename_type"` + RelationType ObjectType `json:"relation_type"` + Relation *RangeVar `json:"relation,omitempty"` + Object Node `json:"object,omitempty"` + Subname *string `json:"subname,omitempty"` + Newname *string `json:"newname,omitempty"` + Behavior DropBehavior `json:"behavior"` + MissingOk bool `json:"missing_ok"` } func (n *RenameStmt) Pos() int { diff --git a/internal/sql/ast/rename_table_stmt.go b/internal/sql/ast/rename_table_stmt.go index b879ddb0b7..a8473e0310 100644 --- a/internal/sql/ast/rename_table_stmt.go +++ b/internal/sql/ast/rename_table_stmt.go @@ -1,9 +1,11 @@ package ast type RenameTableStmt struct { - Table *TableName - NewName *string - MissingOk bool + Tag NodeTag[RenameTableStmt] `json:"tag"` + + Table *TableName `json:"table,omitempty"` + NewName *string `json:"new_name,omitempty"` + MissingOk bool `json:"missing_ok"` } func (n *RenameTableStmt) Pos() int { diff --git a/internal/sql/ast/rename_type_stmt.go b/internal/sql/ast/rename_type_stmt.go index 67472d02f2..fced204dc8 100644 --- a/internal/sql/ast/rename_type_stmt.go +++ b/internal/sql/ast/rename_type_stmt.go @@ -1,8 +1,10 @@ package ast type RenameTypeStmt struct { - Type *TypeName - NewName *string + Tag NodeTag[RenameTypeStmt] `json:"tag"` + + Type *TypeName `json:"type,omitempty"` + NewName *string `json:"new_name,omitempty"` } func (n *RenameTypeStmt) Pos() int { diff --git a/internal/sql/ast/replica_identity_stmt.go b/internal/sql/ast/replica_identity_stmt.go index 2d4291597b..abe08e05e4 100644 --- a/internal/sql/ast/replica_identity_stmt.go +++ b/internal/sql/ast/replica_identity_stmt.go @@ -1,8 +1,10 @@ package ast type ReplicaIdentityStmt struct { - IdentityType byte - Name *string + Tag NodeTag[ReplicaIdentityStmt] `json:"tag"` + + IdentityType byte `json:"identity_type"` + Name *string `json:"name,omitempty"` } func (n *ReplicaIdentityStmt) Pos() int { diff --git a/internal/sql/ast/res_target.go b/internal/sql/ast/res_target.go index dc34879942..58a7e1dac5 100644 --- a/internal/sql/ast/res_target.go +++ b/internal/sql/ast/res_target.go @@ -3,10 +3,12 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ResTarget struct { - Name *string - Indirection *List - Val Node - Location int + Tag NodeTag[ResTarget] `json:"tag"` + + Name *string `json:"name,omitempty"` + Indirection *List `json:"indirection,omitempty"` + Val Node `json:"val,omitempty"` + Location int `json:"location"` } func (n *ResTarget) Pos() int { diff --git a/internal/sql/ast/role_spec.go b/internal/sql/ast/role_spec.go index fba4cecf7d..154ddf3ce4 100644 --- a/internal/sql/ast/role_spec.go +++ b/internal/sql/ast/role_spec.go @@ -1,9 +1,11 @@ package ast type RoleSpec struct { - Roletype RoleSpecType - Rolename *string - Location int + Tag NodeTag[RoleSpec] `json:"tag"` + + Roletype RoleSpecType `json:"roletype"` + Rolename *string `json:"rolename,omitempty"` + Location int `json:"location"` } func (n *RoleSpec) Pos() int { diff --git a/internal/sql/ast/row_compare_expr.go b/internal/sql/ast/row_compare_expr.go index 884cc3420d..bbab320eda 100644 --- a/internal/sql/ast/row_compare_expr.go +++ b/internal/sql/ast/row_compare_expr.go @@ -1,13 +1,15 @@ package ast type RowCompareExpr struct { - Xpr Node - Rctype RowCompareType - Opnos *List - Opfamilies *List - Inputcollids *List - Largs *List - Rargs *List + Tag NodeTag[RowCompareExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Rctype RowCompareType `json:"rctype"` + Opnos *List `json:"opnos,omitempty"` + Opfamilies *List `json:"opfamilies,omitempty"` + Inputcollids *List `json:"inputcollids,omitempty"` + Largs *List `json:"largs,omitempty"` + Rargs *List `json:"rargs,omitempty"` } func (n *RowCompareExpr) Pos() int { diff --git a/internal/sql/ast/row_expr.go b/internal/sql/ast/row_expr.go index 0f8578355a..d898086da6 100644 --- a/internal/sql/ast/row_expr.go +++ b/internal/sql/ast/row_expr.go @@ -3,12 +3,14 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RowExpr struct { - Xpr Node - Args *List - RowTypeid Oid - RowFormat CoercionForm - Colnames *List - Location int + Tag NodeTag[RowExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Args *List `json:"args,omitempty"` + RowTypeid Oid `json:"row_typeid"` + RowFormat CoercionForm `json:"row_format"` + Colnames *List `json:"colnames,omitempty"` + Location int `json:"location"` } func (n *RowExpr) Pos() int { diff --git a/internal/sql/ast/row_mark_clause.go b/internal/sql/ast/row_mark_clause.go index 5f2f8fa2f2..121174e6ba 100644 --- a/internal/sql/ast/row_mark_clause.go +++ b/internal/sql/ast/row_mark_clause.go @@ -1,10 +1,12 @@ package ast type RowMarkClause struct { - Rti Index - Strength LockClauseStrength - WaitPolicy LockWaitPolicy - PushedDown bool + Tag NodeTag[RowMarkClause] `json:"tag"` + + Rti Index `json:"rti"` + Strength LockClauseStrength `json:"strength"` + WaitPolicy LockWaitPolicy `json:"wait_policy"` + PushedDown bool `json:"pushed_down"` } func (n *RowMarkClause) Pos() int { diff --git a/internal/sql/ast/rule_stmt.go b/internal/sql/ast/rule_stmt.go index 5ed05a8c5f..7821866d58 100644 --- a/internal/sql/ast/rule_stmt.go +++ b/internal/sql/ast/rule_stmt.go @@ -1,13 +1,15 @@ package ast type RuleStmt struct { - Relation *RangeVar - Rulename *string - WhereClause Node - Event CmdType - Instead bool - Actions *List - Replace bool + Tag NodeTag[RuleStmt] `json:"tag"` + + Relation *RangeVar `json:"relation,omitempty"` + Rulename *string `json:"rulename,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + Event CmdType `json:"event"` + Instead bool `json:"instead"` + Actions *List `json:"actions,omitempty"` + Replace bool `json:"replace"` } func (n *RuleStmt) Pos() int { diff --git a/internal/sql/ast/scalar_array_op_expr.go b/internal/sql/ast/scalar_array_op_expr.go index b4f36548b3..a427fd0e67 100644 --- a/internal/sql/ast/scalar_array_op_expr.go +++ b/internal/sql/ast/scalar_array_op_expr.go @@ -3,12 +3,14 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ScalarArrayOpExpr struct { - Xpr Node - Opno Oid - UseOr bool - Inputcollid Oid - Args *List - Location int + Tag NodeTag[ScalarArrayOpExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Opno Oid `json:"opno"` + UseOr bool `json:"use_or"` + Inputcollid Oid `json:"inputcollid"` + Args *List `json:"args,omitempty"` + Location int `json:"location"` } func (n *ScalarArrayOpExpr) Pos() int { diff --git a/internal/sql/ast/sec_label_stmt.go b/internal/sql/ast/sec_label_stmt.go index 608edb733f..3a00bee0c4 100644 --- a/internal/sql/ast/sec_label_stmt.go +++ b/internal/sql/ast/sec_label_stmt.go @@ -1,10 +1,12 @@ package ast type SecLabelStmt struct { - Objtype ObjectType - Object Node - Provider *string - Label *string + Tag NodeTag[SecLabelStmt] `json:"tag"` + + Objtype ObjectType `json:"objtype"` + Object Node `json:"object,omitempty"` + Provider *string `json:"provider,omitempty"` + Label *string `json:"label,omitempty"` } func (n *SecLabelStmt) Pos() int { diff --git a/internal/sql/ast/select_stmt.go b/internal/sql/ast/select_stmt.go index 226c110734..ad9e10f9a1 100644 --- a/internal/sql/ast/select_stmt.go +++ b/internal/sql/ast/select_stmt.go @@ -5,24 +5,26 @@ import ( ) type SelectStmt struct { - DistinctClause *List - IntoClause *IntoClause - TargetList *List - FromClause *List - WhereClause Node - GroupClause *List - HavingClause Node - WindowClause *List - ValuesLists *List - SortClause *List - LimitOffset Node - LimitCount Node - LockingClause *List - WithClause *WithClause - Op SetOperation - All bool - Larg *SelectStmt - Rarg *SelectStmt + Tag NodeTag[SelectStmt] `json:"tag"` + + DistinctClause *List `json:"distinct_clause,omitempty"` + IntoClause *IntoClause `json:"into_clause,omitempty"` + TargetList *List `json:"target_list,omitempty"` + FromClause *List `json:"from_clause,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + GroupClause *List `json:"group_clause,omitempty"` + HavingClause Node `json:"having_clause,omitempty"` + WindowClause *List `json:"window_clause,omitempty"` + ValuesLists *List `json:"values_lists,omitempty"` + SortClause *List `json:"sort_clause,omitempty"` + LimitOffset Node `json:"limit_offset,omitempty"` + LimitCount Node `json:"limit_count,omitempty"` + LockingClause *List `json:"locking_clause,omitempty"` + WithClause *WithClause `json:"with_clause,omitempty"` + Op SetOperation `json:"op"` + All bool `json:"all"` + Larg *SelectStmt `json:"larg,omitempty"` + Rarg *SelectStmt `json:"rarg,omitempty"` } func (n *SelectStmt) Pos() int { diff --git a/internal/sql/ast/set_operation_stmt.go b/internal/sql/ast/set_operation_stmt.go index 9ab1950d1b..975460facb 100644 --- a/internal/sql/ast/set_operation_stmt.go +++ b/internal/sql/ast/set_operation_stmt.go @@ -1,14 +1,16 @@ package ast type SetOperationStmt struct { - Op SetOperation - All bool - Larg Node - Rarg Node - ColTypes *List - ColTypmods *List - ColCollations *List - GroupClauses *List + Tag NodeTag[SetOperationStmt] `json:"tag"` + + Op SetOperation `json:"op"` + All bool `json:"all"` + Larg Node `json:"larg,omitempty"` + Rarg Node `json:"rarg,omitempty"` + ColTypes *List `json:"col_types,omitempty"` + ColTypmods *List `json:"col_typmods,omitempty"` + ColCollations *List `json:"col_collations,omitempty"` + GroupClauses *List `json:"group_clauses,omitempty"` } func (n *SetOperationStmt) Pos() int { diff --git a/internal/sql/ast/set_to_default.go b/internal/sql/ast/set_to_default.go index c127d3bc77..6ae1d066c4 100644 --- a/internal/sql/ast/set_to_default.go +++ b/internal/sql/ast/set_to_default.go @@ -1,11 +1,13 @@ package ast type SetToDefault struct { - Xpr Node - TypeId Oid - TypeMod int32 - Collation Oid - Location int + Tag NodeTag[SetToDefault] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + TypeId Oid `json:"type_id"` + TypeMod int32 `json:"type_mod"` + Collation Oid `json:"collation"` + Location int `json:"location"` } func (n *SetToDefault) Pos() int { diff --git a/internal/sql/ast/sort_by.go b/internal/sql/ast/sort_by.go index b8634b7d6d..f1e241cc54 100644 --- a/internal/sql/ast/sort_by.go +++ b/internal/sql/ast/sort_by.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type SortBy struct { - Node Node - SortbyDir SortByDir - SortbyNulls SortByNulls - UseOp *List - Location int + Tag NodeTag[SortBy] `json:"tag"` + + Node Node `json:"node,omitempty"` + SortbyDir SortByDir `json:"sortby_dir"` + SortbyNulls SortByNulls `json:"sortby_nulls"` + UseOp *List `json:"use_op,omitempty"` + Location int `json:"location"` } func (n *SortBy) Pos() int { diff --git a/internal/sql/ast/sort_group_clause.go b/internal/sql/ast/sort_group_clause.go index 775035d799..e28cc89a8b 100644 --- a/internal/sql/ast/sort_group_clause.go +++ b/internal/sql/ast/sort_group_clause.go @@ -1,11 +1,13 @@ package ast type SortGroupClause struct { - TleSortGroupRef Index - Eqop Oid - Sortop Oid - NullsFirst bool - Hashable bool + Tag NodeTag[SortGroupClause] `json:"tag"` + + TleSortGroupRef Index `json:"tle_sort_group_ref"` + Eqop Oid `json:"eqop"` + Sortop Oid `json:"sortop"` + NullsFirst bool `json:"nulls_first"` + Hashable bool `json:"hashable"` } func (n *SortGroupClause) Pos() int { diff --git a/internal/sql/ast/sql_value_function.go b/internal/sql/ast/sql_value_function.go index 31bd008245..4c9fd2b670 100644 --- a/internal/sql/ast/sql_value_function.go +++ b/internal/sql/ast/sql_value_function.go @@ -3,11 +3,13 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type SQLValueFunction struct { - Xpr Node - Op SQLValueFunctionOp - Type Oid - Typmod int32 - Location int + Tag NodeTag[SQLValueFunction] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Op SQLValueFunctionOp `json:"op"` + Type Oid `json:"type"` + Typmod int32 `json:"typmod"` + Location int `json:"location"` } func (n *SQLValueFunction) Pos() int { diff --git a/internal/sql/ast/statement.go b/internal/sql/ast/statement.go index 4d01d949ca..dff54d6fb8 100644 --- a/internal/sql/ast/statement.go +++ b/internal/sql/ast/statement.go @@ -1,7 +1,9 @@ package ast type Statement struct { - Raw *RawStmt + Tag NodeTag[Statement] `json:"tag"` + + Raw *RawStmt `json:"raw,omitempty"` } func (n *Statement) Pos() int { diff --git a/internal/sql/ast/string.go b/internal/sql/ast/string.go index d167ef4575..b2ebe3b211 100644 --- a/internal/sql/ast/string.go +++ b/internal/sql/ast/string.go @@ -3,7 +3,9 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type String struct { - Str string + Tag NodeTag[String] `json:"tag"` + + Str string `json:"str"` } func (n *String) Pos() int { diff --git a/internal/sql/ast/sub_link.go b/internal/sql/ast/sub_link.go index bfd3ded206..184f36c96f 100644 --- a/internal/sql/ast/sub_link.go +++ b/internal/sql/ast/sub_link.go @@ -16,13 +16,15 @@ const ( ) type SubLink struct { - Xpr Node - SubLinkType SubLinkType - SubLinkId int - Testexpr Node - OperName *List - Subselect Node - Location int + Tag NodeTag[SubLink] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + SubLinkType SubLinkType `json:"sub_link_type"` + SubLinkId int `json:"sub_link_id"` + Testexpr Node `json:"testexpr,omitempty"` + OperName *List `json:"oper_name,omitempty"` + Subselect Node `json:"subselect,omitempty"` + Location int `json:"location"` } func (n *SubLink) Pos() int { diff --git a/internal/sql/ast/sub_plan.go b/internal/sql/ast/sub_plan.go index 2443e86c98..50908c7134 100644 --- a/internal/sql/ast/sub_plan.go +++ b/internal/sql/ast/sub_plan.go @@ -1,23 +1,25 @@ package ast type SubPlan struct { - Xpr Node - SubLinkType SubLinkType - Testexpr Node - ParamIds *List - PlanId int - PlanName *string - FirstColType Oid - FirstColTypmod int32 - FirstColCollation Oid - UseHashTable bool - UnknownEqFalse bool - ParallelSafe bool - SetParam *List - ParParam *List - Args *List - StartupCost Cost - PerCallCost Cost + Tag NodeTag[SubPlan] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + SubLinkType SubLinkType `json:"sub_link_type"` + Testexpr Node `json:"testexpr,omitempty"` + ParamIds *List `json:"param_ids,omitempty"` + PlanId int `json:"plan_id"` + PlanName *string `json:"plan_name,omitempty"` + FirstColType Oid `json:"first_col_type"` + FirstColTypmod int32 `json:"first_col_typmod"` + FirstColCollation Oid `json:"first_col_collation"` + UseHashTable bool `json:"use_hash_table"` + UnknownEqFalse bool `json:"unknown_eq_false"` + ParallelSafe bool `json:"parallel_safe"` + SetParam *List `json:"set_param,omitempty"` + ParParam *List `json:"par_param,omitempty"` + Args *List `json:"args,omitempty"` + StartupCost Cost `json:"startup_cost"` + PerCallCost Cost `json:"per_call_cost"` } func (n *SubPlan) Pos() int { diff --git a/internal/sql/ast/table_func.go b/internal/sql/ast/table_func.go index 615ff82074..d2a22e365e 100644 --- a/internal/sql/ast/table_func.go +++ b/internal/sql/ast/table_func.go @@ -1,19 +1,21 @@ package ast type TableFunc struct { - NsUris *List - NsNames *List - Docexpr Node - Rowexpr Node - Colnames *List - Coltypes *List - Coltypmods *List - Colcollations *List - Colexprs *List - Coldefexprs *List - Notnulls []uint32 - Ordinalitycol int - Location int + Tag NodeTag[TableFunc] `json:"tag"` + + NsUris *List `json:"ns_uris,omitempty"` + NsNames *List `json:"ns_names,omitempty"` + Docexpr Node `json:"docexpr,omitempty"` + Rowexpr Node `json:"rowexpr,omitempty"` + Colnames *List `json:"colnames,omitempty"` + Coltypes *List `json:"coltypes,omitempty"` + Coltypmods *List `json:"coltypmods,omitempty"` + Colcollations *List `json:"colcollations,omitempty"` + Colexprs *List `json:"colexprs,omitempty"` + Coldefexprs *List `json:"coldefexprs,omitempty"` + Notnulls []uint32 `json:"notnulls,omitempty"` + Ordinalitycol int `json:"ordinalitycol"` + Location int `json:"location"` } func (n *TableFunc) Pos() int { diff --git a/internal/sql/ast/table_like_clause.go b/internal/sql/ast/table_like_clause.go index 338065f3a2..8a5af1d5e2 100644 --- a/internal/sql/ast/table_like_clause.go +++ b/internal/sql/ast/table_like_clause.go @@ -1,8 +1,10 @@ package ast type TableLikeClause struct { - Relation *RangeVar - Options uint32 + Tag NodeTag[TableLikeClause] `json:"tag"` + + Relation *RangeVar `json:"relation,omitempty"` + Options uint32 `json:"options"` } func (n *TableLikeClause) Pos() int { diff --git a/internal/sql/ast/table_name.go b/internal/sql/ast/table_name.go index 4f494a67e0..1dfe61fd4f 100644 --- a/internal/sql/ast/table_name.go +++ b/internal/sql/ast/table_name.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TableName struct { - Catalog string - Schema string - Name string + Tag NodeTag[TableName] `json:"tag"` + + Catalog string `json:"catalog"` + Schema string `json:"schema"` + Name string `json:"name"` } func (n *TableName) Pos() int { diff --git a/internal/sql/ast/table_sample_clause.go b/internal/sql/ast/table_sample_clause.go index b92f731430..c8d05779ea 100644 --- a/internal/sql/ast/table_sample_clause.go +++ b/internal/sql/ast/table_sample_clause.go @@ -1,9 +1,11 @@ package ast type TableSampleClause struct { - Tsmhandler Oid - Args *List - Repeatable Node + Tag NodeTag[TableSampleClause] `json:"tag"` + + Tsmhandler Oid `json:"tsmhandler"` + Args *List `json:"args,omitempty"` + Repeatable Node `json:"repeatable,omitempty"` } func (n *TableSampleClause) Pos() int { diff --git a/internal/sql/ast/target_entry.go b/internal/sql/ast/target_entry.go index c9f72184e8..eeb5a33d00 100644 --- a/internal/sql/ast/target_entry.go +++ b/internal/sql/ast/target_entry.go @@ -1,14 +1,16 @@ package ast type TargetEntry struct { - Xpr Node - Expr Node - Resno AttrNumber - Resname *string - Ressortgroupref Index - Resorigtbl Oid - Resorigcol AttrNumber - Resjunk bool + Tag NodeTag[TargetEntry] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Expr Node `json:"expr,omitempty"` + Resno AttrNumber `json:"resno"` + Resname *string `json:"resname,omitempty"` + Ressortgroupref Index `json:"ressortgroupref"` + Resorigtbl Oid `json:"resorigtbl"` + Resorigcol AttrNumber `json:"resorigcol"` + Resjunk bool `json:"resjunk"` } func (n *TargetEntry) Pos() int { diff --git a/internal/sql/ast/todo.go b/internal/sql/ast/todo.go index 88e05e1ccf..c9b9d054f1 100644 --- a/internal/sql/ast/todo.go +++ b/internal/sql/ast/todo.go @@ -1,6 +1,7 @@ package ast type TODO struct { + Tag NodeTag[TODO] `json:"tag"` } func (n *TODO) Pos() int { diff --git a/internal/sql/ast/transaction_stmt.go b/internal/sql/ast/transaction_stmt.go index a6bf4bdf83..60dbe32e0d 100644 --- a/internal/sql/ast/transaction_stmt.go +++ b/internal/sql/ast/transaction_stmt.go @@ -1,9 +1,11 @@ package ast type TransactionStmt struct { - Kind TransactionStmtKind - Options *List - Gid *string + Tag NodeTag[TransactionStmt] `json:"tag"` + + Kind TransactionStmtKind `json:"kind"` + Options *List `json:"options,omitempty"` + Gid *string `json:"gid,omitempty"` } func (n *TransactionStmt) Pos() int { diff --git a/internal/sql/ast/trigger_transition.go b/internal/sql/ast/trigger_transition.go index 376745067a..1d09a9547d 100644 --- a/internal/sql/ast/trigger_transition.go +++ b/internal/sql/ast/trigger_transition.go @@ -1,9 +1,11 @@ package ast type TriggerTransition struct { - Name *string - IsNew bool - IsTable bool + Tag NodeTag[TriggerTransition] `json:"tag"` + + Name *string `json:"name,omitempty"` + IsNew bool `json:"is_new"` + IsTable bool `json:"is_table"` } func (n *TriggerTransition) Pos() int { diff --git a/internal/sql/ast/truncate_stmt.go b/internal/sql/ast/truncate_stmt.go index 6636e9f9e8..9a7a21dee1 100644 --- a/internal/sql/ast/truncate_stmt.go +++ b/internal/sql/ast/truncate_stmt.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TruncateStmt struct { - Relations *List - RestartSeqs bool - Behavior DropBehavior + Tag NodeTag[TruncateStmt] `json:"tag"` + + Relations *List `json:"relations,omitempty"` + RestartSeqs bool `json:"restart_seqs"` + Behavior DropBehavior `json:"behavior"` } func (n *TruncateStmt) Pos() int { diff --git a/internal/sql/ast/type_cast.go b/internal/sql/ast/type_cast.go index fe5b321abf..56c8fbb55f 100644 --- a/internal/sql/ast/type_cast.go +++ b/internal/sql/ast/type_cast.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeCast struct { - Arg Node - TypeName *TypeName - Location int + Tag NodeTag[TypeCast] `json:"tag"` + + Arg Node `json:"arg,omitempty"` + TypeName *TypeName `json:"type_name,omitempty"` + Location int `json:"location"` } func (n *TypeCast) Pos() int { diff --git a/internal/sql/ast/type_name.go b/internal/sql/ast/type_name.go index 26ef4d6d2b..9a557707b8 100644 --- a/internal/sql/ast/type_name.go +++ b/internal/sql/ast/type_name.go @@ -3,24 +3,26 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeName struct { - Catalog string - Schema string - Name string + Tag NodeTag[TypeName] `json:"tag"` + + Catalog string `json:"catalog"` + Schema string `json:"schema"` + Name string `json:"name"` // Spelling is the type as the author wrote it, when that differs from // Name: SQLite folds the spaces out of multi-word type names ("VARYING // CHARACTER" resolves as "VARYINGCHARACTER" in the catalog), so the // formatter prints this back instead of the folded form. - Spelling string + Spelling string `json:"spelling"` // From pg.TypeName - Names *List - TypeOid Oid - Setof bool - PctType bool - Typmods *List - Typemod int32 - ArrayBounds *List - Location int + Names *List `json:"names,omitempty"` + TypeOid Oid `json:"type_oid"` + Setof bool `json:"setof"` + PctType bool `json:"pct_type"` + Typmods *List `json:"typmods,omitempty"` + Typemod int32 `json:"typemod"` + ArrayBounds *List `json:"array_bounds,omitempty"` + Location int `json:"location"` } func (n *TypeName) Pos() int { diff --git a/internal/sql/ast/unlisten_stmt.go b/internal/sql/ast/unlisten_stmt.go index ca74e055f8..8c57881ca4 100644 --- a/internal/sql/ast/unlisten_stmt.go +++ b/internal/sql/ast/unlisten_stmt.go @@ -1,7 +1,9 @@ package ast type UnlistenStmt struct { - Conditionname *string + Tag NodeTag[UnlistenStmt] `json:"tag"` + + Conditionname *string `json:"conditionname,omitempty"` } func (n *UnlistenStmt) Pos() int { diff --git a/internal/sql/ast/update_stmt.go b/internal/sql/ast/update_stmt.go index 55775a6624..dc154cfd35 100644 --- a/internal/sql/ast/update_stmt.go +++ b/internal/sql/ast/update_stmt.go @@ -7,16 +7,18 @@ import ( ) type UpdateStmt struct { - Relations *List - TargetList *List - WhereClause Node - FromClause *List - LimitCount Node - ReturningList *List - WithClause *WithClause + Tag NodeTag[UpdateStmt] `json:"tag"` + + Relations *List `json:"relations,omitempty"` + TargetList *List `json:"target_list,omitempty"` + WhereClause Node `json:"where_clause,omitempty"` + FromClause *List `json:"from_clause,omitempty"` + LimitCount Node `json:"limit_count,omitempty"` + ReturningList *List `json:"returning_list,omitempty"` + WithClause *WithClause `json:"with_clause,omitempty"` // PostgreSQL 18 RETURNING WITH (OLD AS ..., NEW AS ...) aliases - ReturningOldAlias string - ReturningNewAlias string + ReturningOldAlias string `json:"returning_old_alias"` + ReturningNewAlias string `json:"returning_new_alias"` } func (n *UpdateStmt) Pos() int { diff --git a/internal/sql/ast/vacuum_stmt.go b/internal/sql/ast/vacuum_stmt.go index 942fb762b2..c04ebc6662 100644 --- a/internal/sql/ast/vacuum_stmt.go +++ b/internal/sql/ast/vacuum_stmt.go @@ -1,9 +1,11 @@ package ast type VacuumStmt struct { - Options int - Relation *RangeVar - VaCols *List + Tag NodeTag[VacuumStmt] `json:"tag"` + + Options int `json:"options"` + Relation *RangeVar `json:"relation,omitempty"` + VaCols *List `json:"va_cols,omitempty"` } func (n *VacuumStmt) Pos() int { diff --git a/internal/sql/ast/var.go b/internal/sql/ast/var.go index 0d558180cb..97d707f999 100644 --- a/internal/sql/ast/var.go +++ b/internal/sql/ast/var.go @@ -1,16 +1,18 @@ package ast type Var struct { - Xpr Node - Varno Index - Varattno AttrNumber - Vartype Oid - Vartypmod int32 - Varcollid Oid - Varlevelsup Index - Varnoold Index - Varoattno AttrNumber - Location int + Tag NodeTag[Var] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Varno Index `json:"varno"` + Varattno AttrNumber `json:"varattno"` + Vartype Oid `json:"vartype"` + Vartypmod int32 `json:"vartypmod"` + Varcollid Oid `json:"varcollid"` + Varlevelsup Index `json:"varlevelsup"` + Varnoold Index `json:"varnoold"` + Varoattno AttrNumber `json:"varoattno"` + Location int `json:"location"` } func (n *Var) Pos() int { diff --git a/internal/sql/ast/variable_expr.go b/internal/sql/ast/variable_expr.go index 83223b482b..84026a1103 100644 --- a/internal/sql/ast/variable_expr.go +++ b/internal/sql/ast/variable_expr.go @@ -5,8 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // VariableExpr represents a MySQL user variable (e.g., @user_id) // This is distinct from sqlc's @param named parameter syntax. type VariableExpr struct { - Name string - Location int + Tag NodeTag[VariableExpr] `json:"tag"` + + Name string `json:"name"` + Location int `json:"location"` } func (n *VariableExpr) Pos() int { diff --git a/internal/sql/ast/variable_set_stmt.go b/internal/sql/ast/variable_set_stmt.go index 9307152293..74cf712b7f 100644 --- a/internal/sql/ast/variable_set_stmt.go +++ b/internal/sql/ast/variable_set_stmt.go @@ -1,10 +1,12 @@ package ast type VariableSetStmt struct { - Kind VariableSetKind - Name *string - Args *List - IsLocal bool + Tag NodeTag[VariableSetStmt] `json:"tag"` + + Kind VariableSetKind `json:"kind"` + Name *string `json:"name,omitempty"` + Args *List `json:"args,omitempty"` + IsLocal bool `json:"is_local"` } func (n *VariableSetStmt) Pos() int { diff --git a/internal/sql/ast/variable_show_stmt.go b/internal/sql/ast/variable_show_stmt.go index c1dc7e95ef..e697115229 100644 --- a/internal/sql/ast/variable_show_stmt.go +++ b/internal/sql/ast/variable_show_stmt.go @@ -1,7 +1,9 @@ package ast type VariableShowStmt struct { - Name *string + Tag NodeTag[VariableShowStmt] `json:"tag"` + + Name *string `json:"name,omitempty"` } func (n *VariableShowStmt) Pos() int { diff --git a/internal/sql/ast/view_stmt.go b/internal/sql/ast/view_stmt.go index be93733f72..ec99b66730 100644 --- a/internal/sql/ast/view_stmt.go +++ b/internal/sql/ast/view_stmt.go @@ -1,12 +1,14 @@ package ast type ViewStmt struct { - View *RangeVar - Aliases *List - Query Node - Replace bool - Options *List - WithCheckOption ViewCheckOption + Tag NodeTag[ViewStmt] `json:"tag"` + + View *RangeVar `json:"view,omitempty"` + Aliases *List `json:"aliases,omitempty"` + Query Node `json:"query,omitempty"` + Replace bool `json:"replace"` + Options *List `json:"options,omitempty"` + WithCheckOption ViewCheckOption `json:"with_check_option"` } func (n *ViewStmt) Pos() int { diff --git a/internal/sql/ast/window_clause.go b/internal/sql/ast/window_clause.go index 0a2f082f01..6f5a826c51 100644 --- a/internal/sql/ast/window_clause.go +++ b/internal/sql/ast/window_clause.go @@ -1,15 +1,17 @@ package ast type WindowClause struct { - Name *string - Refname *string - PartitionClause *List - OrderClause *List - FrameOptions int - StartOffset Node - EndOffset Node - Winref Index - CopiedOrder bool + Tag NodeTag[WindowClause] `json:"tag"` + + Name *string `json:"name,omitempty"` + Refname *string `json:"refname,omitempty"` + PartitionClause *List `json:"partition_clause,omitempty"` + OrderClause *List `json:"order_clause,omitempty"` + FrameOptions int `json:"frame_options"` + StartOffset Node `json:"start_offset,omitempty"` + EndOffset Node `json:"end_offset,omitempty"` + Winref Index `json:"winref"` + CopiedOrder bool `json:"copied_order"` } func (n *WindowClause) Pos() int { diff --git a/internal/sql/ast/window_def.go b/internal/sql/ast/window_def.go index caba3e643c..7a04800353 100644 --- a/internal/sql/ast/window_def.go +++ b/internal/sql/ast/window_def.go @@ -3,14 +3,16 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type WindowDef struct { - Name *string - Refname *string - PartitionClause *List - OrderClause *List - FrameOptions int - StartOffset Node - EndOffset Node - Location int + Tag NodeTag[WindowDef] `json:"tag"` + + Name *string `json:"name,omitempty"` + Refname *string `json:"refname,omitempty"` + PartitionClause *List `json:"partition_clause,omitempty"` + OrderClause *List `json:"order_clause,omitempty"` + FrameOptions int `json:"frame_options"` + StartOffset Node `json:"start_offset,omitempty"` + EndOffset Node `json:"end_offset,omitempty"` + Location int `json:"location"` } func (n *WindowDef) Pos() int { diff --git a/internal/sql/ast/window_func.go b/internal/sql/ast/window_func.go index eb0ba5c968..4202b48f79 100644 --- a/internal/sql/ast/window_func.go +++ b/internal/sql/ast/window_func.go @@ -1,17 +1,19 @@ package ast type WindowFunc struct { - Xpr Node - Winfnoid Oid - Wintype Oid - Wincollid Oid - Inputcollid Oid - Args *List - Aggfilter Node - Winref Index - Winstar bool - Winagg bool - Location int + Tag NodeTag[WindowFunc] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Winfnoid Oid `json:"winfnoid"` + Wintype Oid `json:"wintype"` + Wincollid Oid `json:"wincollid"` + Inputcollid Oid `json:"inputcollid"` + Args *List `json:"args,omitempty"` + Aggfilter Node `json:"aggfilter,omitempty"` + Winref Index `json:"winref"` + Winstar bool `json:"winstar"` + Winagg bool `json:"winagg"` + Location int `json:"location"` } func (n *WindowFunc) Pos() int { diff --git a/internal/sql/ast/with_check_option.go b/internal/sql/ast/with_check_option.go index b622db4753..416c92d0e7 100644 --- a/internal/sql/ast/with_check_option.go +++ b/internal/sql/ast/with_check_option.go @@ -1,11 +1,13 @@ package ast type WithCheckOption struct { - Kind WCOKind - Relname *string - Polname *string - Qual Node - Cascaded bool + Tag NodeTag[WithCheckOption] `json:"tag"` + + Kind WCOKind `json:"kind"` + Relname *string `json:"relname,omitempty"` + Polname *string `json:"polname,omitempty"` + Qual Node `json:"qual,omitempty"` + Cascaded bool `json:"cascaded"` } func (n *WithCheckOption) Pos() int { diff --git a/internal/sql/ast/with_clause.go b/internal/sql/ast/with_clause.go index a7d4b24903..0124661b59 100644 --- a/internal/sql/ast/with_clause.go +++ b/internal/sql/ast/with_clause.go @@ -3,9 +3,11 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type WithClause struct { - Ctes *List - Recursive bool - Location int + Tag NodeTag[WithClause] `json:"tag"` + + Ctes *List `json:"ctes,omitempty"` + Recursive bool `json:"recursive"` + Location int `json:"location"` } func (n *WithClause) Pos() int { diff --git a/internal/sql/ast/xml_expr.go b/internal/sql/ast/xml_expr.go index cbd82b3653..42497118a9 100644 --- a/internal/sql/ast/xml_expr.go +++ b/internal/sql/ast/xml_expr.go @@ -1,16 +1,18 @@ package ast type XmlExpr struct { - Xpr Node - Op XmlExprOp - Name *string - NamedArgs *List - ArgNames *List - Args *List - Xmloption XmlOptionType - Type Oid - Typmod int32 - Location int + Tag NodeTag[XmlExpr] `json:"tag"` + + Xpr Node `json:"xpr,omitempty"` + Op XmlExprOp `json:"op"` + Name *string `json:"name,omitempty"` + NamedArgs *List `json:"named_args,omitempty"` + ArgNames *List `json:"arg_names,omitempty"` + Args *List `json:"args,omitempty"` + Xmloption XmlOptionType `json:"xmloption"` + Type Oid `json:"type"` + Typmod int32 `json:"typmod"` + Location int `json:"location"` } func (n *XmlExpr) Pos() int { diff --git a/internal/sql/ast/xml_serialize.go b/internal/sql/ast/xml_serialize.go index 32e4cc476d..e514db5480 100644 --- a/internal/sql/ast/xml_serialize.go +++ b/internal/sql/ast/xml_serialize.go @@ -1,10 +1,12 @@ package ast type XmlSerialize struct { - Xmloption XmlOptionType - Expr Node - TypeName *TypeName - Location int + Tag NodeTag[XmlSerialize] `json:"tag"` + + Xmloption XmlOptionType `json:"xmloption"` + Expr Node `json:"expr,omitempty"` + TypeName *TypeName `json:"type_name,omitempty"` + Location int `json:"location"` } func (n *XmlSerialize) Pos() int {