From 8c814819c9dcfe01a9099ef6b8c2640b8cf1ef32 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Aug 2026 03:42:25 +0000 Subject: [PATCH 1/4] ast: tag every node with its type in JSON output Node is an interface, so the JSON that parse and analyze --ast print carried no record of which node a given object was. Nodes with no fields of their own all encoded as "{}": a star in a RETURNING clause was indistinguishable from an untranslated clause, and an empty List was indistinguishable from both. Every node struct now declares a zero-sized marker as its first field: Tag NodeTag[T] `json:"tag"` with T the node's own type. encoding/json calls MarshalJSON on the field, and the generic type parameter carries the node's identity to it at compile time, so plain json.Marshal of any node emits its type name with no custom encoder walking the tree. The zero value is valid, so the engines' struct literals are unchanged, and the field is zero-sized, so nodes cost the same memory. The field's UnmarshalJSON accepts only the containing node's name, making a document decoded into the wrong node type an error instead of a silently misfielded tree. A test checks that every node struct declares the field, that its type parameter names the containing struct (the one mistake the compiler cannot catch, since a copy-pasted NodeTag[OtherNode] compiles), and that no node declares a colliding second field. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01T9LCt1mwdY3mE14x3Zz5Vw --- docs/howto/analyze.md | 4 +- docs/howto/parse.md | 27 ++++++ .../analyze_ast/postgresql/stdout.txt | 35 ++++++- .../parse_basic/clickhouse/stdout.txt | 6 ++ .../testdata/parse_basic/duckdb/stdout.txt | 6 ++ .../testdata/parse_basic/googlesql/stdout.txt | 6 ++ .../testdata/parse_basic/mssql/stdout.txt | 6 ++ .../testdata/parse_basic/mysql/stdout.txt | 9 ++ .../parse_basic/postgresql/stdout.txt | 30 +++++- .../testdata/parse_basic/sqlite/stdout.txt | 10 ++ internal/sql/ast/a_array_expr.go | 2 + internal/sql/ast/a_const.go | 2 + internal/sql/ast/a_expr.go | 2 + internal/sql/ast/a_indices.go | 2 + internal/sql/ast/a_indirection.go | 2 + internal/sql/ast/a_star.go | 1 + internal/sql/ast/access_priv.go | 2 + internal/sql/ast/aggref.go | 2 + internal/sql/ast/alias.go | 2 + internal/sql/ast/alter_collation_stmt.go | 2 + internal/sql/ast/alter_database_set_stmt.go | 2 + internal/sql/ast/alter_database_stmt.go | 2 + .../sql/ast/alter_default_privileges_stmt.go | 2 + internal/sql/ast/alter_domain_stmt.go | 2 + internal/sql/ast/alter_enum_stmt.go | 2 + internal/sql/ast/alter_event_trig_stmt.go | 2 + .../sql/ast/alter_extension_contents_stmt.go | 2 + internal/sql/ast/alter_extension_stmt.go | 2 + internal/sql/ast/alter_fdw_stmt.go | 2 + internal/sql/ast/alter_foreign_server_stmt.go | 2 + internal/sql/ast/alter_function_stmt.go | 2 + internal/sql/ast/alter_object_depends_stmt.go | 2 + internal/sql/ast/alter_object_schema_stmt.go | 2 + internal/sql/ast/alter_op_family_stmt.go | 2 + internal/sql/ast/alter_operator_stmt.go | 2 + internal/sql/ast/alter_owner_stmt.go | 2 + internal/sql/ast/alter_policy_stmt.go | 2 + internal/sql/ast/alter_publication_stmt.go | 2 + internal/sql/ast/alter_role_set_stmt.go | 2 + internal/sql/ast/alter_role_stmt.go | 2 + internal/sql/ast/alter_seq_stmt.go | 2 + internal/sql/ast/alter_subscription_stmt.go | 2 + internal/sql/ast/alter_system_stmt.go | 2 + internal/sql/ast/alter_table_cmd.go | 2 + internal/sql/ast/alter_table_move_all_stmt.go | 2 + .../sql/ast/alter_table_set_schema_stmt.go | 2 + .../sql/ast/alter_table_space_options_stmt.go | 2 + internal/sql/ast/alter_table_stmt.go | 2 + .../sql/ast/alter_ts_configuration_stmt.go | 2 + internal/sql/ast/alter_ts_dictionary_stmt.go | 2 + internal/sql/ast/alter_type_add_value_stmt.go | 2 + .../sql/ast/alter_type_rename_value_stmt.go | 2 + .../sql/ast/alter_type_set_schema_stmt.go | 2 + internal/sql/ast/alter_user_mapping_stmt.go | 2 + internal/sql/ast/alternative_sub_plan.go | 2 + internal/sql/ast/array_coerce_expr.go | 2 + internal/sql/ast/array_expr.go | 2 + internal/sql/ast/array_ref.go | 2 + internal/sql/ast/between_expr.go | 2 + internal/sql/ast/bit_string.go | 2 + internal/sql/ast/block_id_data.go | 2 + internal/sql/ast/bool_expr.go | 2 + internal/sql/ast/boolean.go | 2 + internal/sql/ast/boolean_test_expr.go | 2 + internal/sql/ast/call_stmt.go | 2 + internal/sql/ast/case_expr.go | 2 + internal/sql/ast/case_test_expr.go | 2 + internal/sql/ast/case_when.go | 2 + internal/sql/ast/check_point_stmt.go | 1 + internal/sql/ast/close_portal_stmt.go | 2 + internal/sql/ast/cluster_stmt.go | 2 + internal/sql/ast/coalesce_expr.go | 2 + internal/sql/ast/coerce_to_domain.go | 2 + internal/sql/ast/coerce_to_domain_value.go | 2 + internal/sql/ast/coerce_via_io.go | 2 + internal/sql/ast/collate_clause.go | 2 + internal/sql/ast/collate_expr.go | 2 + internal/sql/ast/column_def.go | 2 + internal/sql/ast/column_ref.go | 2 + internal/sql/ast/comment_on_column_stmt.go | 2 + internal/sql/ast/comment_on_schema_stmt.go | 2 + internal/sql/ast/comment_on_table_stmt.go | 2 + internal/sql/ast/comment_on_type_stmt.go | 2 + internal/sql/ast/comment_on_view_stmt.go | 2 + internal/sql/ast/comment_stmt.go | 2 + internal/sql/ast/common_table_expr.go | 2 + internal/sql/ast/composite_type_stmt.go | 2 + internal/sql/ast/const.go | 2 + internal/sql/ast/constraint.go | 2 + internal/sql/ast/constraints_set_stmt.go | 2 + internal/sql/ast/convert_rowtype_expr.go | 2 + internal/sql/ast/copy_stmt.go | 2 + internal/sql/ast/create_am_stmt.go | 2 + internal/sql/ast/create_cast_stmt.go | 2 + internal/sql/ast/create_conversion_stmt.go | 2 + internal/sql/ast/create_domain_stmt.go | 2 + internal/sql/ast/create_enum_stmt.go | 2 + internal/sql/ast/create_event_trig_stmt.go | 2 + internal/sql/ast/create_extension_stmt.go | 2 + internal/sql/ast/create_fdw_stmt.go | 2 + .../sql/ast/create_foreign_server_stmt.go | 2 + internal/sql/ast/create_foreign_table_stmt.go | 2 + internal/sql/ast/create_function_stmt.go | 2 + internal/sql/ast/create_op_class_item.go | 2 + internal/sql/ast/create_op_class_stmt.go | 2 + internal/sql/ast/create_op_family_stmt.go | 2 + internal/sql/ast/create_p_lang_stmt.go | 2 + internal/sql/ast/create_policy_stmt.go | 2 + internal/sql/ast/create_publication_stmt.go | 2 + internal/sql/ast/create_range_stmt.go | 2 + internal/sql/ast/create_role_stmt.go | 2 + internal/sql/ast/create_schema_stmt.go | 2 + internal/sql/ast/create_seq_stmt.go | 2 + internal/sql/ast/create_stats_stmt.go | 2 + internal/sql/ast/create_stmt.go | 2 + internal/sql/ast/create_subscription_stmt.go | 2 + internal/sql/ast/create_table_as_stmt.go | 2 + internal/sql/ast/create_table_space_stmt.go | 2 + internal/sql/ast/create_table_stmt.go | 2 + internal/sql/ast/create_transform_stmt.go | 2 + internal/sql/ast/create_trig_stmt.go | 2 + internal/sql/ast/create_user_mapping_stmt.go | 2 + internal/sql/ast/createdb_stmt.go | 2 + internal/sql/ast/current_of_expr.go | 2 + internal/sql/ast/deallocate_stmt.go | 2 + internal/sql/ast/declare_cursor_stmt.go | 2 + internal/sql/ast/def_elem.go | 2 + internal/sql/ast/define_stmt.go | 2 + internal/sql/ast/delete_stmt.go | 2 + internal/sql/ast/discard_stmt.go | 2 + internal/sql/ast/do_stmt.go | 2 + internal/sql/ast/drop_function_stmt.go | 2 + internal/sql/ast/drop_owned_stmt.go | 2 + internal/sql/ast/drop_role_stmt.go | 2 + internal/sql/ast/drop_schema_stmt.go | 2 + internal/sql/ast/drop_stmt.go | 2 + internal/sql/ast/drop_subscription_stmt.go | 2 + internal/sql/ast/drop_table_space_stmt.go | 2 + internal/sql/ast/drop_table_stmt.go | 2 + internal/sql/ast/drop_type_stmt.go | 2 + internal/sql/ast/drop_user_mapping_stmt.go | 2 + internal/sql/ast/dropdb_stmt.go | 2 + internal/sql/ast/execute_stmt.go | 2 + internal/sql/ast/explain_stmt.go | 2 + internal/sql/ast/expr.go | 1 + internal/sql/ast/fetch_stmt.go | 2 + internal/sql/ast/field_select.go | 2 + internal/sql/ast/field_store.go | 2 + internal/sql/ast/float.go | 2 + internal/sql/ast/from_expr.go | 2 + internal/sql/ast/func_call.go | 2 + internal/sql/ast/func_expr.go | 2 + internal/sql/ast/func_name.go | 2 + internal/sql/ast/func_param.go | 2 + internal/sql/ast/func_spec.go | 2 + internal/sql/ast/function_parameter.go | 2 + internal/sql/ast/grant_role_stmt.go | 2 + internal/sql/ast/grant_stmt.go | 2 + internal/sql/ast/grouping_func.go | 2 + internal/sql/ast/grouping_set.go | 2 + .../sql/ast/import_foreign_schema_stmt.go | 2 + internal/sql/ast/in.go | 2 + internal/sql/ast/index_elem.go | 2 + internal/sql/ast/index_stmt.go | 2 + internal/sql/ast/infer_clause.go | 2 + internal/sql/ast/inference_elem.go | 2 + internal/sql/ast/inline_code_block.go | 2 + internal/sql/ast/insert_stmt.go | 2 + internal/sql/ast/integer.go | 2 + internal/sql/ast/interval_expr.go | 2 + internal/sql/ast/into_clause.go | 2 + internal/sql/ast/join_expr.go | 2 + internal/sql/ast/list.go | 2 + internal/sql/ast/listen_stmt.go | 2 + internal/sql/ast/load_stmt.go | 2 + internal/sql/ast/lock_stmt.go | 2 + internal/sql/ast/locking_clause.go | 2 + internal/sql/ast/min_max_expr.go | 2 + internal/sql/ast/multi_assign_ref.go | 2 + internal/sql/ast/named_arg_expr.go | 2 + internal/sql/ast/next_value_expr.go | 2 + internal/sql/ast/node_tag.go | 41 +++++++++ internal/sql/ast/node_tag_test.go | 92 +++++++++++++++++++ internal/sql/ast/notify_stmt.go | 2 + internal/sql/ast/null.go | 1 + internal/sql/ast/null_test_expr.go | 2 + internal/sql/ast/object_with_args.go | 2 + internal/sql/ast/on_conflict_clause.go | 2 + internal/sql/ast/on_conflict_expr.go | 2 + internal/sql/ast/on_duplicate_key_update.go | 2 + internal/sql/ast/op_expr.go | 2 + internal/sql/ast/param.go | 2 + internal/sql/ast/param_exec_data.go | 2 + internal/sql/ast/param_extern_data.go | 2 + internal/sql/ast/param_list_info_data.go | 2 + internal/sql/ast/param_ref.go | 2 + internal/sql/ast/paren_expr.go | 2 + internal/sql/ast/partition_bound_spec.go | 2 + internal/sql/ast/partition_cmd.go | 2 + internal/sql/ast/partition_elem.go | 2 + internal/sql/ast/partition_range_datum.go | 2 + internal/sql/ast/partition_spec.go | 2 + internal/sql/ast/prepare_stmt.go | 2 + internal/sql/ast/query.go | 2 + internal/sql/ast/range_function.go | 2 + internal/sql/ast/range_subselect.go | 2 + internal/sql/ast/range_table_func.go | 2 + internal/sql/ast/range_table_func_col.go | 2 + internal/sql/ast/range_table_sample.go | 2 + internal/sql/ast/range_tbl_entry.go | 2 + internal/sql/ast/range_tbl_function.go | 2 + internal/sql/ast/range_tbl_ref.go | 2 + internal/sql/ast/range_var.go | 2 + internal/sql/ast/raw_stmt.go | 2 + internal/sql/ast/reassign_owned_stmt.go | 2 + internal/sql/ast/refresh_mat_view_stmt.go | 2 + internal/sql/ast/reindex_stmt.go | 2 + internal/sql/ast/relabel_type.go | 2 + internal/sql/ast/rename_column_stmt.go | 2 + internal/sql/ast/rename_stmt.go | 2 + internal/sql/ast/rename_table_stmt.go | 2 + internal/sql/ast/rename_type_stmt.go | 2 + internal/sql/ast/replica_identity_stmt.go | 2 + internal/sql/ast/res_target.go | 2 + internal/sql/ast/role_spec.go | 2 + internal/sql/ast/row_compare_expr.go | 2 + internal/sql/ast/row_expr.go | 2 + internal/sql/ast/row_mark_clause.go | 2 + internal/sql/ast/rule_stmt.go | 2 + internal/sql/ast/scalar_array_op_expr.go | 2 + internal/sql/ast/sec_label_stmt.go | 2 + internal/sql/ast/select_stmt.go | 2 + internal/sql/ast/set_operation_stmt.go | 2 + internal/sql/ast/set_to_default.go | 2 + internal/sql/ast/sort_by.go | 2 + internal/sql/ast/sort_group_clause.go | 2 + internal/sql/ast/sql_value_function.go | 2 + internal/sql/ast/statement.go | 2 + internal/sql/ast/string.go | 2 + internal/sql/ast/sub_link.go | 2 + internal/sql/ast/sub_plan.go | 2 + internal/sql/ast/table_func.go | 2 + internal/sql/ast/table_like_clause.go | 2 + internal/sql/ast/table_name.go | 2 + internal/sql/ast/table_sample_clause.go | 2 + internal/sql/ast/target_entry.go | 2 + internal/sql/ast/todo.go | 1 + internal/sql/ast/transaction_stmt.go | 2 + internal/sql/ast/trigger_transition.go | 2 + internal/sql/ast/truncate_stmt.go | 2 + internal/sql/ast/type_cast.go | 2 + internal/sql/ast/type_name.go | 2 + internal/sql/ast/unlisten_stmt.go | 2 + internal/sql/ast/update_stmt.go | 2 + internal/sql/ast/vacuum_stmt.go | 2 + internal/sql/ast/var.go | 2 + internal/sql/ast/variable_expr.go | 2 + internal/sql/ast/variable_set_stmt.go | 2 + internal/sql/ast/variable_show_stmt.go | 2 + internal/sql/ast/view_stmt.go | 2 + internal/sql/ast/window_clause.go | 2 + internal/sql/ast/window_def.go | 2 + internal/sql/ast/window_func.go | 2 + internal/sql/ast/with_check_option.go | 2 + internal/sql/ast/with_clause.go | 2 + internal/sql/ast/xml_expr.go | 2 + internal/sql/ast/xml_serialize.go | 2 + 267 files changed, 769 insertions(+), 8 deletions(-) create mode 100644 internal/sql/ast/node_tag.go create mode 100644 internal/sql/ast/node_tag_test.go 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..816693be2e 100644 --- a/docs/howto/parse.md +++ b/docs/howto/parse.md @@ -48,6 +48,7 @@ The output is a JSON array with one object per statement: "name": "GetAuthor", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { "...": "..." }, @@ -60,3 +61,29 @@ The output is a JSON array with one object per statement: Statements without a `-- name:` annotation (for example schema DDL) omit the `name` and `cmd` fields. + +## 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. diff --git a/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt b/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt index b74264f687..eec934554f 100644 --- a/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt +++ b/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt @@ -24,23 +24,32 @@ } ], "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": { + "tag": "List", "Items": null }, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": { + "tag": "List", "Items": null }, "Val": { + "tag": "ColumnRef", "Name": "", "Fields": { + "tag": "List", "Items": [ { + "tag": "String", "Str": "name" } ] @@ -52,8 +61,10 @@ ] }, "FromClause": { + "tag": "List", "Items": [ { + "tag": "RangeVar", "Catalogname": null, "Schemaname": null, "Relname": "authors", @@ -65,19 +76,25 @@ ] }, "WhereClause": { + "tag": "A_Expr", "Kind": 1, "Name": { + "tag": "List", "Items": [ { + "tag": "String", "Str": "=" } ] }, "Lexpr": { + "tag": "ColumnRef", "Name": "", "Fields": { + "tag": "List", "Items": [ { + "tag": "String", "Str": "id" } ] @@ -85,6 +102,7 @@ "Location": 59 }, "Rexpr": { + "tag": "ParamRef", "Number": 1, "Location": 64, "Dollar": true @@ -92,21 +110,32 @@ "Location": 62 }, "GroupClause": { + "tag": "List", "Items": null }, - "HavingClause": {}, + "HavingClause": { + "tag": "TODO" + }, "WindowClause": { + "tag": "List", "Items": null }, "ValuesLists": { + "tag": "List", "Items": null }, "SortClause": { + "tag": "List", "Items": null }, - "LimitOffset": {}, - "LimitCount": {}, + "LimitOffset": { + "tag": "TODO" + }, + "LimitCount": { + "tag": "TODO" + }, "LockingClause": { + "tag": "List", "Items": null }, "WithClause": null, diff --git a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt index 28a5ce7e1f..02a280a4ff 100644 --- a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt @@ -3,16 +3,22 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": null, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": null, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 31 diff --git a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt index ca847e616a..f3a5c9edb6 100644 --- a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt @@ -3,16 +3,22 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": null, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": null, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 30 diff --git a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt index 086f885402..06f4a4deb9 100644 --- a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt @@ -3,16 +3,22 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": null, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": null, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 30 diff --git a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt index b20fbdcee5..e1cdbd9086 100644 --- a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt @@ -3,16 +3,22 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": null, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": null, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 30 diff --git a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt index e9ed28784f..580120ab58 100644 --- a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt @@ -3,16 +3,22 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": null, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": null, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 30 @@ -22,14 +28,17 @@ ] }, "FromClause": { + "tag": "List", "Items": null }, "WhereClause": null, "GroupClause": { + "tag": "List", "Items": null }, "HavingClause": null, "WindowClause": { + "tag": "List", "Items": [] }, "ValuesLists": null, diff --git a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt index fe35a664c7..1b3abb1ea6 100644 --- a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt @@ -3,20 +3,28 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": { + "tag": "List", "Items": null }, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": { + "tag": "List", "Items": null }, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 30 @@ -26,25 +34,39 @@ ] }, "FromClause": { + "tag": "List", "Items": null }, - "WhereClause": {}, + "WhereClause": { + "tag": "TODO" + }, "GroupClause": { + "tag": "List", "Items": null }, - "HavingClause": {}, + "HavingClause": { + "tag": "TODO" + }, "WindowClause": { + "tag": "List", "Items": null }, "ValuesLists": { + "tag": "List", "Items": null }, "SortClause": { + "tag": "List", "Items": null }, - "LimitOffset": {}, - "LimitCount": {}, + "LimitOffset": { + "tag": "TODO" + }, + "LimitCount": { + "tag": "TODO" + }, "LockingClause": { + "tag": "List", "Items": null }, "WithClause": null, diff --git a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt index c1303a9a1e..652d9bdaaf 100644 --- a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt @@ -3,16 +3,22 @@ "name": "GetValue", "cmd": ":one", "ast": { + "tag": "RawStmt", "Stmt": { + "tag": "SelectStmt", "DistinctClause": null, "IntoClause": null, "TargetList": { + "tag": "List", "Items": [ { + "tag": "ResTarget", "Name": null, "Indirection": null, "Val": { + "tag": "A_Const", "Val": { + "tag": "Integer", "Ival": 1 }, "Location": 30 @@ -22,17 +28,21 @@ ] }, "FromClause": { + "tag": "List", "Items": null }, "WhereClause": null, "GroupClause": { + "tag": "List", "Items": null }, "HavingClause": null, "WindowClause": { + "tag": "List", "Items": null }, "ValuesLists": { + "tag": "List", "Items": null }, "SortClause": null, diff --git a/internal/sql/ast/a_array_expr.go b/internal/sql/ast/a_array_expr.go index 0437dac84f..ffd1368586 100644 --- a/internal/sql/ast/a_array_expr.go +++ b/internal/sql/ast/a_array_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_ArrayExpr struct { + Tag NodeTag[A_ArrayExpr] `json:"tag"` + Elements *List Location int } diff --git a/internal/sql/ast/a_const.go b/internal/sql/ast/a_const.go index a6b610e349..aefb14f643 100644 --- a/internal/sql/ast/a_const.go +++ b/internal/sql/ast/a_const.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Const struct { + Tag NodeTag[A_Const] `json:"tag"` + Val Node Location int } diff --git a/internal/sql/ast/a_expr.go b/internal/sql/ast/a_expr.go index ea3242337c..2a1b55346b 100644 --- a/internal/sql/ast/a_expr.go +++ b/internal/sql/ast/a_expr.go @@ -7,6 +7,8 @@ import ( ) type A_Expr struct { + Tag NodeTag[A_Expr] `json:"tag"` + Kind A_Expr_Kind // Name is the operator, as a list of String nodes: PostgreSQL's // operator space is open (user-defined and schema-qualified operators), diff --git a/internal/sql/ast/a_indices.go b/internal/sql/ast/a_indices.go index 7180f220e7..492d9cb4d2 100644 --- a/internal/sql/ast/a_indices.go +++ b/internal/sql/ast/a_indices.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Indices struct { + Tag NodeTag[A_Indices] `json:"tag"` + IsSlice bool Lidx Node Uidx Node diff --git a/internal/sql/ast/a_indirection.go b/internal/sql/ast/a_indirection.go index b03b4621a9..7db4e5fc5e 100644 --- a/internal/sql/ast/a_indirection.go +++ b/internal/sql/ast/a_indirection.go @@ -1,6 +1,8 @@ package ast type A_Indirection struct { + Tag NodeTag[A_Indirection] `json:"tag"` + Arg Node Indirection *List } 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..6f351ba0eb 100644 --- a/internal/sql/ast/access_priv.go +++ b/internal/sql/ast/access_priv.go @@ -1,6 +1,8 @@ package ast type AccessPriv struct { + Tag NodeTag[AccessPriv] `json:"tag"` + PrivName *string Cols *List } diff --git a/internal/sql/ast/aggref.go b/internal/sql/ast/aggref.go index 6642f4d9e3..dd6e0adea9 100644 --- a/internal/sql/ast/aggref.go +++ b/internal/sql/ast/aggref.go @@ -1,6 +1,8 @@ package ast type Aggref struct { + Tag NodeTag[Aggref] `json:"tag"` + Xpr Node Aggfnoid Oid Aggtype Oid diff --git a/internal/sql/ast/alias.go b/internal/sql/ast/alias.go index 7123982305..15092097f1 100644 --- a/internal/sql/ast/alias.go +++ b/internal/sql/ast/alias.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type Alias struct { + Tag NodeTag[Alias] `json:"tag"` + Aliasname *string Colnames *List } diff --git a/internal/sql/ast/alter_collation_stmt.go b/internal/sql/ast/alter_collation_stmt.go index fa78ed7bf1..dec0e4cf68 100644 --- a/internal/sql/ast/alter_collation_stmt.go +++ b/internal/sql/ast/alter_collation_stmt.go @@ -1,6 +1,8 @@ package ast type AlterCollationStmt struct { + Tag NodeTag[AlterCollationStmt] `json:"tag"` + Collname *List } diff --git a/internal/sql/ast/alter_database_set_stmt.go b/internal/sql/ast/alter_database_set_stmt.go index ba9926bed1..6c16831e8a 100644 --- a/internal/sql/ast/alter_database_set_stmt.go +++ b/internal/sql/ast/alter_database_set_stmt.go @@ -1,6 +1,8 @@ package ast type AlterDatabaseSetStmt struct { + Tag NodeTag[AlterDatabaseSetStmt] `json:"tag"` + Dbname *string Setstmt *VariableSetStmt } diff --git a/internal/sql/ast/alter_database_stmt.go b/internal/sql/ast/alter_database_stmt.go index 84d91f089c..995d864023 100644 --- a/internal/sql/ast/alter_database_stmt.go +++ b/internal/sql/ast/alter_database_stmt.go @@ -1,6 +1,8 @@ package ast type AlterDatabaseStmt struct { + Tag NodeTag[AlterDatabaseStmt] `json:"tag"` + Dbname *string Options *List } diff --git a/internal/sql/ast/alter_default_privileges_stmt.go b/internal/sql/ast/alter_default_privileges_stmt.go index 64632a726d..f9f752b200 100644 --- a/internal/sql/ast/alter_default_privileges_stmt.go +++ b/internal/sql/ast/alter_default_privileges_stmt.go @@ -1,6 +1,8 @@ package ast type AlterDefaultPrivilegesStmt struct { + Tag NodeTag[AlterDefaultPrivilegesStmt] `json:"tag"` + Options *List Action *GrantStmt } diff --git a/internal/sql/ast/alter_domain_stmt.go b/internal/sql/ast/alter_domain_stmt.go index f9f419937f..4cd8418c05 100644 --- a/internal/sql/ast/alter_domain_stmt.go +++ b/internal/sql/ast/alter_domain_stmt.go @@ -1,6 +1,8 @@ package ast type AlterDomainStmt struct { + Tag NodeTag[AlterDomainStmt] `json:"tag"` + Subtype byte TypeName *List Name *string diff --git a/internal/sql/ast/alter_enum_stmt.go b/internal/sql/ast/alter_enum_stmt.go index 1346b3c0d0..f2a58e9e7e 100644 --- a/internal/sql/ast/alter_enum_stmt.go +++ b/internal/sql/ast/alter_enum_stmt.go @@ -1,6 +1,8 @@ package ast type AlterEnumStmt struct { + Tag NodeTag[AlterEnumStmt] `json:"tag"` + TypeName *List OldVal *string NewVal *string diff --git a/internal/sql/ast/alter_event_trig_stmt.go b/internal/sql/ast/alter_event_trig_stmt.go index eeb5f75d42..f6bb0e4daf 100644 --- a/internal/sql/ast/alter_event_trig_stmt.go +++ b/internal/sql/ast/alter_event_trig_stmt.go @@ -1,6 +1,8 @@ package ast type AlterEventTrigStmt struct { + Tag NodeTag[AlterEventTrigStmt] `json:"tag"` + Trigname *string Tgenabled byte } diff --git a/internal/sql/ast/alter_extension_contents_stmt.go b/internal/sql/ast/alter_extension_contents_stmt.go index 27ad1c31d6..6ebf0437e0 100644 --- a/internal/sql/ast/alter_extension_contents_stmt.go +++ b/internal/sql/ast/alter_extension_contents_stmt.go @@ -1,6 +1,8 @@ package ast type AlterExtensionContentsStmt struct { + Tag NodeTag[AlterExtensionContentsStmt] `json:"tag"` + Extname *string Action int Objtype ObjectType diff --git a/internal/sql/ast/alter_extension_stmt.go b/internal/sql/ast/alter_extension_stmt.go index 049e712c94..cb191b2b03 100644 --- a/internal/sql/ast/alter_extension_stmt.go +++ b/internal/sql/ast/alter_extension_stmt.go @@ -1,6 +1,8 @@ package ast type AlterExtensionStmt struct { + Tag NodeTag[AlterExtensionStmt] `json:"tag"` + Extname *string Options *List } diff --git a/internal/sql/ast/alter_fdw_stmt.go b/internal/sql/ast/alter_fdw_stmt.go index 12c6457d71..458cef831f 100644 --- a/internal/sql/ast/alter_fdw_stmt.go +++ b/internal/sql/ast/alter_fdw_stmt.go @@ -1,6 +1,8 @@ package ast type AlterFdwStmt struct { + Tag NodeTag[AlterFdwStmt] `json:"tag"` + Fdwname *string FuncOptions *List Options *List diff --git a/internal/sql/ast/alter_foreign_server_stmt.go b/internal/sql/ast/alter_foreign_server_stmt.go index 9f3e8dbe64..0ca94b72e7 100644 --- a/internal/sql/ast/alter_foreign_server_stmt.go +++ b/internal/sql/ast/alter_foreign_server_stmt.go @@ -1,6 +1,8 @@ package ast type AlterForeignServerStmt struct { + Tag NodeTag[AlterForeignServerStmt] `json:"tag"` + Servername *string Version *string Options *List diff --git a/internal/sql/ast/alter_function_stmt.go b/internal/sql/ast/alter_function_stmt.go index 1193ab7656..73bbeb3f1f 100644 --- a/internal/sql/ast/alter_function_stmt.go +++ b/internal/sql/ast/alter_function_stmt.go @@ -1,6 +1,8 @@ package ast type AlterFunctionStmt struct { + Tag NodeTag[AlterFunctionStmt] `json:"tag"` + Func *ObjectWithArgs Actions *List } diff --git a/internal/sql/ast/alter_object_depends_stmt.go b/internal/sql/ast/alter_object_depends_stmt.go index 83cc3c9641..56e6535b1c 100644 --- a/internal/sql/ast/alter_object_depends_stmt.go +++ b/internal/sql/ast/alter_object_depends_stmt.go @@ -1,6 +1,8 @@ package ast type AlterObjectDependsStmt struct { + Tag NodeTag[AlterObjectDependsStmt] `json:"tag"` + ObjectType ObjectType Relation *RangeVar Object Node diff --git a/internal/sql/ast/alter_object_schema_stmt.go b/internal/sql/ast/alter_object_schema_stmt.go index 664e6f1495..d764551113 100644 --- a/internal/sql/ast/alter_object_schema_stmt.go +++ b/internal/sql/ast/alter_object_schema_stmt.go @@ -1,6 +1,8 @@ package ast type AlterObjectSchemaStmt struct { + Tag NodeTag[AlterObjectSchemaStmt] `json:"tag"` + ObjectType ObjectType Relation *RangeVar Object Node diff --git a/internal/sql/ast/alter_op_family_stmt.go b/internal/sql/ast/alter_op_family_stmt.go index 60655d76b0..bb812083ae 100644 --- a/internal/sql/ast/alter_op_family_stmt.go +++ b/internal/sql/ast/alter_op_family_stmt.go @@ -1,6 +1,8 @@ package ast type AlterOpFamilyStmt struct { + Tag NodeTag[AlterOpFamilyStmt] `json:"tag"` + Opfamilyname *List Amname *string IsDrop bool diff --git a/internal/sql/ast/alter_operator_stmt.go b/internal/sql/ast/alter_operator_stmt.go index 11ef659a8c..ac14e1c39f 100644 --- a/internal/sql/ast/alter_operator_stmt.go +++ b/internal/sql/ast/alter_operator_stmt.go @@ -1,6 +1,8 @@ package ast type AlterOperatorStmt struct { + Tag NodeTag[AlterOperatorStmt] `json:"tag"` + Opername *ObjectWithArgs Options *List } diff --git a/internal/sql/ast/alter_owner_stmt.go b/internal/sql/ast/alter_owner_stmt.go index 8a4be65183..43c8e342a6 100644 --- a/internal/sql/ast/alter_owner_stmt.go +++ b/internal/sql/ast/alter_owner_stmt.go @@ -1,6 +1,8 @@ package ast type AlterOwnerStmt struct { + Tag NodeTag[AlterOwnerStmt] `json:"tag"` + ObjectType ObjectType Relation *RangeVar Object Node diff --git a/internal/sql/ast/alter_policy_stmt.go b/internal/sql/ast/alter_policy_stmt.go index 03e814328c..c48ea71bea 100644 --- a/internal/sql/ast/alter_policy_stmt.go +++ b/internal/sql/ast/alter_policy_stmt.go @@ -1,6 +1,8 @@ package ast type AlterPolicyStmt struct { + Tag NodeTag[AlterPolicyStmt] `json:"tag"` + PolicyName *string Table *RangeVar Roles *List diff --git a/internal/sql/ast/alter_publication_stmt.go b/internal/sql/ast/alter_publication_stmt.go index c1288858eb..adcb3facf3 100644 --- a/internal/sql/ast/alter_publication_stmt.go +++ b/internal/sql/ast/alter_publication_stmt.go @@ -1,6 +1,8 @@ package ast type AlterPublicationStmt struct { + Tag NodeTag[AlterPublicationStmt] `json:"tag"` + Pubname *string Options *List Tables *List diff --git a/internal/sql/ast/alter_role_set_stmt.go b/internal/sql/ast/alter_role_set_stmt.go index cda679017c..ec85174170 100644 --- a/internal/sql/ast/alter_role_set_stmt.go +++ b/internal/sql/ast/alter_role_set_stmt.go @@ -1,6 +1,8 @@ package ast type AlterRoleSetStmt struct { + Tag NodeTag[AlterRoleSetStmt] `json:"tag"` + Role *RoleSpec Database *string Setstmt *VariableSetStmt diff --git a/internal/sql/ast/alter_role_stmt.go b/internal/sql/ast/alter_role_stmt.go index e616f05917..26630bfacf 100644 --- a/internal/sql/ast/alter_role_stmt.go +++ b/internal/sql/ast/alter_role_stmt.go @@ -1,6 +1,8 @@ package ast type AlterRoleStmt struct { + Tag NodeTag[AlterRoleStmt] `json:"tag"` + Role *RoleSpec Options *List Action int diff --git a/internal/sql/ast/alter_seq_stmt.go b/internal/sql/ast/alter_seq_stmt.go index ca4c86a413..0ef3bfb34a 100644 --- a/internal/sql/ast/alter_seq_stmt.go +++ b/internal/sql/ast/alter_seq_stmt.go @@ -1,6 +1,8 @@ package ast type AlterSeqStmt struct { + Tag NodeTag[AlterSeqStmt] `json:"tag"` + Sequence *RangeVar Options *List ForIdentity bool diff --git a/internal/sql/ast/alter_subscription_stmt.go b/internal/sql/ast/alter_subscription_stmt.go index 443fc7bfb8..19e955aaa3 100644 --- a/internal/sql/ast/alter_subscription_stmt.go +++ b/internal/sql/ast/alter_subscription_stmt.go @@ -1,6 +1,8 @@ package ast type AlterSubscriptionStmt struct { + Tag NodeTag[AlterSubscriptionStmt] `json:"tag"` + Kind AlterSubscriptionType Subname *string Conninfo *string diff --git a/internal/sql/ast/alter_system_stmt.go b/internal/sql/ast/alter_system_stmt.go index c5657f9c1a..1b05ab05c0 100644 --- a/internal/sql/ast/alter_system_stmt.go +++ b/internal/sql/ast/alter_system_stmt.go @@ -1,6 +1,8 @@ package ast type AlterSystemStmt struct { + Tag NodeTag[AlterSystemStmt] `json:"tag"` + Setstmt *VariableSetStmt } diff --git a/internal/sql/ast/alter_table_cmd.go b/internal/sql/ast/alter_table_cmd.go index 90ffd891eb..5e68571d5b 100644 --- a/internal/sql/ast/alter_table_cmd.go +++ b/internal/sql/ast/alter_table_cmd.go @@ -30,6 +30,8 @@ func (t AlterTableType) String() string { } type AlterTableCmd struct { + Tag NodeTag[AlterTableCmd] `json:"tag"` + Subtype AlterTableType Name *string Def *ColumnDef diff --git a/internal/sql/ast/alter_table_move_all_stmt.go b/internal/sql/ast/alter_table_move_all_stmt.go index 39f1256083..6cdb343d10 100644 --- a/internal/sql/ast/alter_table_move_all_stmt.go +++ b/internal/sql/ast/alter_table_move_all_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTableMoveAllStmt struct { + Tag NodeTag[AlterTableMoveAllStmt] `json:"tag"` + OrigTablespacename *string Objtype ObjectType Roles *List diff --git a/internal/sql/ast/alter_table_set_schema_stmt.go b/internal/sql/ast/alter_table_set_schema_stmt.go index 890cb3e5e8..fb8c9c6c4e 100644 --- a/internal/sql/ast/alter_table_set_schema_stmt.go +++ b/internal/sql/ast/alter_table_set_schema_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTableSetSchemaStmt struct { + Tag NodeTag[AlterTableSetSchemaStmt] `json:"tag"` + Table *TableName NewSchema *string MissingOk bool diff --git a/internal/sql/ast/alter_table_space_options_stmt.go b/internal/sql/ast/alter_table_space_options_stmt.go index fc49cfe6b8..bab3c032e2 100644 --- a/internal/sql/ast/alter_table_space_options_stmt.go +++ b/internal/sql/ast/alter_table_space_options_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTableSpaceOptionsStmt struct { + Tag NodeTag[AlterTableSpaceOptionsStmt] `json:"tag"` + Tablespacename *string Options *List IsReset bool diff --git a/internal/sql/ast/alter_table_stmt.go b/internal/sql/ast/alter_table_stmt.go index afbf014b07..701be525fc 100644 --- a/internal/sql/ast/alter_table_stmt.go +++ b/internal/sql/ast/alter_table_stmt.go @@ -3,6 +3,8 @@ 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 diff --git a/internal/sql/ast/alter_ts_configuration_stmt.go b/internal/sql/ast/alter_ts_configuration_stmt.go index 6b58ada4e6..2253e74340 100644 --- a/internal/sql/ast/alter_ts_configuration_stmt.go +++ b/internal/sql/ast/alter_ts_configuration_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTSConfigurationStmt struct { + Tag NodeTag[AlterTSConfigurationStmt] `json:"tag"` + Kind AlterTSConfigType Cfgname *List Tokentype *List diff --git a/internal/sql/ast/alter_ts_dictionary_stmt.go b/internal/sql/ast/alter_ts_dictionary_stmt.go index 0506c49b34..29862a1646 100644 --- a/internal/sql/ast/alter_ts_dictionary_stmt.go +++ b/internal/sql/ast/alter_ts_dictionary_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTSDictionaryStmt struct { + Tag NodeTag[AlterTSDictionaryStmt] `json:"tag"` + Dictname *List Options *List } diff --git a/internal/sql/ast/alter_type_add_value_stmt.go b/internal/sql/ast/alter_type_add_value_stmt.go index 56ae7dd9b7..015d9e39c9 100644 --- a/internal/sql/ast/alter_type_add_value_stmt.go +++ b/internal/sql/ast/alter_type_add_value_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTypeAddValueStmt struct { + Tag NodeTag[AlterTypeAddValueStmt] `json:"tag"` + Type *TypeName NewValue *string NewValHasNeighbor bool diff --git a/internal/sql/ast/alter_type_rename_value_stmt.go b/internal/sql/ast/alter_type_rename_value_stmt.go index 376286511f..c9d4f5cea5 100644 --- a/internal/sql/ast/alter_type_rename_value_stmt.go +++ b/internal/sql/ast/alter_type_rename_value_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTypeRenameValueStmt struct { + Tag NodeTag[AlterTypeRenameValueStmt] `json:"tag"` + Type *TypeName OldValue *string NewValue *string diff --git a/internal/sql/ast/alter_type_set_schema_stmt.go b/internal/sql/ast/alter_type_set_schema_stmt.go index 22206d85cd..e5755a34e1 100644 --- a/internal/sql/ast/alter_type_set_schema_stmt.go +++ b/internal/sql/ast/alter_type_set_schema_stmt.go @@ -1,6 +1,8 @@ package ast type AlterTypeSetSchemaStmt struct { + Tag NodeTag[AlterTypeSetSchemaStmt] `json:"tag"` + Type *TypeName NewSchema *string } diff --git a/internal/sql/ast/alter_user_mapping_stmt.go b/internal/sql/ast/alter_user_mapping_stmt.go index aeeb0912ae..cb7e09c6dc 100644 --- a/internal/sql/ast/alter_user_mapping_stmt.go +++ b/internal/sql/ast/alter_user_mapping_stmt.go @@ -1,6 +1,8 @@ package ast type AlterUserMappingStmt struct { + Tag NodeTag[AlterUserMappingStmt] `json:"tag"` + User *RoleSpec Servername *string Options *List diff --git a/internal/sql/ast/alternative_sub_plan.go b/internal/sql/ast/alternative_sub_plan.go index 86031afd19..3ad50efb18 100644 --- a/internal/sql/ast/alternative_sub_plan.go +++ b/internal/sql/ast/alternative_sub_plan.go @@ -1,6 +1,8 @@ package ast type AlternativeSubPlan struct { + Tag NodeTag[AlternativeSubPlan] `json:"tag"` + Xpr Node Subplans *List } diff --git a/internal/sql/ast/array_coerce_expr.go b/internal/sql/ast/array_coerce_expr.go index 314c6881bf..16ab4a3b3e 100644 --- a/internal/sql/ast/array_coerce_expr.go +++ b/internal/sql/ast/array_coerce_expr.go @@ -1,6 +1,8 @@ package ast type ArrayCoerceExpr struct { + Tag NodeTag[ArrayCoerceExpr] `json:"tag"` + Xpr Node Arg Node Elemfuncid Oid diff --git a/internal/sql/ast/array_expr.go b/internal/sql/ast/array_expr.go index c61aed8df7..bed2c7fe50 100644 --- a/internal/sql/ast/array_expr.go +++ b/internal/sql/ast/array_expr.go @@ -1,6 +1,8 @@ package ast type ArrayExpr struct { + Tag NodeTag[ArrayExpr] `json:"tag"` + Xpr Node ArrayTypeid Oid ArrayCollid Oid diff --git a/internal/sql/ast/array_ref.go b/internal/sql/ast/array_ref.go index d94d800bb9..1753a21c7f 100644 --- a/internal/sql/ast/array_ref.go +++ b/internal/sql/ast/array_ref.go @@ -1,6 +1,8 @@ package ast type ArrayRef struct { + Tag NodeTag[ArrayRef] `json:"tag"` + Xpr Node Refarraytype Oid Refelemtype Oid diff --git a/internal/sql/ast/between_expr.go b/internal/sql/ast/between_expr.go index a160f1892c..e17fce9286 100644 --- a/internal/sql/ast/between_expr.go +++ b/internal/sql/ast/between_expr.go @@ -3,6 +3,8 @@ 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 // Left is the left expression in the between statement. diff --git a/internal/sql/ast/bit_string.go b/internal/sql/ast/bit_string.go index f1f069d079..253a3f8d0e 100644 --- a/internal/sql/ast/bit_string.go +++ b/internal/sql/ast/bit_string.go @@ -1,6 +1,8 @@ package ast type BitString struct { + Tag NodeTag[BitString] `json:"tag"` + Str string } diff --git a/internal/sql/ast/block_id_data.go b/internal/sql/ast/block_id_data.go index ce5563f6bb..2212e61e80 100644 --- a/internal/sql/ast/block_id_data.go +++ b/internal/sql/ast/block_id_data.go @@ -1,6 +1,8 @@ package ast type BlockIdData struct { + Tag NodeTag[BlockIdData] `json:"tag"` + BiHi uint16 BiLo uint16 } diff --git a/internal/sql/ast/bool_expr.go b/internal/sql/ast/bool_expr.go index 65b4af53d2..0f61b45133 100644 --- a/internal/sql/ast/bool_expr.go +++ b/internal/sql/ast/bool_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type BoolExpr struct { + Tag NodeTag[BoolExpr] `json:"tag"` + Xpr Node Boolop BoolExprType Args *List diff --git a/internal/sql/ast/boolean.go b/internal/sql/ast/boolean.go index 16a6db54da..efb40e7c5d 100644 --- a/internal/sql/ast/boolean.go +++ b/internal/sql/ast/boolean.go @@ -7,6 +7,8 @@ import ( ) type Boolean struct { + Tag NodeTag[Boolean] `json:"tag"` + Boolval bool } diff --git a/internal/sql/ast/boolean_test_expr.go b/internal/sql/ast/boolean_test_expr.go index 7efbb46462..68a75a53e5 100644 --- a/internal/sql/ast/boolean_test_expr.go +++ b/internal/sql/ast/boolean_test_expr.go @@ -1,6 +1,8 @@ package ast type BooleanTest struct { + Tag NodeTag[BooleanTest] `json:"tag"` + Xpr Node Arg Node Booltesttype BoolTestType diff --git a/internal/sql/ast/call_stmt.go b/internal/sql/ast/call_stmt.go index 6cba39986e..400059cbdb 100644 --- a/internal/sql/ast/call_stmt.go +++ b/internal/sql/ast/call_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CallStmt struct { + Tag NodeTag[CallStmt] `json:"tag"` + FuncCall *FuncCall } diff --git a/internal/sql/ast/case_expr.go b/internal/sql/ast/case_expr.go index 52692b297b..18decb83db 100644 --- a/internal/sql/ast/case_expr.go +++ b/internal/sql/ast/case_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseExpr struct { + Tag NodeTag[CaseExpr] `json:"tag"` + Xpr Node Casetype Oid Casecollid Oid diff --git a/internal/sql/ast/case_test_expr.go b/internal/sql/ast/case_test_expr.go index 8899985ca8..58dfae4c8a 100644 --- a/internal/sql/ast/case_test_expr.go +++ b/internal/sql/ast/case_test_expr.go @@ -1,6 +1,8 @@ package ast type CaseTestExpr struct { + Tag NodeTag[CaseTestExpr] `json:"tag"` + Xpr Node TypeId Oid TypeMod int32 diff --git a/internal/sql/ast/case_when.go b/internal/sql/ast/case_when.go index 9636d24a97..9b86268cd8 100644 --- a/internal/sql/ast/case_when.go +++ b/internal/sql/ast/case_when.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseWhen struct { + Tag NodeTag[CaseWhen] `json:"tag"` + Xpr Node Expr Node Result Node 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..446d4109e7 100644 --- a/internal/sql/ast/close_portal_stmt.go +++ b/internal/sql/ast/close_portal_stmt.go @@ -1,6 +1,8 @@ package ast type ClosePortalStmt struct { + Tag NodeTag[ClosePortalStmt] `json:"tag"` + Portalname *string } diff --git a/internal/sql/ast/cluster_stmt.go b/internal/sql/ast/cluster_stmt.go index 5e235eb482..aeb9beeb85 100644 --- a/internal/sql/ast/cluster_stmt.go +++ b/internal/sql/ast/cluster_stmt.go @@ -1,6 +1,8 @@ package ast type ClusterStmt struct { + Tag NodeTag[ClusterStmt] `json:"tag"` + Relation *RangeVar Indexname *string Verbose bool diff --git a/internal/sql/ast/coalesce_expr.go b/internal/sql/ast/coalesce_expr.go index 6aadffd30c..d0bea53286 100644 --- a/internal/sql/ast/coalesce_expr.go +++ b/internal/sql/ast/coalesce_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CoalesceExpr struct { + Tag NodeTag[CoalesceExpr] `json:"tag"` + Xpr Node Coalescetype Oid Coalescecollid Oid diff --git a/internal/sql/ast/coerce_to_domain.go b/internal/sql/ast/coerce_to_domain.go index e81a83f15d..65079dae57 100644 --- a/internal/sql/ast/coerce_to_domain.go +++ b/internal/sql/ast/coerce_to_domain.go @@ -1,6 +1,8 @@ package ast type CoerceToDomain struct { + Tag NodeTag[CoerceToDomain] `json:"tag"` + Xpr Node Arg Node Resulttype Oid diff --git a/internal/sql/ast/coerce_to_domain_value.go b/internal/sql/ast/coerce_to_domain_value.go index b2e26cb00c..de5ce0bc4a 100644 --- a/internal/sql/ast/coerce_to_domain_value.go +++ b/internal/sql/ast/coerce_to_domain_value.go @@ -1,6 +1,8 @@ package ast type CoerceToDomainValue struct { + Tag NodeTag[CoerceToDomainValue] `json:"tag"` + Xpr Node TypeId Oid TypeMod int32 diff --git a/internal/sql/ast/coerce_via_io.go b/internal/sql/ast/coerce_via_io.go index 48aea6ce72..98b0a8965e 100644 --- a/internal/sql/ast/coerce_via_io.go +++ b/internal/sql/ast/coerce_via_io.go @@ -1,6 +1,8 @@ package ast type CoerceViaIO struct { + Tag NodeTag[CoerceViaIO] `json:"tag"` + Xpr Node Arg Node Resulttype Oid diff --git a/internal/sql/ast/collate_clause.go b/internal/sql/ast/collate_clause.go index 0c1629a05d..e212f5c06e 100644 --- a/internal/sql/ast/collate_clause.go +++ b/internal/sql/ast/collate_clause.go @@ -1,6 +1,8 @@ package ast type CollateClause struct { + Tag NodeTag[CollateClause] `json:"tag"` + Arg Node Collname *List Location int diff --git a/internal/sql/ast/collate_expr.go b/internal/sql/ast/collate_expr.go index 80483f75ce..898f5bc4a1 100644 --- a/internal/sql/ast/collate_expr.go +++ b/internal/sql/ast/collate_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CollateExpr struct { + Tag NodeTag[CollateExpr] `json:"tag"` + Xpr Node Arg Node CollOid Oid diff --git a/internal/sql/ast/column_def.go b/internal/sql/ast/column_def.go index 6ac6a6e0c7..1374950120 100644 --- a/internal/sql/ast/column_def.go +++ b/internal/sql/ast/column_def.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ColumnDef struct { + Tag NodeTag[ColumnDef] `json:"tag"` + Colname string // 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 diff --git a/internal/sql/ast/column_ref.go b/internal/sql/ast/column_ref.go index 943311799d..0be1dbdcc4 100644 --- a/internal/sql/ast/column_ref.go +++ b/internal/sql/ast/column_ref.go @@ -7,6 +7,8 @@ import ( ) type ColumnRef struct { + Tag NodeTag[ColumnRef] `json:"tag"` + Name string // From pg.ColumnRef diff --git a/internal/sql/ast/comment_on_column_stmt.go b/internal/sql/ast/comment_on_column_stmt.go index 6438b4ccc7..480a559b3e 100644 --- a/internal/sql/ast/comment_on_column_stmt.go +++ b/internal/sql/ast/comment_on_column_stmt.go @@ -1,6 +1,8 @@ package ast type CommentOnColumnStmt struct { + Tag NodeTag[CommentOnColumnStmt] `json:"tag"` + Table *TableName Col *ColumnRef Comment *string diff --git a/internal/sql/ast/comment_on_schema_stmt.go b/internal/sql/ast/comment_on_schema_stmt.go index edff162db0..fd8e74fc15 100644 --- a/internal/sql/ast/comment_on_schema_stmt.go +++ b/internal/sql/ast/comment_on_schema_stmt.go @@ -1,6 +1,8 @@ package ast type CommentOnSchemaStmt struct { + Tag NodeTag[CommentOnSchemaStmt] `json:"tag"` + Schema *String Comment *string } diff --git a/internal/sql/ast/comment_on_table_stmt.go b/internal/sql/ast/comment_on_table_stmt.go index efb158f94b..2d1db8667a 100644 --- a/internal/sql/ast/comment_on_table_stmt.go +++ b/internal/sql/ast/comment_on_table_stmt.go @@ -1,6 +1,8 @@ package ast type CommentOnTableStmt struct { + Tag NodeTag[CommentOnTableStmt] `json:"tag"` + Table *TableName Comment *string } diff --git a/internal/sql/ast/comment_on_type_stmt.go b/internal/sql/ast/comment_on_type_stmt.go index eb90bf5115..0fd4a1a144 100644 --- a/internal/sql/ast/comment_on_type_stmt.go +++ b/internal/sql/ast/comment_on_type_stmt.go @@ -1,6 +1,8 @@ package ast type CommentOnTypeStmt struct { + Tag NodeTag[CommentOnTypeStmt] `json:"tag"` + Type *TypeName Comment *string } diff --git a/internal/sql/ast/comment_on_view_stmt.go b/internal/sql/ast/comment_on_view_stmt.go index 2648d87918..c0d7e98396 100644 --- a/internal/sql/ast/comment_on_view_stmt.go +++ b/internal/sql/ast/comment_on_view_stmt.go @@ -1,6 +1,8 @@ package ast type CommentOnViewStmt struct { + Tag NodeTag[CommentOnViewStmt] `json:"tag"` + View *TableName Comment *string } diff --git a/internal/sql/ast/comment_stmt.go b/internal/sql/ast/comment_stmt.go index 304827a294..b56c6869ad 100644 --- a/internal/sql/ast/comment_stmt.go +++ b/internal/sql/ast/comment_stmt.go @@ -1,6 +1,8 @@ package ast type CommentStmt struct { + Tag NodeTag[CommentStmt] `json:"tag"` + Objtype ObjectType Object Node Comment *string diff --git a/internal/sql/ast/common_table_expr.go b/internal/sql/ast/common_table_expr.go index a9cc9d5022..df611885cc 100644 --- a/internal/sql/ast/common_table_expr.go +++ b/internal/sql/ast/common_table_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CommonTableExpr struct { + Tag NodeTag[CommonTableExpr] `json:"tag"` + Ctename *string Aliascolnames *List Ctequery Node diff --git a/internal/sql/ast/composite_type_stmt.go b/internal/sql/ast/composite_type_stmt.go index f9a19b2653..ec96701f09 100644 --- a/internal/sql/ast/composite_type_stmt.go +++ b/internal/sql/ast/composite_type_stmt.go @@ -1,6 +1,8 @@ package ast type CompositeTypeStmt struct { + Tag NodeTag[CompositeTypeStmt] `json:"tag"` + TypeName *TypeName } diff --git a/internal/sql/ast/const.go b/internal/sql/ast/const.go index d33f0e84ed..9e026c6b8c 100644 --- a/internal/sql/ast/const.go +++ b/internal/sql/ast/const.go @@ -1,6 +1,8 @@ package ast type Const struct { + Tag NodeTag[Const] `json:"tag"` + Xpr Node Consttype Oid Consttypmod int32 diff --git a/internal/sql/ast/constraint.go b/internal/sql/ast/constraint.go index 5b628506af..d959e0edb4 100644 --- a/internal/sql/ast/constraint.go +++ b/internal/sql/ast/constraint.go @@ -1,6 +1,8 @@ package ast type Constraint struct { + Tag NodeTag[Constraint] `json:"tag"` + Contype ConstrType Conname *string Deferrable bool diff --git a/internal/sql/ast/constraints_set_stmt.go b/internal/sql/ast/constraints_set_stmt.go index ca0a33323d..bb3d108453 100644 --- a/internal/sql/ast/constraints_set_stmt.go +++ b/internal/sql/ast/constraints_set_stmt.go @@ -1,6 +1,8 @@ package ast type ConstraintsSetStmt struct { + Tag NodeTag[ConstraintsSetStmt] `json:"tag"` + Constraints *List Deferred bool } diff --git a/internal/sql/ast/convert_rowtype_expr.go b/internal/sql/ast/convert_rowtype_expr.go index 9e72c0c5c5..93ce47ce49 100644 --- a/internal/sql/ast/convert_rowtype_expr.go +++ b/internal/sql/ast/convert_rowtype_expr.go @@ -1,6 +1,8 @@ package ast type ConvertRowtypeExpr struct { + Tag NodeTag[ConvertRowtypeExpr] `json:"tag"` + Xpr Node Arg Node Resulttype Oid diff --git a/internal/sql/ast/copy_stmt.go b/internal/sql/ast/copy_stmt.go index 65d4dc69cc..c518deb6f2 100644 --- a/internal/sql/ast/copy_stmt.go +++ b/internal/sql/ast/copy_stmt.go @@ -1,6 +1,8 @@ package ast type CopyStmt struct { + Tag NodeTag[CopyStmt] `json:"tag"` + Relation *RangeVar Query Node Attlist *List diff --git a/internal/sql/ast/create_am_stmt.go b/internal/sql/ast/create_am_stmt.go index 16fe6455c5..bfc345efd8 100644 --- a/internal/sql/ast/create_am_stmt.go +++ b/internal/sql/ast/create_am_stmt.go @@ -1,6 +1,8 @@ package ast type CreateAmStmt struct { + Tag NodeTag[CreateAmStmt] `json:"tag"` + Amname *string HandlerName *List Amtype byte diff --git a/internal/sql/ast/create_cast_stmt.go b/internal/sql/ast/create_cast_stmt.go index 7ae94d3c6b..cd478d1abd 100644 --- a/internal/sql/ast/create_cast_stmt.go +++ b/internal/sql/ast/create_cast_stmt.go @@ -1,6 +1,8 @@ package ast type CreateCastStmt struct { + Tag NodeTag[CreateCastStmt] `json:"tag"` + Sourcetype *TypeName Targettype *TypeName Func *ObjectWithArgs diff --git a/internal/sql/ast/create_conversion_stmt.go b/internal/sql/ast/create_conversion_stmt.go index c0f4de14b1..ccbb7dad70 100644 --- a/internal/sql/ast/create_conversion_stmt.go +++ b/internal/sql/ast/create_conversion_stmt.go @@ -1,6 +1,8 @@ package ast type CreateConversionStmt struct { + Tag NodeTag[CreateConversionStmt] `json:"tag"` + ConversionName *List ForEncodingName *string ToEncodingName *string diff --git a/internal/sql/ast/create_domain_stmt.go b/internal/sql/ast/create_domain_stmt.go index 3c541c4b2e..6994a2473c 100644 --- a/internal/sql/ast/create_domain_stmt.go +++ b/internal/sql/ast/create_domain_stmt.go @@ -1,6 +1,8 @@ package ast type CreateDomainStmt struct { + Tag NodeTag[CreateDomainStmt] `json:"tag"` + Domainname *List TypeName *TypeName CollClause *CollateClause diff --git a/internal/sql/ast/create_enum_stmt.go b/internal/sql/ast/create_enum_stmt.go index a7d2df0fc9..9265b24ce3 100644 --- a/internal/sql/ast/create_enum_stmt.go +++ b/internal/sql/ast/create_enum_stmt.go @@ -1,6 +1,8 @@ package ast type CreateEnumStmt struct { + Tag NodeTag[CreateEnumStmt] `json:"tag"` + TypeName *TypeName Vals *List } diff --git a/internal/sql/ast/create_event_trig_stmt.go b/internal/sql/ast/create_event_trig_stmt.go index 276b32a6a0..01aea1096e 100644 --- a/internal/sql/ast/create_event_trig_stmt.go +++ b/internal/sql/ast/create_event_trig_stmt.go @@ -1,6 +1,8 @@ package ast type CreateEventTrigStmt struct { + Tag NodeTag[CreateEventTrigStmt] `json:"tag"` + Trigname *string Eventname *string Whenclause *List diff --git a/internal/sql/ast/create_extension_stmt.go b/internal/sql/ast/create_extension_stmt.go index 140a10da4c..4a23773c37 100644 --- a/internal/sql/ast/create_extension_stmt.go +++ b/internal/sql/ast/create_extension_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateExtensionStmt struct { + Tag NodeTag[CreateExtensionStmt] `json:"tag"` + Extname *string IfNotExists bool Options *List diff --git a/internal/sql/ast/create_fdw_stmt.go b/internal/sql/ast/create_fdw_stmt.go index fd97378308..fad9ee099d 100644 --- a/internal/sql/ast/create_fdw_stmt.go +++ b/internal/sql/ast/create_fdw_stmt.go @@ -1,6 +1,8 @@ package ast type CreateFdwStmt struct { + Tag NodeTag[CreateFdwStmt] `json:"tag"` + Fdwname *string FuncOptions *List Options *List diff --git a/internal/sql/ast/create_foreign_server_stmt.go b/internal/sql/ast/create_foreign_server_stmt.go index b7d24445b4..37fc711296 100644 --- a/internal/sql/ast/create_foreign_server_stmt.go +++ b/internal/sql/ast/create_foreign_server_stmt.go @@ -1,6 +1,8 @@ package ast type CreateForeignServerStmt struct { + Tag NodeTag[CreateForeignServerStmt] `json:"tag"` + Servername *string Servertype *string Version *string diff --git a/internal/sql/ast/create_foreign_table_stmt.go b/internal/sql/ast/create_foreign_table_stmt.go index 6661588786..4e1ab8e53e 100644 --- a/internal/sql/ast/create_foreign_table_stmt.go +++ b/internal/sql/ast/create_foreign_table_stmt.go @@ -1,6 +1,8 @@ package ast type CreateForeignTableStmt struct { + Tag NodeTag[CreateForeignTableStmt] `json:"tag"` + Base *CreateStmt Servername *string Options *List diff --git a/internal/sql/ast/create_function_stmt.go b/internal/sql/ast/create_function_stmt.go index f5200085ee..c878d36fde 100644 --- a/internal/sql/ast/create_function_stmt.go +++ b/internal/sql/ast/create_function_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateFunctionStmt struct { + Tag NodeTag[CreateFunctionStmt] `json:"tag"` + Replace bool Params *List ReturnType *TypeName diff --git a/internal/sql/ast/create_op_class_item.go b/internal/sql/ast/create_op_class_item.go index 09621bd0d8..94d0a00b56 100644 --- a/internal/sql/ast/create_op_class_item.go +++ b/internal/sql/ast/create_op_class_item.go @@ -1,6 +1,8 @@ package ast type CreateOpClassItem struct { + Tag NodeTag[CreateOpClassItem] `json:"tag"` + Itemtype int Name *ObjectWithArgs Number int diff --git a/internal/sql/ast/create_op_class_stmt.go b/internal/sql/ast/create_op_class_stmt.go index a4ab7b067c..ec4f3cbf5e 100644 --- a/internal/sql/ast/create_op_class_stmt.go +++ b/internal/sql/ast/create_op_class_stmt.go @@ -1,6 +1,8 @@ package ast type CreateOpClassStmt struct { + Tag NodeTag[CreateOpClassStmt] `json:"tag"` + Opclassname *List Opfamilyname *List Amname *string diff --git a/internal/sql/ast/create_op_family_stmt.go b/internal/sql/ast/create_op_family_stmt.go index b939625ed3..394a8cf4d4 100644 --- a/internal/sql/ast/create_op_family_stmt.go +++ b/internal/sql/ast/create_op_family_stmt.go @@ -1,6 +1,8 @@ package ast type CreateOpFamilyStmt struct { + Tag NodeTag[CreateOpFamilyStmt] `json:"tag"` + Opfamilyname *List Amname *string } diff --git a/internal/sql/ast/create_p_lang_stmt.go b/internal/sql/ast/create_p_lang_stmt.go index 5f11ce9eb1..0e96bc4725 100644 --- a/internal/sql/ast/create_p_lang_stmt.go +++ b/internal/sql/ast/create_p_lang_stmt.go @@ -1,6 +1,8 @@ package ast type CreatePLangStmt struct { + Tag NodeTag[CreatePLangStmt] `json:"tag"` + Replace bool Plname *string Plhandler *List diff --git a/internal/sql/ast/create_policy_stmt.go b/internal/sql/ast/create_policy_stmt.go index 39e244f7a4..a514ff97fc 100644 --- a/internal/sql/ast/create_policy_stmt.go +++ b/internal/sql/ast/create_policy_stmt.go @@ -1,6 +1,8 @@ package ast type CreatePolicyStmt struct { + Tag NodeTag[CreatePolicyStmt] `json:"tag"` + PolicyName *string Table *RangeVar CmdName *string diff --git a/internal/sql/ast/create_publication_stmt.go b/internal/sql/ast/create_publication_stmt.go index 5d0b6a05f5..562d3c0c90 100644 --- a/internal/sql/ast/create_publication_stmt.go +++ b/internal/sql/ast/create_publication_stmt.go @@ -1,6 +1,8 @@ package ast type CreatePublicationStmt struct { + Tag NodeTag[CreatePublicationStmt] `json:"tag"` + Pubname *string Options *List Tables *List diff --git a/internal/sql/ast/create_range_stmt.go b/internal/sql/ast/create_range_stmt.go index 6e0aaa5092..1b1173d9c4 100644 --- a/internal/sql/ast/create_range_stmt.go +++ b/internal/sql/ast/create_range_stmt.go @@ -1,6 +1,8 @@ package ast type CreateRangeStmt struct { + Tag NodeTag[CreateRangeStmt] `json:"tag"` + TypeName *List Params *List } diff --git a/internal/sql/ast/create_role_stmt.go b/internal/sql/ast/create_role_stmt.go index 144540863e..815a41b05d 100644 --- a/internal/sql/ast/create_role_stmt.go +++ b/internal/sql/ast/create_role_stmt.go @@ -1,6 +1,8 @@ package ast type CreateRoleStmt struct { + Tag NodeTag[CreateRoleStmt] `json:"tag"` + StmtType RoleStmtType Role *string Options *List diff --git a/internal/sql/ast/create_schema_stmt.go b/internal/sql/ast/create_schema_stmt.go index 522f404ec4..46dee5035d 100644 --- a/internal/sql/ast/create_schema_stmt.go +++ b/internal/sql/ast/create_schema_stmt.go @@ -1,6 +1,8 @@ package ast type CreateSchemaStmt struct { + Tag NodeTag[CreateSchemaStmt] `json:"tag"` + Name *string SchemaElts *List Authrole *RoleSpec diff --git a/internal/sql/ast/create_seq_stmt.go b/internal/sql/ast/create_seq_stmt.go index f7b9ef564d..a194b669aa 100644 --- a/internal/sql/ast/create_seq_stmt.go +++ b/internal/sql/ast/create_seq_stmt.go @@ -1,6 +1,8 @@ package ast type CreateSeqStmt struct { + Tag NodeTag[CreateSeqStmt] `json:"tag"` + Sequence *RangeVar Options *List OwnerId Oid diff --git a/internal/sql/ast/create_stats_stmt.go b/internal/sql/ast/create_stats_stmt.go index 4bd64e162c..d34c13632b 100644 --- a/internal/sql/ast/create_stats_stmt.go +++ b/internal/sql/ast/create_stats_stmt.go @@ -1,6 +1,8 @@ package ast type CreateStatsStmt struct { + Tag NodeTag[CreateStatsStmt] `json:"tag"` + Defnames *List StatTypes *List Exprs *List diff --git a/internal/sql/ast/create_stmt.go b/internal/sql/ast/create_stmt.go index 7982b690a2..0fb58fadf8 100644 --- a/internal/sql/ast/create_stmt.go +++ b/internal/sql/ast/create_stmt.go @@ -1,6 +1,8 @@ package ast type CreateStmt struct { + Tag NodeTag[CreateStmt] `json:"tag"` + Relation *RangeVar TableElts *List InhRelations *List diff --git a/internal/sql/ast/create_subscription_stmt.go b/internal/sql/ast/create_subscription_stmt.go index 1d7d49c403..909feae12e 100644 --- a/internal/sql/ast/create_subscription_stmt.go +++ b/internal/sql/ast/create_subscription_stmt.go @@ -1,6 +1,8 @@ package ast type CreateSubscriptionStmt struct { + Tag NodeTag[CreateSubscriptionStmt] `json:"tag"` + Subname *string Conninfo *string Publication *List diff --git a/internal/sql/ast/create_table_as_stmt.go b/internal/sql/ast/create_table_as_stmt.go index 6dbf291de4..88183f1852 100644 --- a/internal/sql/ast/create_table_as_stmt.go +++ b/internal/sql/ast/create_table_as_stmt.go @@ -1,6 +1,8 @@ package ast type CreateTableAsStmt struct { + Tag NodeTag[CreateTableAsStmt] `json:"tag"` + Query Node Into *IntoClause Relkind ObjectType diff --git a/internal/sql/ast/create_table_space_stmt.go b/internal/sql/ast/create_table_space_stmt.go index 92951572d3..aab46db149 100644 --- a/internal/sql/ast/create_table_space_stmt.go +++ b/internal/sql/ast/create_table_space_stmt.go @@ -1,6 +1,8 @@ package ast type CreateTableSpaceStmt struct { + Tag NodeTag[CreateTableSpaceStmt] `json:"tag"` + Tablespacename *string Owner *RoleSpec Location *string diff --git a/internal/sql/ast/create_table_stmt.go b/internal/sql/ast/create_table_stmt.go index cd11c61fac..6f73e907f0 100644 --- a/internal/sql/ast/create_table_stmt.go +++ b/internal/sql/ast/create_table_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateTableStmt struct { + Tag NodeTag[CreateTableStmt] `json:"tag"` + IfNotExists bool Name *TableName Cols []*ColumnDef diff --git a/internal/sql/ast/create_transform_stmt.go b/internal/sql/ast/create_transform_stmt.go index ef83e2c49a..6fc67c78ef 100644 --- a/internal/sql/ast/create_transform_stmt.go +++ b/internal/sql/ast/create_transform_stmt.go @@ -1,6 +1,8 @@ package ast type CreateTransformStmt struct { + Tag NodeTag[CreateTransformStmt] `json:"tag"` + Replace bool TypeName *TypeName Lang *string diff --git a/internal/sql/ast/create_trig_stmt.go b/internal/sql/ast/create_trig_stmt.go index acecce084c..2851e4ad07 100644 --- a/internal/sql/ast/create_trig_stmt.go +++ b/internal/sql/ast/create_trig_stmt.go @@ -1,6 +1,8 @@ package ast type CreateTrigStmt struct { + Tag NodeTag[CreateTrigStmt] `json:"tag"` + Trigname *string Relation *RangeVar Funcname *List diff --git a/internal/sql/ast/create_user_mapping_stmt.go b/internal/sql/ast/create_user_mapping_stmt.go index f5fd41f76c..8a7a251ec1 100644 --- a/internal/sql/ast/create_user_mapping_stmt.go +++ b/internal/sql/ast/create_user_mapping_stmt.go @@ -1,6 +1,8 @@ package ast type CreateUserMappingStmt struct { + Tag NodeTag[CreateUserMappingStmt] `json:"tag"` + User *RoleSpec Servername *string IfNotExists bool diff --git a/internal/sql/ast/createdb_stmt.go b/internal/sql/ast/createdb_stmt.go index 114505862d..9d4eb82c91 100644 --- a/internal/sql/ast/createdb_stmt.go +++ b/internal/sql/ast/createdb_stmt.go @@ -1,6 +1,8 @@ package ast type CreatedbStmt struct { + Tag NodeTag[CreatedbStmt] `json:"tag"` + Dbname *string Options *List } diff --git a/internal/sql/ast/current_of_expr.go b/internal/sql/ast/current_of_expr.go index 88b457f8d2..103e11c9fe 100644 --- a/internal/sql/ast/current_of_expr.go +++ b/internal/sql/ast/current_of_expr.go @@ -1,6 +1,8 @@ package ast type CurrentOfExpr struct { + Tag NodeTag[CurrentOfExpr] `json:"tag"` + Xpr Node Cvarno Index CursorName *string diff --git a/internal/sql/ast/deallocate_stmt.go b/internal/sql/ast/deallocate_stmt.go index b11807b57b..46066dbecc 100644 --- a/internal/sql/ast/deallocate_stmt.go +++ b/internal/sql/ast/deallocate_stmt.go @@ -1,6 +1,8 @@ package ast type DeallocateStmt struct { + Tag NodeTag[DeallocateStmt] `json:"tag"` + Name *string } diff --git a/internal/sql/ast/declare_cursor_stmt.go b/internal/sql/ast/declare_cursor_stmt.go index 82b0e6a2e0..8e2b634c13 100644 --- a/internal/sql/ast/declare_cursor_stmt.go +++ b/internal/sql/ast/declare_cursor_stmt.go @@ -1,6 +1,8 @@ package ast type DeclareCursorStmt struct { + Tag NodeTag[DeclareCursorStmt] `json:"tag"` + Portalname *string Options int Query Node diff --git a/internal/sql/ast/def_elem.go b/internal/sql/ast/def_elem.go index 33aacaaa03..c3219a1691 100644 --- a/internal/sql/ast/def_elem.go +++ b/internal/sql/ast/def_elem.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type DefElem struct { + Tag NodeTag[DefElem] `json:"tag"` + Defnamespace *string Defname *string Arg Node diff --git a/internal/sql/ast/define_stmt.go b/internal/sql/ast/define_stmt.go index 3860183d7e..76266ac9c7 100644 --- a/internal/sql/ast/define_stmt.go +++ b/internal/sql/ast/define_stmt.go @@ -1,6 +1,8 @@ package ast type DefineStmt struct { + Tag NodeTag[DefineStmt] `json:"tag"` + Kind ObjectType Oldstyle bool Defnames *List diff --git a/internal/sql/ast/delete_stmt.go b/internal/sql/ast/delete_stmt.go index 318713ad6c..8919b0e367 100644 --- a/internal/sql/ast/delete_stmt.go +++ b/internal/sql/ast/delete_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type DeleteStmt struct { + Tag NodeTag[DeleteStmt] `json:"tag"` + Relations *List UsingClause *List WhereClause Node diff --git a/internal/sql/ast/discard_stmt.go b/internal/sql/ast/discard_stmt.go index 9c731df1fb..cc5b9c55f2 100644 --- a/internal/sql/ast/discard_stmt.go +++ b/internal/sql/ast/discard_stmt.go @@ -1,6 +1,8 @@ package ast type DiscardStmt struct { + Tag NodeTag[DiscardStmt] `json:"tag"` + Target DiscardMode } diff --git a/internal/sql/ast/do_stmt.go b/internal/sql/ast/do_stmt.go index 9becfb8e64..57e51246ff 100644 --- a/internal/sql/ast/do_stmt.go +++ b/internal/sql/ast/do_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type DoStmt struct { + Tag NodeTag[DoStmt] `json:"tag"` + Args *List } diff --git a/internal/sql/ast/drop_function_stmt.go b/internal/sql/ast/drop_function_stmt.go index c1b10b95c1..9ae735cbec 100644 --- a/internal/sql/ast/drop_function_stmt.go +++ b/internal/sql/ast/drop_function_stmt.go @@ -1,6 +1,8 @@ package ast type DropFunctionStmt struct { + Tag NodeTag[DropFunctionStmt] `json:"tag"` + Funcs []*FuncSpec MissingOk bool } diff --git a/internal/sql/ast/drop_owned_stmt.go b/internal/sql/ast/drop_owned_stmt.go index 5826c33bbc..f48fd0f3fa 100644 --- a/internal/sql/ast/drop_owned_stmt.go +++ b/internal/sql/ast/drop_owned_stmt.go @@ -1,6 +1,8 @@ package ast type DropOwnedStmt struct { + Tag NodeTag[DropOwnedStmt] `json:"tag"` + Roles *List Behavior DropBehavior } diff --git a/internal/sql/ast/drop_role_stmt.go b/internal/sql/ast/drop_role_stmt.go index 95bd26a671..2640fd8ad0 100644 --- a/internal/sql/ast/drop_role_stmt.go +++ b/internal/sql/ast/drop_role_stmt.go @@ -1,6 +1,8 @@ package ast type DropRoleStmt struct { + Tag NodeTag[DropRoleStmt] `json:"tag"` + Roles *List MissingOk bool } diff --git a/internal/sql/ast/drop_schema_stmt.go b/internal/sql/ast/drop_schema_stmt.go index 8b7bad5180..b9afdbab55 100644 --- a/internal/sql/ast/drop_schema_stmt.go +++ b/internal/sql/ast/drop_schema_stmt.go @@ -1,6 +1,8 @@ package ast type DropSchemaStmt struct { + Tag NodeTag[DropSchemaStmt] `json:"tag"` + Schemas []*String MissingOk bool } diff --git a/internal/sql/ast/drop_stmt.go b/internal/sql/ast/drop_stmt.go index 9bb7d649a0..fa6a02e1fe 100644 --- a/internal/sql/ast/drop_stmt.go +++ b/internal/sql/ast/drop_stmt.go @@ -1,6 +1,8 @@ package ast type DropStmt struct { + Tag NodeTag[DropStmt] `json:"tag"` + Objects *List RemoveType ObjectType Behavior DropBehavior diff --git a/internal/sql/ast/drop_subscription_stmt.go b/internal/sql/ast/drop_subscription_stmt.go index 7b8b025ac6..d4656dce41 100644 --- a/internal/sql/ast/drop_subscription_stmt.go +++ b/internal/sql/ast/drop_subscription_stmt.go @@ -1,6 +1,8 @@ package ast type DropSubscriptionStmt struct { + Tag NodeTag[DropSubscriptionStmt] `json:"tag"` + Subname *string MissingOk bool Behavior DropBehavior diff --git a/internal/sql/ast/drop_table_space_stmt.go b/internal/sql/ast/drop_table_space_stmt.go index bf96094d80..26d0dd1959 100644 --- a/internal/sql/ast/drop_table_space_stmt.go +++ b/internal/sql/ast/drop_table_space_stmt.go @@ -1,6 +1,8 @@ package ast type DropTableSpaceStmt struct { + Tag NodeTag[DropTableSpaceStmt] `json:"tag"` + Tablespacename *string MissingOk bool } diff --git a/internal/sql/ast/drop_table_stmt.go b/internal/sql/ast/drop_table_stmt.go index 7485ceb887..f4343e768f 100644 --- a/internal/sql/ast/drop_table_stmt.go +++ b/internal/sql/ast/drop_table_stmt.go @@ -1,6 +1,8 @@ package ast type DropTableStmt struct { + Tag NodeTag[DropTableStmt] `json:"tag"` + IfExists bool Tables []*TableName } diff --git a/internal/sql/ast/drop_type_stmt.go b/internal/sql/ast/drop_type_stmt.go index 3aa0401b19..3de5234a2f 100644 --- a/internal/sql/ast/drop_type_stmt.go +++ b/internal/sql/ast/drop_type_stmt.go @@ -1,6 +1,8 @@ package ast type DropTypeStmt struct { + Tag NodeTag[DropTypeStmt] `json:"tag"` + IfExists bool Types []*TypeName } diff --git a/internal/sql/ast/drop_user_mapping_stmt.go b/internal/sql/ast/drop_user_mapping_stmt.go index f5852c708f..bf9cb4b36a 100644 --- a/internal/sql/ast/drop_user_mapping_stmt.go +++ b/internal/sql/ast/drop_user_mapping_stmt.go @@ -1,6 +1,8 @@ package ast type DropUserMappingStmt struct { + Tag NodeTag[DropUserMappingStmt] `json:"tag"` + User *RoleSpec Servername *string MissingOk bool diff --git a/internal/sql/ast/dropdb_stmt.go b/internal/sql/ast/dropdb_stmt.go index 62a0c47346..1577c1f6e5 100644 --- a/internal/sql/ast/dropdb_stmt.go +++ b/internal/sql/ast/dropdb_stmt.go @@ -1,6 +1,8 @@ package ast type DropdbStmt struct { + Tag NodeTag[DropdbStmt] `json:"tag"` + Dbname *string MissingOk bool } diff --git a/internal/sql/ast/execute_stmt.go b/internal/sql/ast/execute_stmt.go index 92a237141d..31e267c8c9 100644 --- a/internal/sql/ast/execute_stmt.go +++ b/internal/sql/ast/execute_stmt.go @@ -1,6 +1,8 @@ package ast type ExecuteStmt struct { + Tag NodeTag[ExecuteStmt] `json:"tag"` + Name *string Params *List } diff --git a/internal/sql/ast/explain_stmt.go b/internal/sql/ast/explain_stmt.go index 1d78aa815a..c25d97cb31 100644 --- a/internal/sql/ast/explain_stmt.go +++ b/internal/sql/ast/explain_stmt.go @@ -1,6 +1,8 @@ package ast type ExplainStmt struct { + Tag NodeTag[ExplainStmt] `json:"tag"` + Query Node Options *List } 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..72ad5ba65b 100644 --- a/internal/sql/ast/fetch_stmt.go +++ b/internal/sql/ast/fetch_stmt.go @@ -1,6 +1,8 @@ package ast type FetchStmt struct { + Tag NodeTag[FetchStmt] `json:"tag"` + Direction FetchDirection HowMany int64 Portalname *string diff --git a/internal/sql/ast/field_select.go b/internal/sql/ast/field_select.go index 347abd44bf..b6c36594bd 100644 --- a/internal/sql/ast/field_select.go +++ b/internal/sql/ast/field_select.go @@ -1,6 +1,8 @@ package ast type FieldSelect struct { + Tag NodeTag[FieldSelect] `json:"tag"` + Xpr Node Arg Node Fieldnum AttrNumber diff --git a/internal/sql/ast/field_store.go b/internal/sql/ast/field_store.go index 6c2cfc230c..29a00aa25a 100644 --- a/internal/sql/ast/field_store.go +++ b/internal/sql/ast/field_store.go @@ -1,6 +1,8 @@ package ast type FieldStore struct { + Tag NodeTag[FieldStore] `json:"tag"` + Xpr Node Arg Node Newvals *List diff --git a/internal/sql/ast/float.go b/internal/sql/ast/float.go index 94e8c2652f..2b29dbee87 100644 --- a/internal/sql/ast/float.go +++ b/internal/sql/ast/float.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type Float struct { + Tag NodeTag[Float] `json:"tag"` + Str string } diff --git a/internal/sql/ast/from_expr.go b/internal/sql/ast/from_expr.go index deb93da4a4..df74c9a98b 100644 --- a/internal/sql/ast/from_expr.go +++ b/internal/sql/ast/from_expr.go @@ -1,6 +1,8 @@ package ast type FromExpr struct { + Tag NodeTag[FromExpr] `json:"tag"` + Fromlist *List Quals Node } diff --git a/internal/sql/ast/func_call.go b/internal/sql/ast/func_call.go index cb4f210fe4..a38a15ee8e 100644 --- a/internal/sql/ast/func_call.go +++ b/internal/sql/ast/func_call.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncCall struct { + Tag NodeTag[FuncCall] `json:"tag"` + Func *FuncName Funcname *List Args *List diff --git a/internal/sql/ast/func_expr.go b/internal/sql/ast/func_expr.go index e571a63049..cb580a472d 100644 --- a/internal/sql/ast/func_expr.go +++ b/internal/sql/ast/func_expr.go @@ -1,6 +1,8 @@ package ast type FuncExpr struct { + Tag NodeTag[FuncExpr] `json:"tag"` + Xpr Node Funcid Oid Funcresulttype Oid diff --git a/internal/sql/ast/func_name.go b/internal/sql/ast/func_name.go index cdf3e23d33..58f32de754 100644 --- a/internal/sql/ast/func_name.go +++ b/internal/sql/ast/func_name.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncName struct { + Tag NodeTag[FuncName] `json:"tag"` + Catalog string Schema string Name string diff --git a/internal/sql/ast/func_param.go b/internal/sql/ast/func_param.go index 5881a1441f..9a95c40da9 100644 --- a/internal/sql/ast/func_param.go +++ b/internal/sql/ast/func_param.go @@ -14,6 +14,8 @@ const ( ) type FuncParam struct { + Tag NodeTag[FuncParam] `json:"tag"` + Name *string Type *TypeName DefExpr Node // Will always be &ast.TODO diff --git a/internal/sql/ast/func_spec.go b/internal/sql/ast/func_spec.go index f9d4bb40c6..bad51b9c81 100644 --- a/internal/sql/ast/func_spec.go +++ b/internal/sql/ast/func_spec.go @@ -1,6 +1,8 @@ package ast type FuncSpec struct { + Tag NodeTag[FuncSpec] `json:"tag"` + Name *FuncName Args []*TypeName HasArgs bool diff --git a/internal/sql/ast/function_parameter.go b/internal/sql/ast/function_parameter.go index 54262f6130..433ebfbb35 100644 --- a/internal/sql/ast/function_parameter.go +++ b/internal/sql/ast/function_parameter.go @@ -1,6 +1,8 @@ package ast type FunctionParameter struct { + Tag NodeTag[FunctionParameter] `json:"tag"` + Name *string ArgType *TypeName Mode FunctionParameterMode diff --git a/internal/sql/ast/grant_role_stmt.go b/internal/sql/ast/grant_role_stmt.go index 5e0b2a8e87..e6ca89b339 100644 --- a/internal/sql/ast/grant_role_stmt.go +++ b/internal/sql/ast/grant_role_stmt.go @@ -1,6 +1,8 @@ package ast type GrantRoleStmt struct { + Tag NodeTag[GrantRoleStmt] `json:"tag"` + GrantedRoles *List GranteeRoles *List IsGrant bool diff --git a/internal/sql/ast/grant_stmt.go b/internal/sql/ast/grant_stmt.go index cbed7911ac..b25f82630c 100644 --- a/internal/sql/ast/grant_stmt.go +++ b/internal/sql/ast/grant_stmt.go @@ -1,6 +1,8 @@ package ast type GrantStmt struct { + Tag NodeTag[GrantStmt] `json:"tag"` + IsGrant bool Targtype GrantTargetType Objtype GrantObjectType diff --git a/internal/sql/ast/grouping_func.go b/internal/sql/ast/grouping_func.go index 059bfb9dec..1c9eb6b1de 100644 --- a/internal/sql/ast/grouping_func.go +++ b/internal/sql/ast/grouping_func.go @@ -1,6 +1,8 @@ package ast type GroupingFunc struct { + Tag NodeTag[GroupingFunc] `json:"tag"` + Xpr Node Args *List Refs *List diff --git a/internal/sql/ast/grouping_set.go b/internal/sql/ast/grouping_set.go index 32db38a607..084179efed 100644 --- a/internal/sql/ast/grouping_set.go +++ b/internal/sql/ast/grouping_set.go @@ -1,6 +1,8 @@ package ast type GroupingSet struct { + Tag NodeTag[GroupingSet] `json:"tag"` + Kind GroupingSetKind Content *List Location int diff --git a/internal/sql/ast/import_foreign_schema_stmt.go b/internal/sql/ast/import_foreign_schema_stmt.go index 6b333f665b..25fa4ef2cd 100644 --- a/internal/sql/ast/import_foreign_schema_stmt.go +++ b/internal/sql/ast/import_foreign_schema_stmt.go @@ -1,6 +1,8 @@ package ast type ImportForeignSchemaStmt struct { + Tag NodeTag[ImportForeignSchemaStmt] `json:"tag"` + ServerName *string RemoteSchema *string LocalSchema *string diff --git a/internal/sql/ast/in.go b/internal/sql/ast/in.go index 9bdad67eeb..c3d0a0d692 100644 --- a/internal/sql/ast/in.go +++ b/internal/sql/ast/in.go @@ -4,6 +4,8 @@ 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 // List is the list expression in compare list. diff --git a/internal/sql/ast/index_elem.go b/internal/sql/ast/index_elem.go index acc2a7fc23..d6f5c7d8d0 100644 --- a/internal/sql/ast/index_elem.go +++ b/internal/sql/ast/index_elem.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type IndexElem struct { + Tag NodeTag[IndexElem] `json:"tag"` + Name *string Expr Node Indexcolname *string diff --git a/internal/sql/ast/index_stmt.go b/internal/sql/ast/index_stmt.go index fe0f03593c..b4d96d2fd4 100644 --- a/internal/sql/ast/index_stmt.go +++ b/internal/sql/ast/index_stmt.go @@ -1,6 +1,8 @@ package ast type IndexStmt struct { + Tag NodeTag[IndexStmt] `json:"tag"` + Idxname *string Relation *RangeVar AccessMethod *string diff --git a/internal/sql/ast/infer_clause.go b/internal/sql/ast/infer_clause.go index 6df0db4a86..709b602395 100644 --- a/internal/sql/ast/infer_clause.go +++ b/internal/sql/ast/infer_clause.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type InferClause struct { + Tag NodeTag[InferClause] `json:"tag"` + IndexElems *List WhereClause Node Conname *string diff --git a/internal/sql/ast/inference_elem.go b/internal/sql/ast/inference_elem.go index d7b4e091c2..d9af3cb713 100644 --- a/internal/sql/ast/inference_elem.go +++ b/internal/sql/ast/inference_elem.go @@ -1,6 +1,8 @@ package ast type InferenceElem struct { + Tag NodeTag[InferenceElem] `json:"tag"` + Xpr Node Expr Node Infercollid Oid diff --git a/internal/sql/ast/inline_code_block.go b/internal/sql/ast/inline_code_block.go index 91aebcc2e8..be7bf53c31 100644 --- a/internal/sql/ast/inline_code_block.go +++ b/internal/sql/ast/inline_code_block.go @@ -1,6 +1,8 @@ package ast type InlineCodeBlock struct { + Tag NodeTag[InlineCodeBlock] `json:"tag"` + SourceText *string LangOid Oid LangIsTrusted bool diff --git a/internal/sql/ast/insert_stmt.go b/internal/sql/ast/insert_stmt.go index 6ba9988413..90329d0c3b 100644 --- a/internal/sql/ast/insert_stmt.go +++ b/internal/sql/ast/insert_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type InsertStmt struct { + Tag NodeTag[InsertStmt] `json:"tag"` + Relation *RangeVar Cols *List SelectStmt Node diff --git a/internal/sql/ast/integer.go b/internal/sql/ast/integer.go index c0c360f2f2..45481f5c09 100644 --- a/internal/sql/ast/integer.go +++ b/internal/sql/ast/integer.go @@ -7,6 +7,8 @@ import ( ) type Integer struct { + Tag NodeTag[Integer] `json:"tag"` + Ival int64 } diff --git a/internal/sql/ast/interval_expr.go b/internal/sql/ast/interval_expr.go index dac73a0557..4bd191d505 100644 --- a/internal/sql/ast/interval_expr.go +++ b/internal/sql/ast/interval_expr.go @@ -4,6 +4,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // IntervalExpr represents a MySQL INTERVAL expression like "INTERVAL 1 DAY" type IntervalExpr struct { + Tag NodeTag[IntervalExpr] `json:"tag"` + Value Node Unit string Location int diff --git a/internal/sql/ast/into_clause.go b/internal/sql/ast/into_clause.go index e460b65ea0..ec28a7fd63 100644 --- a/internal/sql/ast/into_clause.go +++ b/internal/sql/ast/into_clause.go @@ -1,6 +1,8 @@ package ast type IntoClause struct { + Tag NodeTag[IntoClause] `json:"tag"` + Rel *RangeVar ColNames *List Options *List diff --git a/internal/sql/ast/join_expr.go b/internal/sql/ast/join_expr.go index a6bd132d7c..3713f82751 100644 --- a/internal/sql/ast/join_expr.go +++ b/internal/sql/ast/join_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type JoinExpr struct { + Tag NodeTag[JoinExpr] `json:"tag"` + Jointype JoinType IsNatural bool Larg Node diff --git a/internal/sql/ast/list.go b/internal/sql/ast/list.go index 3bb9d90dcd..0a061bbd60 100644 --- a/internal/sql/ast/list.go +++ b/internal/sql/ast/list.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type List struct { + Tag NodeTag[List] `json:"tag"` + Items []Node } diff --git a/internal/sql/ast/listen_stmt.go b/internal/sql/ast/listen_stmt.go index 48c38419a8..ef33ab1903 100644 --- a/internal/sql/ast/listen_stmt.go +++ b/internal/sql/ast/listen_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ListenStmt struct { + Tag NodeTag[ListenStmt] `json:"tag"` + Conditionname *string } diff --git a/internal/sql/ast/load_stmt.go b/internal/sql/ast/load_stmt.go index 1a211fc11a..0ac3335156 100644 --- a/internal/sql/ast/load_stmt.go +++ b/internal/sql/ast/load_stmt.go @@ -1,6 +1,8 @@ package ast type LoadStmt struct { + Tag NodeTag[LoadStmt] `json:"tag"` + Filename *string } diff --git a/internal/sql/ast/lock_stmt.go b/internal/sql/ast/lock_stmt.go index 70ec64dce3..13b84fc8aa 100644 --- a/internal/sql/ast/lock_stmt.go +++ b/internal/sql/ast/lock_stmt.go @@ -1,6 +1,8 @@ package ast type LockStmt struct { + Tag NodeTag[LockStmt] `json:"tag"` + Relations *List Mode int Nowait bool diff --git a/internal/sql/ast/locking_clause.go b/internal/sql/ast/locking_clause.go index 6202b4ae02..ca0c57eacc 100644 --- a/internal/sql/ast/locking_clause.go +++ b/internal/sql/ast/locking_clause.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type LockingClause struct { + Tag NodeTag[LockingClause] `json:"tag"` + LockedRels *List Strength LockClauseStrength WaitPolicy LockWaitPolicy diff --git a/internal/sql/ast/min_max_expr.go b/internal/sql/ast/min_max_expr.go index 8f0f7ea578..628ac8fcb7 100644 --- a/internal/sql/ast/min_max_expr.go +++ b/internal/sql/ast/min_max_expr.go @@ -1,6 +1,8 @@ package ast type MinMaxExpr struct { + Tag NodeTag[MinMaxExpr] `json:"tag"` + Xpr Node Minmaxtype Oid Minmaxcollid Oid diff --git a/internal/sql/ast/multi_assign_ref.go b/internal/sql/ast/multi_assign_ref.go index 94b783bcc1..68b25c99a7 100644 --- a/internal/sql/ast/multi_assign_ref.go +++ b/internal/sql/ast/multi_assign_ref.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type MultiAssignRef struct { + Tag NodeTag[MultiAssignRef] `json:"tag"` + Source Node Colno int Ncolumns int diff --git a/internal/sql/ast/named_arg_expr.go b/internal/sql/ast/named_arg_expr.go index a711fd2712..de7fcccdcd 100644 --- a/internal/sql/ast/named_arg_expr.go +++ b/internal/sql/ast/named_arg_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type NamedArgExpr struct { + Tag NodeTag[NamedArgExpr] `json:"tag"` + Xpr Node Arg Node Name *string diff --git a/internal/sql/ast/next_value_expr.go b/internal/sql/ast/next_value_expr.go index 050c090368..21c4034b29 100644 --- a/internal/sql/ast/next_value_expr.go +++ b/internal/sql/ast/next_value_expr.go @@ -1,6 +1,8 @@ package ast type NextValueExpr struct { + Tag NodeTag[NextValueExpr] `json:"tag"` + Xpr Node Seqid Oid TypeId Oid diff --git a/internal/sql/ast/node_tag.go b/internal/sql/ast/node_tag.go new file mode 100644 index 0000000000..55355892a6 --- /dev/null +++ b/internal/sql/ast/node_tag.go @@ -0,0 +1,41 @@ +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. A test checks +// that every node declares the field and that its type parameter matches. +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/node_tag_test.go b/internal/sql/ast/node_tag_test.go new file mode 100644 index 0000000000..a36fd071d0 --- /dev/null +++ b/internal/sql/ast/node_tag_test.go @@ -0,0 +1,92 @@ +package ast + +import ( + "go/ast" + "go/parser" + "go/token" + "strings" + "testing" +) + +// TestNodeTagFields guards the JSON encoding: every node struct must declare +// Tag NodeTag[T] as its first field with T naming the struct itself, and no +// node may declare another field that collides with the "tag" key. Nothing in +// the language enforces either — the field is copy-pasted between node files, +// so its type parameter can silently name the wrong node, and encoding/json +// matches field names case-insensitively on decode, so a second field named +// Tag would capture the tag string. +// +// This is a unit test because the invariant is about the declarations in this +// package, not about anything sqlc produces. No SQL input can exercise a node +// that has not been written yet, so the end-to-end tests cannot catch the day +// someone adds one without the field. +func TestNodeTagFields(t *testing.T) { + fset := token.NewFileSet() + pkgs, err := parser.ParseDir(fset, ".", nil, 0) + if err != nil { + t.Fatalf("parsing package: %s", err) + } + pkg := pkgs["ast"] + + // The node set: struct types with their own pointer-receiver Pos method. + nodes := map[string]bool{} + for _, file := range pkg.Files { + for _, decl := range file.Decls { + fn, ok := decl.(*ast.FuncDecl) + if !ok || fn.Name.Name != "Pos" || fn.Recv == nil { + continue + } + if star, ok := fn.Recv.List[0].Type.(*ast.StarExpr); ok { + if ident, ok := star.X.(*ast.Ident); ok { + nodes[ident.Name] = true + } + } + } + } + if len(nodes) == 0 { + t.Fatal("found no Pos methods; the test is broken") + } + + for _, file := range pkg.Files { + ast.Inspect(file, func(n ast.Node) bool { + spec, ok := n.(*ast.TypeSpec) + if !ok { + return true + } + structType, ok := spec.Type.(*ast.StructType) + if !ok || !nodes[spec.Name.Name] { + return true + } + name := spec.Name.Name + + fields := structType.Fields.List + if len(fields) == 0 || len(fields[0].Names) != 1 || fields[0].Names[0].Name != "Tag" { + t.Errorf("%s: first field must be Tag NodeTag[%s]", name, name) + return true + } + index, ok := fields[0].Type.(*ast.IndexExpr) + if !ok { + t.Errorf("%s: Tag field must have type NodeTag[%s]", name, name) + return true + } + base, _ := index.X.(*ast.Ident) + arg, _ := index.Index.(*ast.Ident) + if base == nil || base.Name != "NodeTag" || arg == nil { + t.Errorf("%s: Tag field must have type NodeTag[%s]", name, name) + return true + } + if arg.Name != name { + t.Errorf("%s: Tag field is NodeTag[%s]; its type parameter must name the containing struct", name, arg.Name) + } + + for _, field := range fields[1:] { + for _, fname := range field.Names { + if strings.EqualFold(fname.Name, "tag") { + t.Errorf("%s declares a second field %q, which collides with the tag field on JSON decode", name, fname.Name) + } + } + } + return true + }) + } +} diff --git a/internal/sql/ast/notify_stmt.go b/internal/sql/ast/notify_stmt.go index abecb94360..1ac9719d48 100644 --- a/internal/sql/ast/notify_stmt.go +++ b/internal/sql/ast/notify_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type NotifyStmt struct { + Tag NodeTag[NotifyStmt] `json:"tag"` + Conditionname *string Payload *string } 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..8ecdce15dd 100644 --- a/internal/sql/ast/null_test_expr.go +++ b/internal/sql/ast/null_test_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type NullTest struct { + Tag NodeTag[NullTest] `json:"tag"` + Xpr Node Arg Node Nulltesttype NullTestType diff --git a/internal/sql/ast/object_with_args.go b/internal/sql/ast/object_with_args.go index 5b5a1a8bd9..d1f5361671 100644 --- a/internal/sql/ast/object_with_args.go +++ b/internal/sql/ast/object_with_args.go @@ -1,6 +1,8 @@ package ast type ObjectWithArgs struct { + Tag NodeTag[ObjectWithArgs] `json:"tag"` + Objname *List Objargs *List ArgsUnspecified bool diff --git a/internal/sql/ast/on_conflict_clause.go b/internal/sql/ast/on_conflict_clause.go index 7e04c7ff52..934873fbe8 100644 --- a/internal/sql/ast/on_conflict_clause.go +++ b/internal/sql/ast/on_conflict_clause.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type OnConflictClause struct { + Tag NodeTag[OnConflictClause] `json:"tag"` + Action OnConflictAction Infer *InferClause TargetList *List diff --git a/internal/sql/ast/on_conflict_expr.go b/internal/sql/ast/on_conflict_expr.go index ae9659c754..c76f7794bd 100644 --- a/internal/sql/ast/on_conflict_expr.go +++ b/internal/sql/ast/on_conflict_expr.go @@ -1,6 +1,8 @@ package ast type OnConflictExpr struct { + Tag NodeTag[OnConflictExpr] `json:"tag"` + Action OnConflictAction ArbiterElems *List ArbiterWhere Node diff --git a/internal/sql/ast/on_duplicate_key_update.go b/internal/sql/ast/on_duplicate_key_update.go index a11ce1ab18..137681ef52 100644 --- a/internal/sql/ast/on_duplicate_key_update.go +++ b/internal/sql/ast/on_duplicate_key_update.go @@ -4,6 +4,8 @@ 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 diff --git a/internal/sql/ast/op_expr.go b/internal/sql/ast/op_expr.go index 0c7c21726e..55cd391b03 100644 --- a/internal/sql/ast/op_expr.go +++ b/internal/sql/ast/op_expr.go @@ -1,6 +1,8 @@ package ast type OpExpr struct { + Tag NodeTag[OpExpr] `json:"tag"` + Xpr Node Opno Oid Opresulttype Oid diff --git a/internal/sql/ast/param.go b/internal/sql/ast/param.go index 33220800bb..14a8c73ebc 100644 --- a/internal/sql/ast/param.go +++ b/internal/sql/ast/param.go @@ -1,6 +1,8 @@ package ast type Param struct { + Tag NodeTag[Param] `json:"tag"` + Xpr Node Paramkind ParamKind Paramid int diff --git a/internal/sql/ast/param_exec_data.go b/internal/sql/ast/param_exec_data.go index 0d8c3db9bf..9f032e0a94 100644 --- a/internal/sql/ast/param_exec_data.go +++ b/internal/sql/ast/param_exec_data.go @@ -1,6 +1,8 @@ package ast type ParamExecData struct { + Tag NodeTag[ParamExecData] `json:"tag"` + ExecPlan any Value Datum Isnull bool diff --git a/internal/sql/ast/param_extern_data.go b/internal/sql/ast/param_extern_data.go index a5d9bfcd49..c221a4bf8f 100644 --- a/internal/sql/ast/param_extern_data.go +++ b/internal/sql/ast/param_extern_data.go @@ -1,6 +1,8 @@ package ast type ParamExternData struct { + Tag NodeTag[ParamExternData] `json:"tag"` + Value Datum Isnull bool Pflags uint16 diff --git a/internal/sql/ast/param_list_info_data.go b/internal/sql/ast/param_list_info_data.go index a3fa0796e2..6ec93b100b 100644 --- a/internal/sql/ast/param_list_info_data.go +++ b/internal/sql/ast/param_list_info_data.go @@ -1,6 +1,8 @@ package ast type ParamListInfoData struct { + Tag NodeTag[ParamListInfoData] `json:"tag"` + ParamFetchArg any ParserSetupArg any NumParams int diff --git a/internal/sql/ast/param_ref.go b/internal/sql/ast/param_ref.go index 02c98f3dfb..c35bc4e49b 100644 --- a/internal/sql/ast/param_ref.go +++ b/internal/sql/ast/param_ref.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ParamRef struct { + Tag NodeTag[ParamRef] `json:"tag"` + Number int Location int Dollar bool diff --git a/internal/sql/ast/paren_expr.go b/internal/sql/ast/paren_expr.go index 831d461f3e..a0b580643d 100644 --- a/internal/sql/ast/paren_expr.go +++ b/internal/sql/ast/paren_expr.go @@ -4,6 +4,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" // ParenExpr represents a parenthesized expression type ParenExpr struct { + Tag NodeTag[ParenExpr] `json:"tag"` + Expr Node Location int } diff --git a/internal/sql/ast/partition_bound_spec.go b/internal/sql/ast/partition_bound_spec.go index fb4ada70af..e15fbbb7b7 100644 --- a/internal/sql/ast/partition_bound_spec.go +++ b/internal/sql/ast/partition_bound_spec.go @@ -1,6 +1,8 @@ package ast type PartitionBoundSpec struct { + Tag NodeTag[PartitionBoundSpec] `json:"tag"` + Strategy byte Listdatums *List Lowerdatums *List diff --git a/internal/sql/ast/partition_cmd.go b/internal/sql/ast/partition_cmd.go index 2deb30e998..c5d28b72f9 100644 --- a/internal/sql/ast/partition_cmd.go +++ b/internal/sql/ast/partition_cmd.go @@ -1,6 +1,8 @@ package ast type PartitionCmd struct { + Tag NodeTag[PartitionCmd] `json:"tag"` + Name *RangeVar Bound *PartitionBoundSpec } diff --git a/internal/sql/ast/partition_elem.go b/internal/sql/ast/partition_elem.go index b4be165d36..ba39e7d13c 100644 --- a/internal/sql/ast/partition_elem.go +++ b/internal/sql/ast/partition_elem.go @@ -1,6 +1,8 @@ package ast type PartitionElem struct { + Tag NodeTag[PartitionElem] `json:"tag"` + Name *string Expr Node Collation *List diff --git a/internal/sql/ast/partition_range_datum.go b/internal/sql/ast/partition_range_datum.go index 312437dd32..ae519716d8 100644 --- a/internal/sql/ast/partition_range_datum.go +++ b/internal/sql/ast/partition_range_datum.go @@ -1,6 +1,8 @@ package ast type PartitionRangeDatum struct { + Tag NodeTag[PartitionRangeDatum] `json:"tag"` + Kind PartitionRangeDatumKind Value Node Location int diff --git a/internal/sql/ast/partition_spec.go b/internal/sql/ast/partition_spec.go index 2918119e68..9a989a9581 100644 --- a/internal/sql/ast/partition_spec.go +++ b/internal/sql/ast/partition_spec.go @@ -1,6 +1,8 @@ package ast type PartitionSpec struct { + Tag NodeTag[PartitionSpec] `json:"tag"` + Strategy *string PartParams *List Location int diff --git a/internal/sql/ast/prepare_stmt.go b/internal/sql/ast/prepare_stmt.go index a088ac29b1..be91f3242e 100644 --- a/internal/sql/ast/prepare_stmt.go +++ b/internal/sql/ast/prepare_stmt.go @@ -1,6 +1,8 @@ package ast type PrepareStmt struct { + Tag NodeTag[PrepareStmt] `json:"tag"` + Name *string Argtypes *List Query Node diff --git a/internal/sql/ast/query.go b/internal/sql/ast/query.go index db25dfeb5d..257cdc8b84 100644 --- a/internal/sql/ast/query.go +++ b/internal/sql/ast/query.go @@ -1,6 +1,8 @@ package ast type Query struct { + Tag NodeTag[Query] `json:"tag"` + CommandType CmdType QuerySource QuerySource QueryId uint32 diff --git a/internal/sql/ast/range_function.go b/internal/sql/ast/range_function.go index dca63595d8..bcaf71ea9c 100644 --- a/internal/sql/ast/range_function.go +++ b/internal/sql/ast/range_function.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeFunction struct { + Tag NodeTag[RangeFunction] `json:"tag"` + Lateral bool Ordinality bool IsRowsfrom bool diff --git a/internal/sql/ast/range_subselect.go b/internal/sql/ast/range_subselect.go index 51a8825e2b..e90b87365a 100644 --- a/internal/sql/ast/range_subselect.go +++ b/internal/sql/ast/range_subselect.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeSubselect struct { + Tag NodeTag[RangeSubselect] `json:"tag"` + Lateral bool Subquery Node Alias *Alias diff --git a/internal/sql/ast/range_table_func.go b/internal/sql/ast/range_table_func.go index e53992edab..8ae783649d 100644 --- a/internal/sql/ast/range_table_func.go +++ b/internal/sql/ast/range_table_func.go @@ -1,6 +1,8 @@ package ast type RangeTableFunc struct { + Tag NodeTag[RangeTableFunc] `json:"tag"` + Lateral bool Docexpr Node Rowexpr Node diff --git a/internal/sql/ast/range_table_func_col.go b/internal/sql/ast/range_table_func_col.go index 2c06db1c08..aefd35d155 100644 --- a/internal/sql/ast/range_table_func_col.go +++ b/internal/sql/ast/range_table_func_col.go @@ -1,6 +1,8 @@ package ast type RangeTableFuncCol struct { + Tag NodeTag[RangeTableFuncCol] `json:"tag"` + Colname *string TypeName *TypeName ForOrdinality bool diff --git a/internal/sql/ast/range_table_sample.go b/internal/sql/ast/range_table_sample.go index c5fa2a2880..92c1900a9f 100644 --- a/internal/sql/ast/range_table_sample.go +++ b/internal/sql/ast/range_table_sample.go @@ -1,6 +1,8 @@ package ast type RangeTableSample struct { + Tag NodeTag[RangeTableSample] `json:"tag"` + Relation Node Method *List Args *List diff --git a/internal/sql/ast/range_tbl_entry.go b/internal/sql/ast/range_tbl_entry.go index be40e619b4..5a79d9c026 100644 --- a/internal/sql/ast/range_tbl_entry.go +++ b/internal/sql/ast/range_tbl_entry.go @@ -1,6 +1,8 @@ package ast type RangeTblEntry struct { + Tag NodeTag[RangeTblEntry] `json:"tag"` + Rtekind RTEKind Relid Oid Relkind byte diff --git a/internal/sql/ast/range_tbl_function.go b/internal/sql/ast/range_tbl_function.go index ee0e609f74..a77bdae6a8 100644 --- a/internal/sql/ast/range_tbl_function.go +++ b/internal/sql/ast/range_tbl_function.go @@ -1,6 +1,8 @@ package ast type RangeTblFunction struct { + Tag NodeTag[RangeTblFunction] `json:"tag"` + Funcexpr Node Funccolcount int Funccolnames *List diff --git a/internal/sql/ast/range_tbl_ref.go b/internal/sql/ast/range_tbl_ref.go index de537568de..20951e062d 100644 --- a/internal/sql/ast/range_tbl_ref.go +++ b/internal/sql/ast/range_tbl_ref.go @@ -1,6 +1,8 @@ package ast type RangeTblRef struct { + Tag NodeTag[RangeTblRef] `json:"tag"` + Rtindex int } diff --git a/internal/sql/ast/range_var.go b/internal/sql/ast/range_var.go index 250b2b3bbf..24b0e13214 100644 --- a/internal/sql/ast/range_var.go +++ b/internal/sql/ast/range_var.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeVar struct { + Tag NodeTag[RangeVar] `json:"tag"` + Catalogname *string Schemaname *string Relname *string diff --git a/internal/sql/ast/raw_stmt.go b/internal/sql/ast/raw_stmt.go index 619b844244..a037d93cbd 100644 --- a/internal/sql/ast/raw_stmt.go +++ b/internal/sql/ast/raw_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RawStmt struct { + Tag NodeTag[RawStmt] `json:"tag"` + Stmt Node StmtLocation int StmtLen int diff --git a/internal/sql/ast/reassign_owned_stmt.go b/internal/sql/ast/reassign_owned_stmt.go index 9162131f46..53f5306fe0 100644 --- a/internal/sql/ast/reassign_owned_stmt.go +++ b/internal/sql/ast/reassign_owned_stmt.go @@ -1,6 +1,8 @@ package ast type ReassignOwnedStmt struct { + Tag NodeTag[ReassignOwnedStmt] `json:"tag"` + Roles *List Newrole *RoleSpec } diff --git a/internal/sql/ast/refresh_mat_view_stmt.go b/internal/sql/ast/refresh_mat_view_stmt.go index f627e7bf21..058ffa86de 100644 --- a/internal/sql/ast/refresh_mat_view_stmt.go +++ b/internal/sql/ast/refresh_mat_view_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RefreshMatViewStmt struct { + Tag NodeTag[RefreshMatViewStmt] `json:"tag"` + Concurrent bool SkipData bool Relation *RangeVar diff --git a/internal/sql/ast/reindex_stmt.go b/internal/sql/ast/reindex_stmt.go index 9d33d490fe..52e33be7ea 100644 --- a/internal/sql/ast/reindex_stmt.go +++ b/internal/sql/ast/reindex_stmt.go @@ -1,6 +1,8 @@ package ast type ReindexStmt struct { + Tag NodeTag[ReindexStmt] `json:"tag"` + Kind ReindexObjectType Relation *RangeVar Name *string diff --git a/internal/sql/ast/relabel_type.go b/internal/sql/ast/relabel_type.go index e30e93184e..eccb6819e3 100644 --- a/internal/sql/ast/relabel_type.go +++ b/internal/sql/ast/relabel_type.go @@ -1,6 +1,8 @@ package ast type RelabelType struct { + Tag NodeTag[RelabelType] `json:"tag"` + Xpr Node Arg Node Resulttype Oid diff --git a/internal/sql/ast/rename_column_stmt.go b/internal/sql/ast/rename_column_stmt.go index 498b89d6ef..2164c2b2d7 100644 --- a/internal/sql/ast/rename_column_stmt.go +++ b/internal/sql/ast/rename_column_stmt.go @@ -1,6 +1,8 @@ package ast type RenameColumnStmt struct { + Tag NodeTag[RenameColumnStmt] `json:"tag"` + Table *TableName Col *ColumnRef NewName *string diff --git a/internal/sql/ast/rename_stmt.go b/internal/sql/ast/rename_stmt.go index cb9c176324..c52adb42fd 100644 --- a/internal/sql/ast/rename_stmt.go +++ b/internal/sql/ast/rename_stmt.go @@ -1,6 +1,8 @@ package ast type RenameStmt struct { + Tag NodeTag[RenameStmt] `json:"tag"` + RenameType ObjectType RelationType ObjectType Relation *RangeVar diff --git a/internal/sql/ast/rename_table_stmt.go b/internal/sql/ast/rename_table_stmt.go index b879ddb0b7..6a2d53b825 100644 --- a/internal/sql/ast/rename_table_stmt.go +++ b/internal/sql/ast/rename_table_stmt.go @@ -1,6 +1,8 @@ package ast type RenameTableStmt struct { + Tag NodeTag[RenameTableStmt] `json:"tag"` + Table *TableName NewName *string MissingOk bool diff --git a/internal/sql/ast/rename_type_stmt.go b/internal/sql/ast/rename_type_stmt.go index 67472d02f2..0eaa0932be 100644 --- a/internal/sql/ast/rename_type_stmt.go +++ b/internal/sql/ast/rename_type_stmt.go @@ -1,6 +1,8 @@ package ast type RenameTypeStmt struct { + Tag NodeTag[RenameTypeStmt] `json:"tag"` + Type *TypeName NewName *string } diff --git a/internal/sql/ast/replica_identity_stmt.go b/internal/sql/ast/replica_identity_stmt.go index 2d4291597b..109218aa17 100644 --- a/internal/sql/ast/replica_identity_stmt.go +++ b/internal/sql/ast/replica_identity_stmt.go @@ -1,6 +1,8 @@ package ast type ReplicaIdentityStmt struct { + Tag NodeTag[ReplicaIdentityStmt] `json:"tag"` + IdentityType byte Name *string } diff --git a/internal/sql/ast/res_target.go b/internal/sql/ast/res_target.go index dc34879942..4afbdae02e 100644 --- a/internal/sql/ast/res_target.go +++ b/internal/sql/ast/res_target.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ResTarget struct { + Tag NodeTag[ResTarget] `json:"tag"` + Name *string Indirection *List Val Node diff --git a/internal/sql/ast/role_spec.go b/internal/sql/ast/role_spec.go index fba4cecf7d..0681e0377e 100644 --- a/internal/sql/ast/role_spec.go +++ b/internal/sql/ast/role_spec.go @@ -1,6 +1,8 @@ package ast type RoleSpec struct { + Tag NodeTag[RoleSpec] `json:"tag"` + Roletype RoleSpecType Rolename *string Location int diff --git a/internal/sql/ast/row_compare_expr.go b/internal/sql/ast/row_compare_expr.go index 884cc3420d..e7ef6dc4c2 100644 --- a/internal/sql/ast/row_compare_expr.go +++ b/internal/sql/ast/row_compare_expr.go @@ -1,6 +1,8 @@ package ast type RowCompareExpr struct { + Tag NodeTag[RowCompareExpr] `json:"tag"` + Xpr Node Rctype RowCompareType Opnos *List diff --git a/internal/sql/ast/row_expr.go b/internal/sql/ast/row_expr.go index 0f8578355a..6409a355a2 100644 --- a/internal/sql/ast/row_expr.go +++ b/internal/sql/ast/row_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type RowExpr struct { + Tag NodeTag[RowExpr] `json:"tag"` + Xpr Node Args *List RowTypeid Oid diff --git a/internal/sql/ast/row_mark_clause.go b/internal/sql/ast/row_mark_clause.go index 5f2f8fa2f2..d57f9aea2f 100644 --- a/internal/sql/ast/row_mark_clause.go +++ b/internal/sql/ast/row_mark_clause.go @@ -1,6 +1,8 @@ package ast type RowMarkClause struct { + Tag NodeTag[RowMarkClause] `json:"tag"` + Rti Index Strength LockClauseStrength WaitPolicy LockWaitPolicy diff --git a/internal/sql/ast/rule_stmt.go b/internal/sql/ast/rule_stmt.go index 5ed05a8c5f..0d3ad61958 100644 --- a/internal/sql/ast/rule_stmt.go +++ b/internal/sql/ast/rule_stmt.go @@ -1,6 +1,8 @@ package ast type RuleStmt struct { + Tag NodeTag[RuleStmt] `json:"tag"` + Relation *RangeVar Rulename *string WhereClause Node diff --git a/internal/sql/ast/scalar_array_op_expr.go b/internal/sql/ast/scalar_array_op_expr.go index b4f36548b3..3163fbd988 100644 --- a/internal/sql/ast/scalar_array_op_expr.go +++ b/internal/sql/ast/scalar_array_op_expr.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type ScalarArrayOpExpr struct { + Tag NodeTag[ScalarArrayOpExpr] `json:"tag"` + Xpr Node Opno Oid UseOr bool diff --git a/internal/sql/ast/sec_label_stmt.go b/internal/sql/ast/sec_label_stmt.go index 608edb733f..39e1df1c40 100644 --- a/internal/sql/ast/sec_label_stmt.go +++ b/internal/sql/ast/sec_label_stmt.go @@ -1,6 +1,8 @@ package ast type SecLabelStmt struct { + Tag NodeTag[SecLabelStmt] `json:"tag"` + Objtype ObjectType Object Node Provider *string diff --git a/internal/sql/ast/select_stmt.go b/internal/sql/ast/select_stmt.go index 226c110734..755647e829 100644 --- a/internal/sql/ast/select_stmt.go +++ b/internal/sql/ast/select_stmt.go @@ -5,6 +5,8 @@ import ( ) type SelectStmt struct { + Tag NodeTag[SelectStmt] `json:"tag"` + DistinctClause *List IntoClause *IntoClause TargetList *List diff --git a/internal/sql/ast/set_operation_stmt.go b/internal/sql/ast/set_operation_stmt.go index 9ab1950d1b..f96534903c 100644 --- a/internal/sql/ast/set_operation_stmt.go +++ b/internal/sql/ast/set_operation_stmt.go @@ -1,6 +1,8 @@ package ast type SetOperationStmt struct { + Tag NodeTag[SetOperationStmt] `json:"tag"` + Op SetOperation All bool Larg Node diff --git a/internal/sql/ast/set_to_default.go b/internal/sql/ast/set_to_default.go index c127d3bc77..cca5fbc7a7 100644 --- a/internal/sql/ast/set_to_default.go +++ b/internal/sql/ast/set_to_default.go @@ -1,6 +1,8 @@ package ast type SetToDefault struct { + Tag NodeTag[SetToDefault] `json:"tag"` + Xpr Node TypeId Oid TypeMod int32 diff --git a/internal/sql/ast/sort_by.go b/internal/sql/ast/sort_by.go index b8634b7d6d..de6c9eb2cc 100644 --- a/internal/sql/ast/sort_by.go +++ b/internal/sql/ast/sort_by.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type SortBy struct { + Tag NodeTag[SortBy] `json:"tag"` + Node Node SortbyDir SortByDir SortbyNulls SortByNulls diff --git a/internal/sql/ast/sort_group_clause.go b/internal/sql/ast/sort_group_clause.go index 775035d799..47395bf690 100644 --- a/internal/sql/ast/sort_group_clause.go +++ b/internal/sql/ast/sort_group_clause.go @@ -1,6 +1,8 @@ package ast type SortGroupClause struct { + Tag NodeTag[SortGroupClause] `json:"tag"` + TleSortGroupRef Index Eqop Oid Sortop Oid diff --git a/internal/sql/ast/sql_value_function.go b/internal/sql/ast/sql_value_function.go index 31bd008245..c4efd63df9 100644 --- a/internal/sql/ast/sql_value_function.go +++ b/internal/sql/ast/sql_value_function.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type SQLValueFunction struct { + Tag NodeTag[SQLValueFunction] `json:"tag"` + Xpr Node Op SQLValueFunctionOp Type Oid diff --git a/internal/sql/ast/statement.go b/internal/sql/ast/statement.go index 4d01d949ca..3668d4530d 100644 --- a/internal/sql/ast/statement.go +++ b/internal/sql/ast/statement.go @@ -1,6 +1,8 @@ package ast type Statement struct { + Tag NodeTag[Statement] `json:"tag"` + Raw *RawStmt } diff --git a/internal/sql/ast/string.go b/internal/sql/ast/string.go index d167ef4575..9ad7fde90c 100644 --- a/internal/sql/ast/string.go +++ b/internal/sql/ast/string.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type String struct { + Tag NodeTag[String] `json:"tag"` + Str string } diff --git a/internal/sql/ast/sub_link.go b/internal/sql/ast/sub_link.go index bfd3ded206..8645663f9d 100644 --- a/internal/sql/ast/sub_link.go +++ b/internal/sql/ast/sub_link.go @@ -16,6 +16,8 @@ const ( ) type SubLink struct { + Tag NodeTag[SubLink] `json:"tag"` + Xpr Node SubLinkType SubLinkType SubLinkId int diff --git a/internal/sql/ast/sub_plan.go b/internal/sql/ast/sub_plan.go index 2443e86c98..060ba9f28e 100644 --- a/internal/sql/ast/sub_plan.go +++ b/internal/sql/ast/sub_plan.go @@ -1,6 +1,8 @@ package ast type SubPlan struct { + Tag NodeTag[SubPlan] `json:"tag"` + Xpr Node SubLinkType SubLinkType Testexpr Node diff --git a/internal/sql/ast/table_func.go b/internal/sql/ast/table_func.go index 615ff82074..2d341da226 100644 --- a/internal/sql/ast/table_func.go +++ b/internal/sql/ast/table_func.go @@ -1,6 +1,8 @@ package ast type TableFunc struct { + Tag NodeTag[TableFunc] `json:"tag"` + NsUris *List NsNames *List Docexpr Node diff --git a/internal/sql/ast/table_like_clause.go b/internal/sql/ast/table_like_clause.go index 338065f3a2..54f68dbf25 100644 --- a/internal/sql/ast/table_like_clause.go +++ b/internal/sql/ast/table_like_clause.go @@ -1,6 +1,8 @@ package ast type TableLikeClause struct { + Tag NodeTag[TableLikeClause] `json:"tag"` + Relation *RangeVar Options uint32 } diff --git a/internal/sql/ast/table_name.go b/internal/sql/ast/table_name.go index 4f494a67e0..399faee295 100644 --- a/internal/sql/ast/table_name.go +++ b/internal/sql/ast/table_name.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TableName struct { + Tag NodeTag[TableName] `json:"tag"` + Catalog string Schema string Name string diff --git a/internal/sql/ast/table_sample_clause.go b/internal/sql/ast/table_sample_clause.go index b92f731430..c5e78f9796 100644 --- a/internal/sql/ast/table_sample_clause.go +++ b/internal/sql/ast/table_sample_clause.go @@ -1,6 +1,8 @@ package ast type TableSampleClause struct { + Tag NodeTag[TableSampleClause] `json:"tag"` + Tsmhandler Oid Args *List Repeatable Node diff --git a/internal/sql/ast/target_entry.go b/internal/sql/ast/target_entry.go index c9f72184e8..a35dcaa6b0 100644 --- a/internal/sql/ast/target_entry.go +++ b/internal/sql/ast/target_entry.go @@ -1,6 +1,8 @@ package ast type TargetEntry struct { + Tag NodeTag[TargetEntry] `json:"tag"` + Xpr Node Expr Node Resno AttrNumber 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..e22a2fb620 100644 --- a/internal/sql/ast/transaction_stmt.go +++ b/internal/sql/ast/transaction_stmt.go @@ -1,6 +1,8 @@ package ast type TransactionStmt struct { + Tag NodeTag[TransactionStmt] `json:"tag"` + Kind TransactionStmtKind Options *List Gid *string diff --git a/internal/sql/ast/trigger_transition.go b/internal/sql/ast/trigger_transition.go index 376745067a..a4e177b307 100644 --- a/internal/sql/ast/trigger_transition.go +++ b/internal/sql/ast/trigger_transition.go @@ -1,6 +1,8 @@ package ast type TriggerTransition struct { + Tag NodeTag[TriggerTransition] `json:"tag"` + Name *string IsNew bool IsTable bool diff --git a/internal/sql/ast/truncate_stmt.go b/internal/sql/ast/truncate_stmt.go index 6636e9f9e8..4d07c09ac7 100644 --- a/internal/sql/ast/truncate_stmt.go +++ b/internal/sql/ast/truncate_stmt.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TruncateStmt struct { + Tag NodeTag[TruncateStmt] `json:"tag"` + Relations *List RestartSeqs bool Behavior DropBehavior diff --git a/internal/sql/ast/type_cast.go b/internal/sql/ast/type_cast.go index fe5b321abf..299b9244dc 100644 --- a/internal/sql/ast/type_cast.go +++ b/internal/sql/ast/type_cast.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeCast struct { + Tag NodeTag[TypeCast] `json:"tag"` + Arg Node TypeName *TypeName Location int diff --git a/internal/sql/ast/type_name.go b/internal/sql/ast/type_name.go index 26ef4d6d2b..7fee688272 100644 --- a/internal/sql/ast/type_name.go +++ b/internal/sql/ast/type_name.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeName struct { + Tag NodeTag[TypeName] `json:"tag"` + Catalog string Schema string Name string diff --git a/internal/sql/ast/unlisten_stmt.go b/internal/sql/ast/unlisten_stmt.go index ca74e055f8..719b82ab21 100644 --- a/internal/sql/ast/unlisten_stmt.go +++ b/internal/sql/ast/unlisten_stmt.go @@ -1,6 +1,8 @@ package ast type UnlistenStmt struct { + Tag NodeTag[UnlistenStmt] `json:"tag"` + Conditionname *string } diff --git a/internal/sql/ast/update_stmt.go b/internal/sql/ast/update_stmt.go index 55775a6624..2eb5cca674 100644 --- a/internal/sql/ast/update_stmt.go +++ b/internal/sql/ast/update_stmt.go @@ -7,6 +7,8 @@ import ( ) type UpdateStmt struct { + Tag NodeTag[UpdateStmt] `json:"tag"` + Relations *List TargetList *List WhereClause Node diff --git a/internal/sql/ast/vacuum_stmt.go b/internal/sql/ast/vacuum_stmt.go index 942fb762b2..cf310a0943 100644 --- a/internal/sql/ast/vacuum_stmt.go +++ b/internal/sql/ast/vacuum_stmt.go @@ -1,6 +1,8 @@ package ast type VacuumStmt struct { + Tag NodeTag[VacuumStmt] `json:"tag"` + Options int Relation *RangeVar VaCols *List diff --git a/internal/sql/ast/var.go b/internal/sql/ast/var.go index 0d558180cb..7ba8835a7a 100644 --- a/internal/sql/ast/var.go +++ b/internal/sql/ast/var.go @@ -1,6 +1,8 @@ package ast type Var struct { + Tag NodeTag[Var] `json:"tag"` + Xpr Node Varno Index Varattno AttrNumber diff --git a/internal/sql/ast/variable_expr.go b/internal/sql/ast/variable_expr.go index 83223b482b..fb4b6c9faf 100644 --- a/internal/sql/ast/variable_expr.go +++ b/internal/sql/ast/variable_expr.go @@ -5,6 +5,8 @@ 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 { + Tag NodeTag[VariableExpr] `json:"tag"` + Name string Location int } diff --git a/internal/sql/ast/variable_set_stmt.go b/internal/sql/ast/variable_set_stmt.go index 9307152293..50c6e8f1c8 100644 --- a/internal/sql/ast/variable_set_stmt.go +++ b/internal/sql/ast/variable_set_stmt.go @@ -1,6 +1,8 @@ package ast type VariableSetStmt struct { + Tag NodeTag[VariableSetStmt] `json:"tag"` + Kind VariableSetKind Name *string Args *List diff --git a/internal/sql/ast/variable_show_stmt.go b/internal/sql/ast/variable_show_stmt.go index c1dc7e95ef..f0b518f9ec 100644 --- a/internal/sql/ast/variable_show_stmt.go +++ b/internal/sql/ast/variable_show_stmt.go @@ -1,6 +1,8 @@ package ast type VariableShowStmt struct { + Tag NodeTag[VariableShowStmt] `json:"tag"` + Name *string } diff --git a/internal/sql/ast/view_stmt.go b/internal/sql/ast/view_stmt.go index be93733f72..320c32c43e 100644 --- a/internal/sql/ast/view_stmt.go +++ b/internal/sql/ast/view_stmt.go @@ -1,6 +1,8 @@ package ast type ViewStmt struct { + Tag NodeTag[ViewStmt] `json:"tag"` + View *RangeVar Aliases *List Query Node diff --git a/internal/sql/ast/window_clause.go b/internal/sql/ast/window_clause.go index 0a2f082f01..68612605b2 100644 --- a/internal/sql/ast/window_clause.go +++ b/internal/sql/ast/window_clause.go @@ -1,6 +1,8 @@ package ast type WindowClause struct { + Tag NodeTag[WindowClause] `json:"tag"` + Name *string Refname *string PartitionClause *List diff --git a/internal/sql/ast/window_def.go b/internal/sql/ast/window_def.go index caba3e643c..2164a38773 100644 --- a/internal/sql/ast/window_def.go +++ b/internal/sql/ast/window_def.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type WindowDef struct { + Tag NodeTag[WindowDef] `json:"tag"` + Name *string Refname *string PartitionClause *List diff --git a/internal/sql/ast/window_func.go b/internal/sql/ast/window_func.go index eb0ba5c968..606848a9e1 100644 --- a/internal/sql/ast/window_func.go +++ b/internal/sql/ast/window_func.go @@ -1,6 +1,8 @@ package ast type WindowFunc struct { + Tag NodeTag[WindowFunc] `json:"tag"` + Xpr Node Winfnoid Oid Wintype Oid diff --git a/internal/sql/ast/with_check_option.go b/internal/sql/ast/with_check_option.go index b622db4753..9448b10631 100644 --- a/internal/sql/ast/with_check_option.go +++ b/internal/sql/ast/with_check_option.go @@ -1,6 +1,8 @@ package ast type WithCheckOption struct { + Tag NodeTag[WithCheckOption] `json:"tag"` + Kind WCOKind Relname *string Polname *string diff --git a/internal/sql/ast/with_clause.go b/internal/sql/ast/with_clause.go index a7d4b24903..a601970628 100644 --- a/internal/sql/ast/with_clause.go +++ b/internal/sql/ast/with_clause.go @@ -3,6 +3,8 @@ package ast import "github.com/sqlc-dev/sqlc/internal/sql/format" type WithClause struct { + Tag NodeTag[WithClause] `json:"tag"` + Ctes *List Recursive bool Location int diff --git a/internal/sql/ast/xml_expr.go b/internal/sql/ast/xml_expr.go index cbd82b3653..715e854530 100644 --- a/internal/sql/ast/xml_expr.go +++ b/internal/sql/ast/xml_expr.go @@ -1,6 +1,8 @@ package ast type XmlExpr struct { + Tag NodeTag[XmlExpr] `json:"tag"` + Xpr Node Op XmlExprOp Name *string diff --git a/internal/sql/ast/xml_serialize.go b/internal/sql/ast/xml_serialize.go index 32e4cc476d..0d06dd9d53 100644 --- a/internal/sql/ast/xml_serialize.go +++ b/internal/sql/ast/xml_serialize.go @@ -1,6 +1,8 @@ package ast type XmlSerialize struct { + Tag NodeTag[XmlSerialize] `json:"tag"` + Xmloption XmlOptionType Expr Node TypeName *TypeName From 4f101f1dd56639fc7285c5e968ed8100c4d0c3c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Aug 2026 03:46:22 +0000 Subject: [PATCH 2/4] ast: omit absent fields from JSON output Most of what parse printed was absent fields. On a four-query file, 25% of the keys were null and another 9% were empty containers, so reading an AST meant scanning past clauses the statement never had. Mark every pointer, slice, interface and map field of the node structs with json:",omitempty". Scalars keep no such tag on purpose: StmtLocation is 0 for the first statement in a file and LIMIT 0 parses to an Ival of 0, so omitting zero-valued scalars would lose what the parser found rather than what it did not. Field names are unchanged. Beyond nil fields this also drops empty lists, which is a small normalization: the dolphin converter builds Items as an empty slice where the postgresql one leaves it nil, so the same SQL printed different JSON per engine. Both now print as a bare tagged List. This depends on the type tags. Omitting a nil Items turns an empty List into "{}", which without a tag would be indistinguishable from A_Star and TODO. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01T9LCt1mwdY3mE14x3Zz5Vw --- docs/howto/parse.md | 21 ++++++++++ .../analyze_ast/postgresql/stdout.txt | 31 ++++----------- .../parse_basic/clickhouse/stdout.txt | 19 +--------- .../testdata/parse_basic/duckdb/stdout.txt | 19 +--------- .../testdata/parse_basic/googlesql/stdout.txt | 19 +--------- .../testdata/parse_basic/mssql/stdout.txt | 19 +--------- .../testdata/parse_basic/mysql/stdout.txt | 25 ++---------- .../parse_basic/postgresql/stdout.txt | 31 +++++---------- .../testdata/parse_basic/sqlite/stdout.txt | 27 +++---------- internal/sql/ast/a_array_expr.go | 2 +- internal/sql/ast/a_const.go | 2 +- internal/sql/ast/a_expr.go | 6 +-- internal/sql/ast/a_indices.go | 4 +- internal/sql/ast/a_indirection.go | 4 +- internal/sql/ast/access_priv.go | 4 +- internal/sql/ast/aggref.go | 14 +++---- internal/sql/ast/alias.go | 4 +- internal/sql/ast/alter_collation_stmt.go | 2 +- internal/sql/ast/alter_database_set_stmt.go | 4 +- internal/sql/ast/alter_database_stmt.go | 4 +- .../sql/ast/alter_default_privileges_stmt.go | 4 +- internal/sql/ast/alter_domain_stmt.go | 6 +-- internal/sql/ast/alter_enum_stmt.go | 8 ++-- internal/sql/ast/alter_event_trig_stmt.go | 2 +- .../sql/ast/alter_extension_contents_stmt.go | 4 +- internal/sql/ast/alter_extension_stmt.go | 4 +- internal/sql/ast/alter_fdw_stmt.go | 6 +-- internal/sql/ast/alter_foreign_server_stmt.go | 6 +-- internal/sql/ast/alter_function_stmt.go | 4 +- internal/sql/ast/alter_object_depends_stmt.go | 6 +-- internal/sql/ast/alter_object_schema_stmt.go | 6 +-- internal/sql/ast/alter_op_family_stmt.go | 6 +-- internal/sql/ast/alter_operator_stmt.go | 4 +- internal/sql/ast/alter_owner_stmt.go | 6 +-- internal/sql/ast/alter_policy_stmt.go | 10 ++--- internal/sql/ast/alter_publication_stmt.go | 6 +-- internal/sql/ast/alter_role_set_stmt.go | 6 +-- internal/sql/ast/alter_role_stmt.go | 4 +- internal/sql/ast/alter_seq_stmt.go | 4 +- internal/sql/ast/alter_subscription_stmt.go | 8 ++-- internal/sql/ast/alter_system_stmt.go | 2 +- internal/sql/ast/alter_table_cmd.go | 6 +-- internal/sql/ast/alter_table_move_all_stmt.go | 6 +-- .../sql/ast/alter_table_set_schema_stmt.go | 4 +- .../sql/ast/alter_table_space_options_stmt.go | 4 +- internal/sql/ast/alter_table_stmt.go | 6 +-- .../sql/ast/alter_ts_configuration_stmt.go | 6 +-- internal/sql/ast/alter_ts_dictionary_stmt.go | 4 +- internal/sql/ast/alter_type_add_value_stmt.go | 6 +-- .../sql/ast/alter_type_rename_value_stmt.go | 6 +-- .../sql/ast/alter_type_set_schema_stmt.go | 4 +- internal/sql/ast/alter_user_mapping_stmt.go | 6 +-- internal/sql/ast/alternative_sub_plan.go | 4 +- internal/sql/ast/array_coerce_expr.go | 4 +- internal/sql/ast/array_expr.go | 4 +- internal/sql/ast/array_ref.go | 10 ++--- internal/sql/ast/between_expr.go | 6 +-- internal/sql/ast/bool_expr.go | 4 +- internal/sql/ast/boolean_test_expr.go | 4 +- internal/sql/ast/call_stmt.go | 2 +- internal/sql/ast/case_expr.go | 8 ++-- internal/sql/ast/case_test_expr.go | 2 +- internal/sql/ast/case_when.go | 6 +-- internal/sql/ast/close_portal_stmt.go | 2 +- internal/sql/ast/cluster_stmt.go | 4 +- internal/sql/ast/coalesce_expr.go | 4 +- internal/sql/ast/coerce_to_domain.go | 4 +- internal/sql/ast/coerce_to_domain_value.go | 2 +- internal/sql/ast/coerce_via_io.go | 4 +- internal/sql/ast/collate_clause.go | 4 +- internal/sql/ast/collate_expr.go | 4 +- internal/sql/ast/column_def.go | 16 ++++---- internal/sql/ast/column_ref.go | 2 +- internal/sql/ast/comment.go | 4 +- internal/sql/ast/comment_on_column_stmt.go | 6 +-- internal/sql/ast/comment_on_schema_stmt.go | 4 +- internal/sql/ast/comment_on_table_stmt.go | 4 +- internal/sql/ast/comment_on_type_stmt.go | 4 +- internal/sql/ast/comment_on_view_stmt.go | 4 +- internal/sql/ast/comment_stmt.go | 4 +- internal/sql/ast/common_table_expr.go | 14 +++---- internal/sql/ast/composite_type_stmt.go | 2 +- internal/sql/ast/const.go | 2 +- internal/sql/ast/constraint.go | 28 +++++++------- internal/sql/ast/constraints_set_stmt.go | 2 +- internal/sql/ast/convert_rowtype_expr.go | 4 +- internal/sql/ast/copy_stmt.go | 10 ++--- internal/sql/ast/create_am_stmt.go | 4 +- internal/sql/ast/create_cast_stmt.go | 6 +-- internal/sql/ast/create_conversion_stmt.go | 8 ++-- internal/sql/ast/create_domain_stmt.go | 8 ++-- internal/sql/ast/create_enum_stmt.go | 4 +- internal/sql/ast/create_event_trig_stmt.go | 8 ++-- internal/sql/ast/create_extension_stmt.go | 4 +- internal/sql/ast/create_fdw_stmt.go | 6 +-- .../sql/ast/create_foreign_server_stmt.go | 10 ++--- internal/sql/ast/create_foreign_table_stmt.go | 6 +-- internal/sql/ast/create_function_stmt.go | 10 ++--- internal/sql/ast/create_op_class_item.go | 8 ++-- internal/sql/ast/create_op_class_stmt.go | 10 ++--- internal/sql/ast/create_op_family_stmt.go | 4 +- internal/sql/ast/create_p_lang_stmt.go | 8 ++-- internal/sql/ast/create_policy_stmt.go | 12 +++--- internal/sql/ast/create_publication_stmt.go | 6 +-- internal/sql/ast/create_range_stmt.go | 4 +- internal/sql/ast/create_role_stmt.go | 4 +- internal/sql/ast/create_schema_stmt.go | 6 +-- internal/sql/ast/create_seq_stmt.go | 4 +- internal/sql/ast/create_stats_stmt.go | 8 ++-- internal/sql/ast/create_stmt.go | 18 ++++----- internal/sql/ast/create_subscription_stmt.go | 8 ++-- internal/sql/ast/create_table_as_stmt.go | 4 +- internal/sql/ast/create_table_space_stmt.go | 8 ++-- internal/sql/ast/create_table_stmt.go | 10 ++--- internal/sql/ast/create_transform_stmt.go | 8 ++-- internal/sql/ast/create_trig_stmt.go | 16 ++++---- internal/sql/ast/create_user_mapping_stmt.go | 6 +-- internal/sql/ast/createdb_stmt.go | 4 +- internal/sql/ast/current_of_expr.go | 4 +- internal/sql/ast/deallocate_stmt.go | 2 +- internal/sql/ast/declare_cursor_stmt.go | 4 +- internal/sql/ast/def_elem.go | 6 +-- internal/sql/ast/define_stmt.go | 6 +-- internal/sql/ast/delete_stmt.go | 16 ++++---- internal/sql/ast/do_stmt.go | 2 +- internal/sql/ast/drop_function_stmt.go | 2 +- internal/sql/ast/drop_owned_stmt.go | 2 +- internal/sql/ast/drop_role_stmt.go | 2 +- internal/sql/ast/drop_schema_stmt.go | 2 +- internal/sql/ast/drop_stmt.go | 2 +- internal/sql/ast/drop_subscription_stmt.go | 2 +- internal/sql/ast/drop_table_space_stmt.go | 2 +- internal/sql/ast/drop_table_stmt.go | 2 +- internal/sql/ast/drop_type_stmt.go | 2 +- internal/sql/ast/drop_user_mapping_stmt.go | 4 +- internal/sql/ast/dropdb_stmt.go | 2 +- internal/sql/ast/execute_stmt.go | 4 +- internal/sql/ast/explain_stmt.go | 4 +- internal/sql/ast/fetch_stmt.go | 2 +- internal/sql/ast/field_select.go | 4 +- internal/sql/ast/field_store.go | 8 ++-- internal/sql/ast/from_expr.go | 4 +- internal/sql/ast/func_call.go | 14 +++---- internal/sql/ast/func_expr.go | 4 +- internal/sql/ast/func_param.go | 6 +-- internal/sql/ast/func_spec.go | 4 +- internal/sql/ast/function_parameter.go | 6 +-- internal/sql/ast/grant_role_stmt.go | 6 +-- internal/sql/ast/grant_stmt.go | 6 +-- internal/sql/ast/grouping_func.go | 8 ++-- internal/sql/ast/grouping_set.go | 2 +- .../sql/ast/import_foreign_schema_stmt.go | 10 ++--- internal/sql/ast/in.go | 6 +-- internal/sql/ast/index_elem.go | 10 ++--- internal/sql/ast/index_stmt.go | 18 ++++----- internal/sql/ast/infer_clause.go | 6 +-- internal/sql/ast/inference_elem.go | 4 +- internal/sql/ast/inline_code_block.go | 2 +- internal/sql/ast/insert_stmt.go | 14 +++---- internal/sql/ast/interval_expr.go | 2 +- internal/sql/ast/into_clause.go | 10 ++--- internal/sql/ast/join_expr.go | 10 ++--- internal/sql/ast/list.go | 2 +- internal/sql/ast/listen_stmt.go | 2 +- internal/sql/ast/load_stmt.go | 2 +- internal/sql/ast/lock_stmt.go | 2 +- internal/sql/ast/locking_clause.go | 2 +- internal/sql/ast/min_max_expr.go | 4 +- internal/sql/ast/multi_assign_ref.go | 2 +- internal/sql/ast/named_arg_expr.go | 6 +-- internal/sql/ast/next_value_expr.go | 2 +- internal/sql/ast/notify_stmt.go | 4 +- internal/sql/ast/null_test_expr.go | 4 +- internal/sql/ast/object_with_args.go | 4 +- internal/sql/ast/on_conflict_clause.go | 6 +-- internal/sql/ast/on_conflict_expr.go | 10 ++--- internal/sql/ast/on_duplicate_key_update.go | 2 +- internal/sql/ast/op_expr.go | 4 +- internal/sql/ast/param.go | 2 +- internal/sql/ast/param_exec_data.go | 2 +- internal/sql/ast/param_list_info_data.go | 6 +-- internal/sql/ast/paren_expr.go | 2 +- internal/sql/ast/partition_bound_spec.go | 6 +-- internal/sql/ast/partition_cmd.go | 4 +- internal/sql/ast/partition_elem.go | 8 ++-- internal/sql/ast/partition_range_datum.go | 2 +- internal/sql/ast/partition_spec.go | 4 +- internal/sql/ast/prepare_stmt.go | 6 +-- internal/sql/ast/query.go | 38 +++++++++---------- internal/sql/ast/range_function.go | 6 +-- internal/sql/ast/range_subselect.go | 4 +- internal/sql/ast/range_table_func.go | 10 ++--- internal/sql/ast/range_table_func_col.go | 8 ++-- internal/sql/ast/range_table_sample.go | 8 ++-- internal/sql/ast/range_tbl_entry.go | 34 ++++++++--------- internal/sql/ast/range_tbl_function.go | 12 +++--- internal/sql/ast/range_var.go | 8 ++-- internal/sql/ast/raw_stmt.go | 2 +- internal/sql/ast/reassign_owned_stmt.go | 4 +- internal/sql/ast/refresh_mat_view_stmt.go | 2 +- internal/sql/ast/reindex_stmt.go | 4 +- internal/sql/ast/relabel_type.go | 4 +- internal/sql/ast/rename_column_stmt.go | 6 +-- internal/sql/ast/rename_stmt.go | 8 ++-- internal/sql/ast/rename_table_stmt.go | 4 +- internal/sql/ast/rename_type_stmt.go | 4 +- internal/sql/ast/replica_identity_stmt.go | 2 +- internal/sql/ast/res_target.go | 6 +-- internal/sql/ast/role_spec.go | 2 +- internal/sql/ast/row_compare_expr.go | 12 +++--- internal/sql/ast/row_expr.go | 6 +-- internal/sql/ast/rule_stmt.go | 8 ++-- internal/sql/ast/scalar_array_op_expr.go | 4 +- internal/sql/ast/sec_label_stmt.go | 6 +-- internal/sql/ast/select_stmt.go | 32 ++++++++-------- internal/sql/ast/set_operation_stmt.go | 12 +++--- internal/sql/ast/set_to_default.go | 2 +- internal/sql/ast/sort_by.go | 4 +- internal/sql/ast/sql_value_function.go | 2 +- internal/sql/ast/statement.go | 2 +- internal/sql/ast/sub_link.go | 8 ++-- internal/sql/ast/sub_plan.go | 14 +++---- internal/sql/ast/table_func.go | 22 +++++------ internal/sql/ast/table_like_clause.go | 2 +- internal/sql/ast/table_sample_clause.go | 4 +- internal/sql/ast/target_entry.go | 6 +-- internal/sql/ast/transaction_stmt.go | 4 +- internal/sql/ast/trigger_transition.go | 2 +- internal/sql/ast/truncate_stmt.go | 2 +- internal/sql/ast/type_cast.go | 4 +- internal/sql/ast/type_name.go | 6 +-- internal/sql/ast/unlisten_stmt.go | 2 +- internal/sql/ast/update_stmt.go | 14 +++---- internal/sql/ast/vacuum_stmt.go | 4 +- internal/sql/ast/var.go | 2 +- internal/sql/ast/variable_set_stmt.go | 4 +- internal/sql/ast/variable_show_stmt.go | 2 +- internal/sql/ast/view_stmt.go | 8 ++-- internal/sql/ast/window_clause.go | 12 +++--- internal/sql/ast/window_def.go | 12 +++--- internal/sql/ast/window_func.go | 6 +-- internal/sql/ast/with_check_option.go | 6 +-- internal/sql/ast/with_clause.go | 2 +- internal/sql/ast/xml_expr.go | 10 ++--- internal/sql/ast/xml_serialize.go | 4 +- 245 files changed, 755 insertions(+), 864 deletions(-) diff --git a/docs/howto/parse.md b/docs/howto/parse.md index 816693be2e..a4fd10c6d5 100644 --- a/docs/howto/parse.md +++ b/docs/howto/parse.md @@ -87,3 +87,24 @@ clause would all print as `{}`. 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: `StmtLocation` 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 eec934554f..ab257bea23 100644 --- a/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt +++ b/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt @@ -28,19 +28,15 @@ "Stmt": { "tag": "SelectStmt", "DistinctClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, "Indirection": { - "tag": "List", - "Items": null + "tag": "List" }, "Val": { "tag": "ColumnRef", @@ -65,12 +61,9 @@ "Items": [ { "tag": "RangeVar", - "Catalogname": null, - "Schemaname": null, "Relname": "authors", "Inh": true, "Relpersistence": 112, - "Alias": null, "Location": 45 } ] @@ -110,23 +103,19 @@ "Location": 62 }, "GroupClause": { - "tag": "List", - "Items": null + "tag": "List" }, "HavingClause": { "tag": "TODO" }, "WindowClause": { - "tag": "List", - "Items": null + "tag": "List" }, "ValuesLists": { - "tag": "List", - "Items": null + "tag": "List" }, "SortClause": { - "tag": "List", - "Items": null + "tag": "List" }, "LimitOffset": { "tag": "TODO" @@ -135,14 +124,10 @@ "tag": "TODO" }, "LockingClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "WithClause": null, "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "All": false }, "StmtLocation": 0, "StmtLen": 66 diff --git a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt index 02a280a4ff..8b2e6a9f56 100644 --- a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt @@ -6,15 +6,11 @@ "tag": "RawStmt", "Stmt": { "tag": "SelectStmt", - "DistinctClause": null, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, - "Indirection": null, "Val": { "tag": "A_Const", "Val": { @@ -27,21 +23,8 @@ } ] }, - "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 + "All": false }, "StmtLocation": 0, "StmtLen": 32 diff --git a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt index f3a5c9edb6..cae0296ac7 100644 --- a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt @@ -6,15 +6,11 @@ "tag": "RawStmt", "Stmt": { "tag": "SelectStmt", - "DistinctClause": null, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, - "Indirection": null, "Val": { "tag": "A_Const", "Val": { @@ -27,21 +23,8 @@ } ] }, - "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 + "All": false }, "StmtLocation": 0, "StmtLen": 33 diff --git a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt index 06f4a4deb9..715536dec9 100644 --- a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt @@ -6,15 +6,11 @@ "tag": "RawStmt", "Stmt": { "tag": "SelectStmt", - "DistinctClause": null, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, - "Indirection": null, "Val": { "tag": "A_Const", "Val": { @@ -27,21 +23,8 @@ } ] }, - "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 + "All": false }, "StmtLocation": 0, "StmtLen": 31 diff --git a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt index e1cdbd9086..39e5aa0df6 100644 --- a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt @@ -6,15 +6,11 @@ "tag": "RawStmt", "Stmt": { "tag": "SelectStmt", - "DistinctClause": null, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, - "Indirection": null, "Val": { "tag": "A_Const", "Val": { @@ -27,21 +23,8 @@ } ] }, - "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 + "All": false }, "StmtLocation": 0, "StmtLen": 32 diff --git a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt index 580120ab58..90b2f25822 100644 --- a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt @@ -6,15 +6,11 @@ "tag": "RawStmt", "Stmt": { "tag": "SelectStmt", - "DistinctClause": null, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, - "Indirection": null, "Val": { "tag": "A_Const", "Val": { @@ -28,29 +24,16 @@ ] }, "FromClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "WhereClause": null, "GroupClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "HavingClause": null, "WindowClause": { - "tag": "List", - "Items": [] + "tag": "List" }, - "ValuesLists": null, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "All": false }, "StmtLocation": 0, "StmtLen": 31 diff --git a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt index 1b3abb1ea6..deaaea7d6c 100644 --- a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt @@ -7,19 +7,15 @@ "Stmt": { "tag": "SelectStmt", "DistinctClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, "Indirection": { - "tag": "List", - "Items": null + "tag": "List" }, "Val": { "tag": "A_Const", @@ -34,30 +30,25 @@ ] }, "FromClause": { - "tag": "List", - "Items": null + "tag": "List" }, "WhereClause": { "tag": "TODO" }, "GroupClause": { - "tag": "List", - "Items": null + "tag": "List" }, "HavingClause": { "tag": "TODO" }, "WindowClause": { - "tag": "List", - "Items": null + "tag": "List" }, "ValuesLists": { - "tag": "List", - "Items": null + "tag": "List" }, "SortClause": { - "tag": "List", - "Items": null + "tag": "List" }, "LimitOffset": { "tag": "TODO" @@ -66,14 +57,10 @@ "tag": "TODO" }, "LockingClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "WithClause": null, "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "All": false }, "StmtLocation": 0, "StmtLen": 31 diff --git a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt index 652d9bdaaf..50d4c72330 100644 --- a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt @@ -6,15 +6,11 @@ "tag": "RawStmt", "Stmt": { "tag": "SelectStmt", - "DistinctClause": null, - "IntoClause": null, "TargetList": { "tag": "List", "Items": [ { "tag": "ResTarget", - "Name": null, - "Indirection": null, "Val": { "tag": "A_Const", "Val": { @@ -28,32 +24,19 @@ ] }, "FromClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "WhereClause": null, "GroupClause": { - "tag": "List", - "Items": null + "tag": "List" }, - "HavingClause": null, "WindowClause": { - "tag": "List", - "Items": null + "tag": "List" }, "ValuesLists": { - "tag": "List", - "Items": null + "tag": "List" }, - "SortClause": null, - "LimitOffset": null, - "LimitCount": null, - "LockingClause": null, - "WithClause": null, "Op": 0, - "All": false, - "Larg": null, - "Rarg": null + "All": false }, "StmtLocation": 0, "StmtLen": 31 diff --git a/internal/sql/ast/a_array_expr.go b/internal/sql/ast/a_array_expr.go index ffd1368586..57db49109a 100644 --- a/internal/sql/ast/a_array_expr.go +++ b/internal/sql/ast/a_array_expr.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_ArrayExpr struct { Tag NodeTag[A_ArrayExpr] `json:"tag"` - Elements *List + Elements *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/a_const.go b/internal/sql/ast/a_const.go index aefb14f643..d98c00ced5 100644 --- a/internal/sql/ast/a_const.go +++ b/internal/sql/ast/a_const.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Const struct { Tag NodeTag[A_Const] `json:"tag"` - Val Node + Val Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/a_expr.go b/internal/sql/ast/a_expr.go index 2a1b55346b..b1f7d28e52 100644 --- a/internal/sql/ast/a_expr.go +++ b/internal/sql/ast/a_expr.go @@ -17,9 +17,9 @@ 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 + Name *List `json:",omitempty"` + Lexpr Node `json:",omitempty"` + Rexpr Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/a_indices.go b/internal/sql/ast/a_indices.go index 492d9cb4d2..57f9428dac 100644 --- a/internal/sql/ast/a_indices.go +++ b/internal/sql/ast/a_indices.go @@ -6,8 +6,8 @@ type A_Indices struct { Tag NodeTag[A_Indices] `json:"tag"` IsSlice bool - Lidx Node - Uidx Node + Lidx Node `json:",omitempty"` + Uidx Node `json:",omitempty"` } func (n *A_Indices) Pos() int { diff --git a/internal/sql/ast/a_indirection.go b/internal/sql/ast/a_indirection.go index 7db4e5fc5e..10fe4cdd64 100644 --- a/internal/sql/ast/a_indirection.go +++ b/internal/sql/ast/a_indirection.go @@ -3,8 +3,8 @@ package ast type A_Indirection struct { Tag NodeTag[A_Indirection] `json:"tag"` - Arg Node - Indirection *List + Arg Node `json:",omitempty"` + Indirection *List `json:",omitempty"` } func (n *A_Indirection) Pos() int { diff --git a/internal/sql/ast/access_priv.go b/internal/sql/ast/access_priv.go index 6f351ba0eb..bade930a67 100644 --- a/internal/sql/ast/access_priv.go +++ b/internal/sql/ast/access_priv.go @@ -3,8 +3,8 @@ package ast type AccessPriv struct { Tag NodeTag[AccessPriv] `json:"tag"` - PrivName *string - Cols *List + PrivName *string `json:",omitempty"` + Cols *List `json:",omitempty"` } func (n *AccessPriv) Pos() int { diff --git a/internal/sql/ast/aggref.go b/internal/sql/ast/aggref.go index dd6e0adea9..990b8b8932 100644 --- a/internal/sql/ast/aggref.go +++ b/internal/sql/ast/aggref.go @@ -3,17 +3,17 @@ package ast type Aggref struct { Tag NodeTag[Aggref] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Aggfnoid Oid Aggtype Oid Aggcollid Oid Inputcollid Oid - Aggargtypes *List - Aggdirectargs *List - Args *List - Aggorder *List - Aggdistinct *List - Aggfilter Node + Aggargtypes *List `json:",omitempty"` + Aggdirectargs *List `json:",omitempty"` + Args *List `json:",omitempty"` + Aggorder *List `json:",omitempty"` + Aggdistinct *List `json:",omitempty"` + Aggfilter Node `json:",omitempty"` Aggstar bool Aggvariadic bool Aggkind byte diff --git a/internal/sql/ast/alias.go b/internal/sql/ast/alias.go index 15092097f1..00a2d1c8f0 100644 --- a/internal/sql/ast/alias.go +++ b/internal/sql/ast/alias.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type Alias struct { Tag NodeTag[Alias] `json:"tag"` - Aliasname *string - Colnames *List + Aliasname *string `json:",omitempty"` + Colnames *List `json:",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 dec0e4cf68..d52f18fd5e 100644 --- a/internal/sql/ast/alter_collation_stmt.go +++ b/internal/sql/ast/alter_collation_stmt.go @@ -3,7 +3,7 @@ package ast type AlterCollationStmt struct { Tag NodeTag[AlterCollationStmt] `json:"tag"` - Collname *List + Collname *List `json:",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 6c16831e8a..607d98df57 100644 --- a/internal/sql/ast/alter_database_set_stmt.go +++ b/internal/sql/ast/alter_database_set_stmt.go @@ -3,8 +3,8 @@ package ast type AlterDatabaseSetStmt struct { Tag NodeTag[AlterDatabaseSetStmt] `json:"tag"` - Dbname *string - Setstmt *VariableSetStmt + Dbname *string `json:",omitempty"` + Setstmt *VariableSetStmt `json:",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 995d864023..a4144d9619 100644 --- a/internal/sql/ast/alter_database_stmt.go +++ b/internal/sql/ast/alter_database_stmt.go @@ -3,8 +3,8 @@ package ast type AlterDatabaseStmt struct { Tag NodeTag[AlterDatabaseStmt] `json:"tag"` - Dbname *string - Options *List + Dbname *string `json:",omitempty"` + Options *List `json:",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 f9f752b200..ec4c19c2b4 100644 --- a/internal/sql/ast/alter_default_privileges_stmt.go +++ b/internal/sql/ast/alter_default_privileges_stmt.go @@ -3,8 +3,8 @@ package ast type AlterDefaultPrivilegesStmt struct { Tag NodeTag[AlterDefaultPrivilegesStmt] `json:"tag"` - Options *List - Action *GrantStmt + Options *List `json:",omitempty"` + Action *GrantStmt `json:",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 4cd8418c05..33fd6e3b48 100644 --- a/internal/sql/ast/alter_domain_stmt.go +++ b/internal/sql/ast/alter_domain_stmt.go @@ -4,9 +4,9 @@ type AlterDomainStmt struct { Tag NodeTag[AlterDomainStmt] `json:"tag"` Subtype byte - TypeName *List - Name *string - Def Node + TypeName *List `json:",omitempty"` + Name *string `json:",omitempty"` + Def Node `json:",omitempty"` Behavior DropBehavior MissingOk bool } diff --git a/internal/sql/ast/alter_enum_stmt.go b/internal/sql/ast/alter_enum_stmt.go index f2a58e9e7e..cbca3a362e 100644 --- a/internal/sql/ast/alter_enum_stmt.go +++ b/internal/sql/ast/alter_enum_stmt.go @@ -3,10 +3,10 @@ package ast type AlterEnumStmt struct { Tag NodeTag[AlterEnumStmt] `json:"tag"` - TypeName *List - OldVal *string - NewVal *string - NewValNeighbor *string + TypeName *List `json:",omitempty"` + OldVal *string `json:",omitempty"` + NewVal *string `json:",omitempty"` + NewValNeighbor *string `json:",omitempty"` NewValIsAfter bool SkipIfNewValExists bool } diff --git a/internal/sql/ast/alter_event_trig_stmt.go b/internal/sql/ast/alter_event_trig_stmt.go index f6bb0e4daf..287d4e6228 100644 --- a/internal/sql/ast/alter_event_trig_stmt.go +++ b/internal/sql/ast/alter_event_trig_stmt.go @@ -3,7 +3,7 @@ package ast type AlterEventTrigStmt struct { Tag NodeTag[AlterEventTrigStmt] `json:"tag"` - Trigname *string + Trigname *string `json:",omitempty"` Tgenabled byte } diff --git a/internal/sql/ast/alter_extension_contents_stmt.go b/internal/sql/ast/alter_extension_contents_stmt.go index 6ebf0437e0..b92cd38993 100644 --- a/internal/sql/ast/alter_extension_contents_stmt.go +++ b/internal/sql/ast/alter_extension_contents_stmt.go @@ -3,10 +3,10 @@ package ast type AlterExtensionContentsStmt struct { Tag NodeTag[AlterExtensionContentsStmt] `json:"tag"` - Extname *string + Extname *string `json:",omitempty"` Action int Objtype ObjectType - Object Node + Object Node `json:",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 cb191b2b03..3a11ceb6b8 100644 --- a/internal/sql/ast/alter_extension_stmt.go +++ b/internal/sql/ast/alter_extension_stmt.go @@ -3,8 +3,8 @@ package ast type AlterExtensionStmt struct { Tag NodeTag[AlterExtensionStmt] `json:"tag"` - Extname *string - Options *List + Extname *string `json:",omitempty"` + Options *List `json:",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 458cef831f..be52b57b8c 100644 --- a/internal/sql/ast/alter_fdw_stmt.go +++ b/internal/sql/ast/alter_fdw_stmt.go @@ -3,9 +3,9 @@ package ast type AlterFdwStmt struct { Tag NodeTag[AlterFdwStmt] `json:"tag"` - Fdwname *string - FuncOptions *List - Options *List + Fdwname *string `json:",omitempty"` + FuncOptions *List `json:",omitempty"` + Options *List `json:",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 0ca94b72e7..7f8281b86d 100644 --- a/internal/sql/ast/alter_foreign_server_stmt.go +++ b/internal/sql/ast/alter_foreign_server_stmt.go @@ -3,9 +3,9 @@ package ast type AlterForeignServerStmt struct { Tag NodeTag[AlterForeignServerStmt] `json:"tag"` - Servername *string - Version *string - Options *List + Servername *string `json:",omitempty"` + Version *string `json:",omitempty"` + Options *List `json:",omitempty"` HasVersion bool } diff --git a/internal/sql/ast/alter_function_stmt.go b/internal/sql/ast/alter_function_stmt.go index 73bbeb3f1f..9d37870de5 100644 --- a/internal/sql/ast/alter_function_stmt.go +++ b/internal/sql/ast/alter_function_stmt.go @@ -3,8 +3,8 @@ package ast type AlterFunctionStmt struct { Tag NodeTag[AlterFunctionStmt] `json:"tag"` - Func *ObjectWithArgs - Actions *List + Func *ObjectWithArgs `json:",omitempty"` + Actions *List `json:",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 56e6535b1c..656ffc257a 100644 --- a/internal/sql/ast/alter_object_depends_stmt.go +++ b/internal/sql/ast/alter_object_depends_stmt.go @@ -4,9 +4,9 @@ type AlterObjectDependsStmt struct { Tag NodeTag[AlterObjectDependsStmt] `json:"tag"` ObjectType ObjectType - Relation *RangeVar - Object Node - Extname Node + Relation *RangeVar `json:",omitempty"` + Object Node `json:",omitempty"` + Extname Node `json:",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 d764551113..49d7dfe67b 100644 --- a/internal/sql/ast/alter_object_schema_stmt.go +++ b/internal/sql/ast/alter_object_schema_stmt.go @@ -4,9 +4,9 @@ type AlterObjectSchemaStmt struct { Tag NodeTag[AlterObjectSchemaStmt] `json:"tag"` ObjectType ObjectType - Relation *RangeVar - Object Node - Newschema *string + Relation *RangeVar `json:",omitempty"` + Object Node `json:",omitempty"` + Newschema *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/alter_op_family_stmt.go b/internal/sql/ast/alter_op_family_stmt.go index bb812083ae..8211cbe347 100644 --- a/internal/sql/ast/alter_op_family_stmt.go +++ b/internal/sql/ast/alter_op_family_stmt.go @@ -3,10 +3,10 @@ package ast type AlterOpFamilyStmt struct { Tag NodeTag[AlterOpFamilyStmt] `json:"tag"` - Opfamilyname *List - Amname *string + Opfamilyname *List `json:",omitempty"` + Amname *string `json:",omitempty"` IsDrop bool - Items *List + Items *List `json:",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 ac14e1c39f..51a56b4277 100644 --- a/internal/sql/ast/alter_operator_stmt.go +++ b/internal/sql/ast/alter_operator_stmt.go @@ -3,8 +3,8 @@ package ast type AlterOperatorStmt struct { Tag NodeTag[AlterOperatorStmt] `json:"tag"` - Opername *ObjectWithArgs - Options *List + Opername *ObjectWithArgs `json:",omitempty"` + Options *List `json:",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 43c8e342a6..0463e6e5da 100644 --- a/internal/sql/ast/alter_owner_stmt.go +++ b/internal/sql/ast/alter_owner_stmt.go @@ -4,9 +4,9 @@ type AlterOwnerStmt struct { Tag NodeTag[AlterOwnerStmt] `json:"tag"` ObjectType ObjectType - Relation *RangeVar - Object Node - Newowner *RoleSpec + Relation *RangeVar `json:",omitempty"` + Object Node `json:",omitempty"` + Newowner *RoleSpec `json:",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 c48ea71bea..e599c8eba9 100644 --- a/internal/sql/ast/alter_policy_stmt.go +++ b/internal/sql/ast/alter_policy_stmt.go @@ -3,11 +3,11 @@ package ast type AlterPolicyStmt struct { Tag NodeTag[AlterPolicyStmt] `json:"tag"` - PolicyName *string - Table *RangeVar - Roles *List - Qual Node - WithCheck Node + PolicyName *string `json:",omitempty"` + Table *RangeVar `json:",omitempty"` + Roles *List `json:",omitempty"` + Qual Node `json:",omitempty"` + WithCheck Node `json:",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 adcb3facf3..8bd61b93ae 100644 --- a/internal/sql/ast/alter_publication_stmt.go +++ b/internal/sql/ast/alter_publication_stmt.go @@ -3,9 +3,9 @@ package ast type AlterPublicationStmt struct { Tag NodeTag[AlterPublicationStmt] `json:"tag"` - Pubname *string - Options *List - Tables *List + Pubname *string `json:",omitempty"` + Options *List `json:",omitempty"` + Tables *List `json:",omitempty"` ForAllTables bool TableAction DefElemAction } diff --git a/internal/sql/ast/alter_role_set_stmt.go b/internal/sql/ast/alter_role_set_stmt.go index ec85174170..2e1ce504d4 100644 --- a/internal/sql/ast/alter_role_set_stmt.go +++ b/internal/sql/ast/alter_role_set_stmt.go @@ -3,9 +3,9 @@ package ast type AlterRoleSetStmt struct { Tag NodeTag[AlterRoleSetStmt] `json:"tag"` - Role *RoleSpec - Database *string - Setstmt *VariableSetStmt + Role *RoleSpec `json:",omitempty"` + Database *string `json:",omitempty"` + Setstmt *VariableSetStmt `json:",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 26630bfacf..3b7e02411a 100644 --- a/internal/sql/ast/alter_role_stmt.go +++ b/internal/sql/ast/alter_role_stmt.go @@ -3,8 +3,8 @@ package ast type AlterRoleStmt struct { Tag NodeTag[AlterRoleStmt] `json:"tag"` - Role *RoleSpec - Options *List + Role *RoleSpec `json:",omitempty"` + Options *List `json:",omitempty"` Action int } diff --git a/internal/sql/ast/alter_seq_stmt.go b/internal/sql/ast/alter_seq_stmt.go index 0ef3bfb34a..e27072f133 100644 --- a/internal/sql/ast/alter_seq_stmt.go +++ b/internal/sql/ast/alter_seq_stmt.go @@ -3,8 +3,8 @@ package ast type AlterSeqStmt struct { Tag NodeTag[AlterSeqStmt] `json:"tag"` - Sequence *RangeVar - Options *List + Sequence *RangeVar `json:",omitempty"` + Options *List `json:",omitempty"` ForIdentity bool MissingOk bool } diff --git a/internal/sql/ast/alter_subscription_stmt.go b/internal/sql/ast/alter_subscription_stmt.go index 19e955aaa3..7d0ecc18cb 100644 --- a/internal/sql/ast/alter_subscription_stmt.go +++ b/internal/sql/ast/alter_subscription_stmt.go @@ -4,10 +4,10 @@ type AlterSubscriptionStmt struct { Tag NodeTag[AlterSubscriptionStmt] `json:"tag"` Kind AlterSubscriptionType - Subname *string - Conninfo *string - Publication *List - Options *List + Subname *string `json:",omitempty"` + Conninfo *string `json:",omitempty"` + Publication *List `json:",omitempty"` + Options *List `json:",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 1b05ab05c0..d3ff7e59b1 100644 --- a/internal/sql/ast/alter_system_stmt.go +++ b/internal/sql/ast/alter_system_stmt.go @@ -3,7 +3,7 @@ package ast type AlterSystemStmt struct { Tag NodeTag[AlterSystemStmt] `json:"tag"` - Setstmt *VariableSetStmt + Setstmt *VariableSetStmt `json:",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 5e68571d5b..88ea854a1f 100644 --- a/internal/sql/ast/alter_table_cmd.go +++ b/internal/sql/ast/alter_table_cmd.go @@ -33,9 +33,9 @@ type AlterTableCmd struct { Tag NodeTag[AlterTableCmd] `json:"tag"` Subtype AlterTableType - Name *string - Def *ColumnDef - Newowner *RoleSpec + Name *string `json:",omitempty"` + Def *ColumnDef `json:",omitempty"` + Newowner *RoleSpec `json:",omitempty"` Behavior DropBehavior MissingOk bool } diff --git a/internal/sql/ast/alter_table_move_all_stmt.go b/internal/sql/ast/alter_table_move_all_stmt.go index 6cdb343d10..bc6ad1ac09 100644 --- a/internal/sql/ast/alter_table_move_all_stmt.go +++ b/internal/sql/ast/alter_table_move_all_stmt.go @@ -3,10 +3,10 @@ package ast type AlterTableMoveAllStmt struct { Tag NodeTag[AlterTableMoveAllStmt] `json:"tag"` - OrigTablespacename *string + OrigTablespacename *string `json:",omitempty"` Objtype ObjectType - Roles *List - NewTablespacename *string + Roles *List `json:",omitempty"` + NewTablespacename *string `json:",omitempty"` Nowait bool } diff --git a/internal/sql/ast/alter_table_set_schema_stmt.go b/internal/sql/ast/alter_table_set_schema_stmt.go index fb8c9c6c4e..9f0d25b1cb 100644 --- a/internal/sql/ast/alter_table_set_schema_stmt.go +++ b/internal/sql/ast/alter_table_set_schema_stmt.go @@ -3,8 +3,8 @@ package ast type AlterTableSetSchemaStmt struct { Tag NodeTag[AlterTableSetSchemaStmt] `json:"tag"` - Table *TableName - NewSchema *string + Table *TableName `json:",omitempty"` + NewSchema *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/alter_table_space_options_stmt.go b/internal/sql/ast/alter_table_space_options_stmt.go index bab3c032e2..47642533a3 100644 --- a/internal/sql/ast/alter_table_space_options_stmt.go +++ b/internal/sql/ast/alter_table_space_options_stmt.go @@ -3,8 +3,8 @@ package ast type AlterTableSpaceOptionsStmt struct { Tag NodeTag[AlterTableSpaceOptionsStmt] `json:"tag"` - Tablespacename *string - Options *List + Tablespacename *string `json:",omitempty"` + Options *List `json:",omitempty"` IsReset bool } diff --git a/internal/sql/ast/alter_table_stmt.go b/internal/sql/ast/alter_table_stmt.go index 701be525fc..74a358b15a 100644 --- a/internal/sql/ast/alter_table_stmt.go +++ b/internal/sql/ast/alter_table_stmt.go @@ -6,9 +6,9 @@ type AlterTableStmt struct { Tag NodeTag[AlterTableStmt] `json:"tag"` // TODO: Only TableName or Relation should be defined - Relation *RangeVar - Table *TableName - Cmds *List + Relation *RangeVar `json:",omitempty"` + Table *TableName `json:",omitempty"` + Cmds *List `json:",omitempty"` MissingOk bool Relkind ObjectType // Incomplete marks a statement whose source carried syntax this node diff --git a/internal/sql/ast/alter_ts_configuration_stmt.go b/internal/sql/ast/alter_ts_configuration_stmt.go index 2253e74340..ed1faa69cd 100644 --- a/internal/sql/ast/alter_ts_configuration_stmt.go +++ b/internal/sql/ast/alter_ts_configuration_stmt.go @@ -4,9 +4,9 @@ type AlterTSConfigurationStmt struct { Tag NodeTag[AlterTSConfigurationStmt] `json:"tag"` Kind AlterTSConfigType - Cfgname *List - Tokentype *List - Dicts *List + Cfgname *List `json:",omitempty"` + Tokentype *List `json:",omitempty"` + Dicts *List `json:",omitempty"` Override bool Replace bool MissingOk bool diff --git a/internal/sql/ast/alter_ts_dictionary_stmt.go b/internal/sql/ast/alter_ts_dictionary_stmt.go index 29862a1646..401785f2ac 100644 --- a/internal/sql/ast/alter_ts_dictionary_stmt.go +++ b/internal/sql/ast/alter_ts_dictionary_stmt.go @@ -3,8 +3,8 @@ package ast type AlterTSDictionaryStmt struct { Tag NodeTag[AlterTSDictionaryStmt] `json:"tag"` - Dictname *List - Options *List + Dictname *List `json:",omitempty"` + Options *List `json:",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 015d9e39c9..470304fbb5 100644 --- a/internal/sql/ast/alter_type_add_value_stmt.go +++ b/internal/sql/ast/alter_type_add_value_stmt.go @@ -3,10 +3,10 @@ package ast type AlterTypeAddValueStmt struct { Tag NodeTag[AlterTypeAddValueStmt] `json:"tag"` - Type *TypeName - NewValue *string + Type *TypeName `json:",omitempty"` + NewValue *string `json:",omitempty"` NewValHasNeighbor bool - NewValNeighbor *string + NewValNeighbor *string `json:",omitempty"` NewValIsAfter bool SkipIfNewValExists bool } diff --git a/internal/sql/ast/alter_type_rename_value_stmt.go b/internal/sql/ast/alter_type_rename_value_stmt.go index c9d4f5cea5..aa5c6961d6 100644 --- a/internal/sql/ast/alter_type_rename_value_stmt.go +++ b/internal/sql/ast/alter_type_rename_value_stmt.go @@ -3,9 +3,9 @@ package ast type AlterTypeRenameValueStmt struct { Tag NodeTag[AlterTypeRenameValueStmt] `json:"tag"` - Type *TypeName - OldValue *string - NewValue *string + Type *TypeName `json:",omitempty"` + OldValue *string `json:",omitempty"` + NewValue *string `json:",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 e5755a34e1..c0abb42144 100644 --- a/internal/sql/ast/alter_type_set_schema_stmt.go +++ b/internal/sql/ast/alter_type_set_schema_stmt.go @@ -3,8 +3,8 @@ package ast type AlterTypeSetSchemaStmt struct { Tag NodeTag[AlterTypeSetSchemaStmt] `json:"tag"` - Type *TypeName - NewSchema *string + Type *TypeName `json:",omitempty"` + NewSchema *string `json:",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 cb7e09c6dc..3041a45df3 100644 --- a/internal/sql/ast/alter_user_mapping_stmt.go +++ b/internal/sql/ast/alter_user_mapping_stmt.go @@ -3,9 +3,9 @@ package ast type AlterUserMappingStmt struct { Tag NodeTag[AlterUserMappingStmt] `json:"tag"` - User *RoleSpec - Servername *string - Options *List + User *RoleSpec `json:",omitempty"` + Servername *string `json:",omitempty"` + Options *List `json:",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 3ad50efb18..68b51e235d 100644 --- a/internal/sql/ast/alternative_sub_plan.go +++ b/internal/sql/ast/alternative_sub_plan.go @@ -3,8 +3,8 @@ package ast type AlternativeSubPlan struct { Tag NodeTag[AlternativeSubPlan] `json:"tag"` - Xpr Node - Subplans *List + Xpr Node `json:",omitempty"` + Subplans *List `json:",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 16ab4a3b3e..2cef349648 100644 --- a/internal/sql/ast/array_coerce_expr.go +++ b/internal/sql/ast/array_coerce_expr.go @@ -3,8 +3,8 @@ package ast type ArrayCoerceExpr struct { Tag NodeTag[ArrayCoerceExpr] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Elemfuncid Oid Resulttype Oid Resulttypmod int32 diff --git a/internal/sql/ast/array_expr.go b/internal/sql/ast/array_expr.go index bed2c7fe50..c6a0d2b773 100644 --- a/internal/sql/ast/array_expr.go +++ b/internal/sql/ast/array_expr.go @@ -3,11 +3,11 @@ package ast type ArrayExpr struct { Tag NodeTag[ArrayExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` ArrayTypeid Oid ArrayCollid Oid ElementTypeid Oid - Elements *List + Elements *List `json:",omitempty"` Multidims bool Location int } diff --git a/internal/sql/ast/array_ref.go b/internal/sql/ast/array_ref.go index 1753a21c7f..19cadc1c40 100644 --- a/internal/sql/ast/array_ref.go +++ b/internal/sql/ast/array_ref.go @@ -3,15 +3,15 @@ package ast type ArrayRef struct { Tag NodeTag[ArrayRef] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Refarraytype Oid Refelemtype Oid Reftypmod int32 Refcollid Oid - Refupperindexpr *List - Reflowerindexpr *List - Refexpr Node - Refassgnexpr Node + Refupperindexpr *List `json:",omitempty"` + Reflowerindexpr *List `json:",omitempty"` + Refexpr Node `json:",omitempty"` + Refassgnexpr Node `json:",omitempty"` } func (n *ArrayRef) Pos() int { diff --git a/internal/sql/ast/between_expr.go b/internal/sql/ast/between_expr.go index e17fce9286..2c4d69dc7c 100644 --- a/internal/sql/ast/between_expr.go +++ b/internal/sql/ast/between_expr.go @@ -6,11 +6,11 @@ type BetweenExpr struct { Tag NodeTag[BetweenExpr] `json:"tag"` // Expr is the value expression to be compared. - Expr Node + Expr Node `json:",omitempty"` // Left is the left expression in the between statement. - Left Node + Left Node `json:",omitempty"` // Right is the right expression in the between statement. - Right Node + Right Node `json:",omitempty"` // Not is true, the expression is "not between". Not bool Location int diff --git a/internal/sql/ast/bool_expr.go b/internal/sql/ast/bool_expr.go index 0f61b45133..50491a234d 100644 --- a/internal/sql/ast/bool_expr.go +++ b/internal/sql/ast/bool_expr.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type BoolExpr struct { Tag NodeTag[BoolExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Boolop BoolExprType - Args *List + Args *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/boolean_test_expr.go b/internal/sql/ast/boolean_test_expr.go index 68a75a53e5..cec077c7be 100644 --- a/internal/sql/ast/boolean_test_expr.go +++ b/internal/sql/ast/boolean_test_expr.go @@ -3,8 +3,8 @@ package ast type BooleanTest struct { Tag NodeTag[BooleanTest] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Booltesttype BoolTestType Location int } diff --git a/internal/sql/ast/call_stmt.go b/internal/sql/ast/call_stmt.go index 400059cbdb..39213a7f66 100644 --- a/internal/sql/ast/call_stmt.go +++ b/internal/sql/ast/call_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CallStmt struct { Tag NodeTag[CallStmt] `json:"tag"` - FuncCall *FuncCall + FuncCall *FuncCall `json:",omitempty"` } func (n *CallStmt) Pos() int { diff --git a/internal/sql/ast/case_expr.go b/internal/sql/ast/case_expr.go index 18decb83db..9f69eeb893 100644 --- a/internal/sql/ast/case_expr.go +++ b/internal/sql/ast/case_expr.go @@ -5,12 +5,12 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseExpr struct { Tag NodeTag[CaseExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Casetype Oid Casecollid Oid - Arg Node - Args *List - Defresult Node + Arg Node `json:",omitempty"` + Args *List `json:",omitempty"` + Defresult Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/case_test_expr.go b/internal/sql/ast/case_test_expr.go index 58dfae4c8a..876556b52b 100644 --- a/internal/sql/ast/case_test_expr.go +++ b/internal/sql/ast/case_test_expr.go @@ -3,7 +3,7 @@ package ast type CaseTestExpr struct { Tag NodeTag[CaseTestExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` TypeId Oid TypeMod int32 Collation Oid diff --git a/internal/sql/ast/case_when.go b/internal/sql/ast/case_when.go index 9b86268cd8..1124a95ce0 100644 --- a/internal/sql/ast/case_when.go +++ b/internal/sql/ast/case_when.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseWhen struct { Tag NodeTag[CaseWhen] `json:"tag"` - Xpr Node - Expr Node - Result Node + Xpr Node `json:",omitempty"` + Expr Node `json:",omitempty"` + Result Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/close_portal_stmt.go b/internal/sql/ast/close_portal_stmt.go index 446d4109e7..a3b5d9c082 100644 --- a/internal/sql/ast/close_portal_stmt.go +++ b/internal/sql/ast/close_portal_stmt.go @@ -3,7 +3,7 @@ package ast type ClosePortalStmt struct { Tag NodeTag[ClosePortalStmt] `json:"tag"` - Portalname *string + Portalname *string `json:",omitempty"` } func (n *ClosePortalStmt) Pos() int { diff --git a/internal/sql/ast/cluster_stmt.go b/internal/sql/ast/cluster_stmt.go index aeb9beeb85..d2c9cde18f 100644 --- a/internal/sql/ast/cluster_stmt.go +++ b/internal/sql/ast/cluster_stmt.go @@ -3,8 +3,8 @@ package ast type ClusterStmt struct { Tag NodeTag[ClusterStmt] `json:"tag"` - Relation *RangeVar - Indexname *string + Relation *RangeVar `json:",omitempty"` + Indexname *string `json:",omitempty"` Verbose bool } diff --git a/internal/sql/ast/coalesce_expr.go b/internal/sql/ast/coalesce_expr.go index d0bea53286..f4401c17fe 100644 --- a/internal/sql/ast/coalesce_expr.go +++ b/internal/sql/ast/coalesce_expr.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CoalesceExpr struct { Tag NodeTag[CoalesceExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Coalescetype Oid Coalescecollid Oid - Args *List + Args *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/coerce_to_domain.go b/internal/sql/ast/coerce_to_domain.go index 65079dae57..ebb2acde23 100644 --- a/internal/sql/ast/coerce_to_domain.go +++ b/internal/sql/ast/coerce_to_domain.go @@ -3,8 +3,8 @@ package ast type CoerceToDomain struct { Tag NodeTag[CoerceToDomain] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Resulttype Oid Resulttypmod int32 Resultcollid Oid diff --git a/internal/sql/ast/coerce_to_domain_value.go b/internal/sql/ast/coerce_to_domain_value.go index de5ce0bc4a..7f76aaf256 100644 --- a/internal/sql/ast/coerce_to_domain_value.go +++ b/internal/sql/ast/coerce_to_domain_value.go @@ -3,7 +3,7 @@ package ast type CoerceToDomainValue struct { Tag NodeTag[CoerceToDomainValue] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` TypeId Oid TypeMod int32 Collation Oid diff --git a/internal/sql/ast/coerce_via_io.go b/internal/sql/ast/coerce_via_io.go index 98b0a8965e..01e0f7e8c3 100644 --- a/internal/sql/ast/coerce_via_io.go +++ b/internal/sql/ast/coerce_via_io.go @@ -3,8 +3,8 @@ package ast type CoerceViaIO struct { Tag NodeTag[CoerceViaIO] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Resulttype Oid Resultcollid Oid Coerceformat CoercionForm diff --git a/internal/sql/ast/collate_clause.go b/internal/sql/ast/collate_clause.go index e212f5c06e..8854456b2e 100644 --- a/internal/sql/ast/collate_clause.go +++ b/internal/sql/ast/collate_clause.go @@ -3,8 +3,8 @@ package ast type CollateClause struct { Tag NodeTag[CollateClause] `json:"tag"` - Arg Node - Collname *List + Arg Node `json:",omitempty"` + Collname *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/collate_expr.go b/internal/sql/ast/collate_expr.go index 898f5bc4a1..0ea98d3826 100644 --- a/internal/sql/ast/collate_expr.go +++ b/internal/sql/ast/collate_expr.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CollateExpr struct { Tag NodeTag[CollateExpr] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` CollOid Oid Location int } diff --git a/internal/sql/ast/column_def.go b/internal/sql/ast/column_def.go index 1374950120..566e05dbac 100644 --- a/internal/sql/ast/column_def.go +++ b/internal/sql/ast/column_def.go @@ -9,14 +9,14 @@ type ColumnDef struct { // 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 + TypeName *TypeName `json:",omitempty"` Typeless bool IsNotNull bool IsUnsigned bool IsArray bool ArrayDims int - Vals *List - Length *int + Vals *List `json:",omitempty"` + Length *int `json:",omitempty"` PrimaryKey bool // IsHidden marks a column a relation offers by name without listing it, // like the column an sqlite fts5 table names after itself. The legacy @@ -30,13 +30,13 @@ type ColumnDef struct { IsFromType bool IsFromParent bool Storage byte - RawDefault Node - CookedDefault Node + RawDefault Node `json:",omitempty"` + CookedDefault Node `json:",omitempty"` Identity byte - CollClause *CollateClause + CollClause *CollateClause `json:",omitempty"` CollOid Oid - Constraints *List - Fdwoptions *List + Constraints *List `json:",omitempty"` + Fdwoptions *List `json:",omitempty"` Location int Comment string } diff --git a/internal/sql/ast/column_ref.go b/internal/sql/ast/column_ref.go index 0be1dbdcc4..8abd2947bd 100644 --- a/internal/sql/ast/column_ref.go +++ b/internal/sql/ast/column_ref.go @@ -12,7 +12,7 @@ type ColumnRef struct { Name string // From pg.ColumnRef - Fields *List + Fields *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/comment.go b/internal/sql/ast/comment.go index ea877328b0..e97be453f6 100644 --- a/internal/sql/ast/comment.go +++ b/internal/sql/ast/comment.go @@ -12,8 +12,8 @@ import ( // Roslyn's terminology — return it from ParseFile, so the formatter gets // statements and comments from one lexer pass. type File struct { - Stmts []Statement - Comments []Comment + Stmts []Statement `json:",omitempty"` + Comments []Comment `json:",omitempty"` } // Comment is a single SQL comment, positioned by byte offsets into the diff --git a/internal/sql/ast/comment_on_column_stmt.go b/internal/sql/ast/comment_on_column_stmt.go index 480a559b3e..6074555258 100644 --- a/internal/sql/ast/comment_on_column_stmt.go +++ b/internal/sql/ast/comment_on_column_stmt.go @@ -3,9 +3,9 @@ package ast type CommentOnColumnStmt struct { Tag NodeTag[CommentOnColumnStmt] `json:"tag"` - Table *TableName - Col *ColumnRef - Comment *string + Table *TableName `json:",omitempty"` + Col *ColumnRef `json:",omitempty"` + Comment *string `json:",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 fd8e74fc15..9edd4d7b4a 100644 --- a/internal/sql/ast/comment_on_schema_stmt.go +++ b/internal/sql/ast/comment_on_schema_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnSchemaStmt struct { Tag NodeTag[CommentOnSchemaStmt] `json:"tag"` - Schema *String - Comment *string + Schema *String `json:",omitempty"` + Comment *string `json:",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 2d1db8667a..3fd4059217 100644 --- a/internal/sql/ast/comment_on_table_stmt.go +++ b/internal/sql/ast/comment_on_table_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnTableStmt struct { Tag NodeTag[CommentOnTableStmt] `json:"tag"` - Table *TableName - Comment *string + Table *TableName `json:",omitempty"` + Comment *string `json:",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 0fd4a1a144..e85823d195 100644 --- a/internal/sql/ast/comment_on_type_stmt.go +++ b/internal/sql/ast/comment_on_type_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnTypeStmt struct { Tag NodeTag[CommentOnTypeStmt] `json:"tag"` - Type *TypeName - Comment *string + Type *TypeName `json:",omitempty"` + Comment *string `json:",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 c0d7e98396..2a2592c27a 100644 --- a/internal/sql/ast/comment_on_view_stmt.go +++ b/internal/sql/ast/comment_on_view_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnViewStmt struct { Tag NodeTag[CommentOnViewStmt] `json:"tag"` - View *TableName - Comment *string + View *TableName `json:",omitempty"` + Comment *string `json:",omitempty"` } func (n *CommentOnViewStmt) Pos() int { diff --git a/internal/sql/ast/comment_stmt.go b/internal/sql/ast/comment_stmt.go index b56c6869ad..48ba85ce4f 100644 --- a/internal/sql/ast/comment_stmt.go +++ b/internal/sql/ast/comment_stmt.go @@ -4,8 +4,8 @@ type CommentStmt struct { Tag NodeTag[CommentStmt] `json:"tag"` Objtype ObjectType - Object Node - Comment *string + Object Node `json:",omitempty"` + Comment *string `json:",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 df611885cc..480ae73432 100644 --- a/internal/sql/ast/common_table_expr.go +++ b/internal/sql/ast/common_table_expr.go @@ -5,16 +5,16 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CommonTableExpr struct { Tag NodeTag[CommonTableExpr] `json:"tag"` - Ctename *string - Aliascolnames *List - Ctequery Node + Ctename *string `json:",omitempty"` + Aliascolnames *List `json:",omitempty"` + Ctequery Node `json:",omitempty"` Location int Cterecursive bool Cterefcount int - Ctecolnames *List - Ctecoltypes *List - Ctecoltypmods *List - Ctecolcollations *List + Ctecolnames *List `json:",omitempty"` + Ctecoltypes *List `json:",omitempty"` + Ctecoltypmods *List `json:",omitempty"` + Ctecolcollations *List `json:",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 ec96701f09..3ec95e8285 100644 --- a/internal/sql/ast/composite_type_stmt.go +++ b/internal/sql/ast/composite_type_stmt.go @@ -3,7 +3,7 @@ package ast type CompositeTypeStmt struct { Tag NodeTag[CompositeTypeStmt] `json:"tag"` - TypeName *TypeName + TypeName *TypeName `json:",omitempty"` } func (n *CompositeTypeStmt) Pos() int { diff --git a/internal/sql/ast/const.go b/internal/sql/ast/const.go index 9e026c6b8c..0c114b6a40 100644 --- a/internal/sql/ast/const.go +++ b/internal/sql/ast/const.go @@ -3,7 +3,7 @@ package ast type Const struct { Tag NodeTag[Const] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Consttype Oid Consttypmod int32 Constcollid Oid diff --git a/internal/sql/ast/constraint.go b/internal/sql/ast/constraint.go index d959e0edb4..7b8017741e 100644 --- a/internal/sql/ast/constraint.go +++ b/internal/sql/ast/constraint.go @@ -4,28 +4,28 @@ type Constraint struct { Tag NodeTag[Constraint] `json:"tag"` Contype ConstrType - Conname *string + Conname *string `json:",omitempty"` Deferrable bool Initdeferred bool Location int IsNoInherit bool - RawExpr Node - CookedExpr *string + RawExpr Node `json:",omitempty"` + CookedExpr *string `json:",omitempty"` GeneratedWhen byte - Keys *List - Exclusions *List - Options *List - Indexname *string - Indexspace *string - AccessMethod *string - WhereClause Node - Pktable *RangeVar - FkAttrs *List - PkAttrs *List + Keys *List `json:",omitempty"` + Exclusions *List `json:",omitempty"` + Options *List `json:",omitempty"` + Indexname *string `json:",omitempty"` + Indexspace *string `json:",omitempty"` + AccessMethod *string `json:",omitempty"` + WhereClause Node `json:",omitempty"` + Pktable *RangeVar `json:",omitempty"` + FkAttrs *List `json:",omitempty"` + PkAttrs *List `json:",omitempty"` FkMatchtype byte FkUpdAction byte FkDelAction byte - OldConpfeqop *List + OldConpfeqop *List `json:",omitempty"` OldPktableOid Oid SkipValidation bool InitiallyValid bool diff --git a/internal/sql/ast/constraints_set_stmt.go b/internal/sql/ast/constraints_set_stmt.go index bb3d108453..71dadf8437 100644 --- a/internal/sql/ast/constraints_set_stmt.go +++ b/internal/sql/ast/constraints_set_stmt.go @@ -3,7 +3,7 @@ package ast type ConstraintsSetStmt struct { Tag NodeTag[ConstraintsSetStmt] `json:"tag"` - Constraints *List + Constraints *List `json:",omitempty"` Deferred bool } diff --git a/internal/sql/ast/convert_rowtype_expr.go b/internal/sql/ast/convert_rowtype_expr.go index 93ce47ce49..24461d467d 100644 --- a/internal/sql/ast/convert_rowtype_expr.go +++ b/internal/sql/ast/convert_rowtype_expr.go @@ -3,8 +3,8 @@ package ast type ConvertRowtypeExpr struct { Tag NodeTag[ConvertRowtypeExpr] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Resulttype Oid Convertformat CoercionForm Location int diff --git a/internal/sql/ast/copy_stmt.go b/internal/sql/ast/copy_stmt.go index c518deb6f2..7c68f023a0 100644 --- a/internal/sql/ast/copy_stmt.go +++ b/internal/sql/ast/copy_stmt.go @@ -3,13 +3,13 @@ package ast type CopyStmt struct { Tag NodeTag[CopyStmt] `json:"tag"` - Relation *RangeVar - Query Node - Attlist *List + Relation *RangeVar `json:",omitempty"` + Query Node `json:",omitempty"` + Attlist *List `json:",omitempty"` IsFrom bool IsProgram bool - Filename *string - Options *List + Filename *string `json:",omitempty"` + Options *List `json:",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 bfc345efd8..8b7c361a13 100644 --- a/internal/sql/ast/create_am_stmt.go +++ b/internal/sql/ast/create_am_stmt.go @@ -3,8 +3,8 @@ package ast type CreateAmStmt struct { Tag NodeTag[CreateAmStmt] `json:"tag"` - Amname *string - HandlerName *List + Amname *string `json:",omitempty"` + HandlerName *List `json:",omitempty"` Amtype byte } diff --git a/internal/sql/ast/create_cast_stmt.go b/internal/sql/ast/create_cast_stmt.go index cd478d1abd..839826879c 100644 --- a/internal/sql/ast/create_cast_stmt.go +++ b/internal/sql/ast/create_cast_stmt.go @@ -3,9 +3,9 @@ package ast type CreateCastStmt struct { Tag NodeTag[CreateCastStmt] `json:"tag"` - Sourcetype *TypeName - Targettype *TypeName - Func *ObjectWithArgs + Sourcetype *TypeName `json:",omitempty"` + Targettype *TypeName `json:",omitempty"` + Func *ObjectWithArgs `json:",omitempty"` Context CoercionContext Inout bool } diff --git a/internal/sql/ast/create_conversion_stmt.go b/internal/sql/ast/create_conversion_stmt.go index ccbb7dad70..5a9dfcca86 100644 --- a/internal/sql/ast/create_conversion_stmt.go +++ b/internal/sql/ast/create_conversion_stmt.go @@ -3,10 +3,10 @@ package ast type CreateConversionStmt struct { Tag NodeTag[CreateConversionStmt] `json:"tag"` - ConversionName *List - ForEncodingName *string - ToEncodingName *string - FuncName *List + ConversionName *List `json:",omitempty"` + ForEncodingName *string `json:",omitempty"` + ToEncodingName *string `json:",omitempty"` + FuncName *List `json:",omitempty"` Def bool } diff --git a/internal/sql/ast/create_domain_stmt.go b/internal/sql/ast/create_domain_stmt.go index 6994a2473c..f9351cd8ee 100644 --- a/internal/sql/ast/create_domain_stmt.go +++ b/internal/sql/ast/create_domain_stmt.go @@ -3,10 +3,10 @@ package ast type CreateDomainStmt struct { Tag NodeTag[CreateDomainStmt] `json:"tag"` - Domainname *List - TypeName *TypeName - CollClause *CollateClause - Constraints *List + Domainname *List `json:",omitempty"` + TypeName *TypeName `json:",omitempty"` + CollClause *CollateClause `json:",omitempty"` + Constraints *List `json:",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 9265b24ce3..fd952b2cd9 100644 --- a/internal/sql/ast/create_enum_stmt.go +++ b/internal/sql/ast/create_enum_stmt.go @@ -3,8 +3,8 @@ package ast type CreateEnumStmt struct { Tag NodeTag[CreateEnumStmt] `json:"tag"` - TypeName *TypeName - Vals *List + TypeName *TypeName `json:",omitempty"` + Vals *List `json:",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 01aea1096e..d716436b42 100644 --- a/internal/sql/ast/create_event_trig_stmt.go +++ b/internal/sql/ast/create_event_trig_stmt.go @@ -3,10 +3,10 @@ package ast type CreateEventTrigStmt struct { Tag NodeTag[CreateEventTrigStmt] `json:"tag"` - Trigname *string - Eventname *string - Whenclause *List - Funcname *List + Trigname *string `json:",omitempty"` + Eventname *string `json:",omitempty"` + Whenclause *List `json:",omitempty"` + Funcname *List `json:",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 4a23773c37..a9bfa557d9 100644 --- a/internal/sql/ast/create_extension_stmt.go +++ b/internal/sql/ast/create_extension_stmt.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateExtensionStmt struct { Tag NodeTag[CreateExtensionStmt] `json:"tag"` - Extname *string + Extname *string `json:",omitempty"` IfNotExists bool - Options *List + Options *List `json:",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 fad9ee099d..6f1bd9421d 100644 --- a/internal/sql/ast/create_fdw_stmt.go +++ b/internal/sql/ast/create_fdw_stmt.go @@ -3,9 +3,9 @@ package ast type CreateFdwStmt struct { Tag NodeTag[CreateFdwStmt] `json:"tag"` - Fdwname *string - FuncOptions *List - Options *List + Fdwname *string `json:",omitempty"` + FuncOptions *List `json:",omitempty"` + Options *List `json:",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 37fc711296..bd8d936eff 100644 --- a/internal/sql/ast/create_foreign_server_stmt.go +++ b/internal/sql/ast/create_foreign_server_stmt.go @@ -3,12 +3,12 @@ package ast type CreateForeignServerStmt struct { Tag NodeTag[CreateForeignServerStmt] `json:"tag"` - Servername *string - Servertype *string - Version *string - Fdwname *string + Servername *string `json:",omitempty"` + Servertype *string `json:",omitempty"` + Version *string `json:",omitempty"` + Fdwname *string `json:",omitempty"` IfNotExists bool - Options *List + Options *List `json:",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 4e1ab8e53e..4e0b8e5089 100644 --- a/internal/sql/ast/create_foreign_table_stmt.go +++ b/internal/sql/ast/create_foreign_table_stmt.go @@ -3,9 +3,9 @@ package ast type CreateForeignTableStmt struct { Tag NodeTag[CreateForeignTableStmt] `json:"tag"` - Base *CreateStmt - Servername *string - Options *List + Base *CreateStmt `json:",omitempty"` + Servername *string `json:",omitempty"` + Options *List `json:",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 c878d36fde..71af48da39 100644 --- a/internal/sql/ast/create_function_stmt.go +++ b/internal/sql/ast/create_function_stmt.go @@ -6,12 +6,12 @@ type CreateFunctionStmt struct { Tag NodeTag[CreateFunctionStmt] `json:"tag"` Replace bool - Params *List - ReturnType *TypeName - Func *FuncName + Params *List `json:",omitempty"` + ReturnType *TypeName `json:",omitempty"` + Func *FuncName `json:",omitempty"` // TODO: Understand these two fields - Options *List - WithClause *List + Options *List `json:",omitempty"` + WithClause *List `json:",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 94d0a00b56..e1709856a5 100644 --- a/internal/sql/ast/create_op_class_item.go +++ b/internal/sql/ast/create_op_class_item.go @@ -4,11 +4,11 @@ type CreateOpClassItem struct { Tag NodeTag[CreateOpClassItem] `json:"tag"` Itemtype int - Name *ObjectWithArgs + Name *ObjectWithArgs `json:",omitempty"` Number int - OrderFamily *List - ClassArgs *List - Storedtype *TypeName + OrderFamily *List `json:",omitempty"` + ClassArgs *List `json:",omitempty"` + Storedtype *TypeName `json:",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 ec4f3cbf5e..a4b62f4129 100644 --- a/internal/sql/ast/create_op_class_stmt.go +++ b/internal/sql/ast/create_op_class_stmt.go @@ -3,11 +3,11 @@ package ast type CreateOpClassStmt struct { Tag NodeTag[CreateOpClassStmt] `json:"tag"` - Opclassname *List - Opfamilyname *List - Amname *string - Datatype *TypeName - Items *List + Opclassname *List `json:",omitempty"` + Opfamilyname *List `json:",omitempty"` + Amname *string `json:",omitempty"` + Datatype *TypeName `json:",omitempty"` + Items *List `json:",omitempty"` IsDefault bool } diff --git a/internal/sql/ast/create_op_family_stmt.go b/internal/sql/ast/create_op_family_stmt.go index 394a8cf4d4..4e4a497004 100644 --- a/internal/sql/ast/create_op_family_stmt.go +++ b/internal/sql/ast/create_op_family_stmt.go @@ -3,8 +3,8 @@ package ast type CreateOpFamilyStmt struct { Tag NodeTag[CreateOpFamilyStmt] `json:"tag"` - Opfamilyname *List - Amname *string + Opfamilyname *List `json:",omitempty"` + Amname *string `json:",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 0e96bc4725..f3b9ab9fda 100644 --- a/internal/sql/ast/create_p_lang_stmt.go +++ b/internal/sql/ast/create_p_lang_stmt.go @@ -4,10 +4,10 @@ type CreatePLangStmt struct { Tag NodeTag[CreatePLangStmt] `json:"tag"` Replace bool - Plname *string - Plhandler *List - Plinline *List - Plvalidator *List + Plname *string `json:",omitempty"` + Plhandler *List `json:",omitempty"` + Plinline *List `json:",omitempty"` + Plvalidator *List `json:",omitempty"` Pltrusted bool } diff --git a/internal/sql/ast/create_policy_stmt.go b/internal/sql/ast/create_policy_stmt.go index a514ff97fc..e945edbfc8 100644 --- a/internal/sql/ast/create_policy_stmt.go +++ b/internal/sql/ast/create_policy_stmt.go @@ -3,13 +3,13 @@ package ast type CreatePolicyStmt struct { Tag NodeTag[CreatePolicyStmt] `json:"tag"` - PolicyName *string - Table *RangeVar - CmdName *string + PolicyName *string `json:",omitempty"` + Table *RangeVar `json:",omitempty"` + CmdName *string `json:",omitempty"` Permissive bool - Roles *List - Qual Node - WithCheck Node + Roles *List `json:",omitempty"` + Qual Node `json:",omitempty"` + WithCheck Node `json:",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 562d3c0c90..e20a133d03 100644 --- a/internal/sql/ast/create_publication_stmt.go +++ b/internal/sql/ast/create_publication_stmt.go @@ -3,9 +3,9 @@ package ast type CreatePublicationStmt struct { Tag NodeTag[CreatePublicationStmt] `json:"tag"` - Pubname *string - Options *List - Tables *List + Pubname *string `json:",omitempty"` + Options *List `json:",omitempty"` + Tables *List `json:",omitempty"` ForAllTables bool } diff --git a/internal/sql/ast/create_range_stmt.go b/internal/sql/ast/create_range_stmt.go index 1b1173d9c4..f832d5ba2f 100644 --- a/internal/sql/ast/create_range_stmt.go +++ b/internal/sql/ast/create_range_stmt.go @@ -3,8 +3,8 @@ package ast type CreateRangeStmt struct { Tag NodeTag[CreateRangeStmt] `json:"tag"` - TypeName *List - Params *List + TypeName *List `json:",omitempty"` + Params *List `json:",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 815a41b05d..a9787e33ad 100644 --- a/internal/sql/ast/create_role_stmt.go +++ b/internal/sql/ast/create_role_stmt.go @@ -4,8 +4,8 @@ type CreateRoleStmt struct { Tag NodeTag[CreateRoleStmt] `json:"tag"` StmtType RoleStmtType - Role *string - Options *List + Role *string `json:",omitempty"` + Options *List `json:",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 46dee5035d..aaec484f10 100644 --- a/internal/sql/ast/create_schema_stmt.go +++ b/internal/sql/ast/create_schema_stmt.go @@ -3,9 +3,9 @@ package ast type CreateSchemaStmt struct { Tag NodeTag[CreateSchemaStmt] `json:"tag"` - Name *string - SchemaElts *List - Authrole *RoleSpec + Name *string `json:",omitempty"` + SchemaElts *List `json:",omitempty"` + Authrole *RoleSpec `json:",omitempty"` IfNotExists bool } diff --git a/internal/sql/ast/create_seq_stmt.go b/internal/sql/ast/create_seq_stmt.go index a194b669aa..2293841ed8 100644 --- a/internal/sql/ast/create_seq_stmt.go +++ b/internal/sql/ast/create_seq_stmt.go @@ -3,8 +3,8 @@ package ast type CreateSeqStmt struct { Tag NodeTag[CreateSeqStmt] `json:"tag"` - Sequence *RangeVar - Options *List + Sequence *RangeVar `json:",omitempty"` + Options *List `json:",omitempty"` OwnerId Oid ForIdentity bool IfNotExists bool diff --git a/internal/sql/ast/create_stats_stmt.go b/internal/sql/ast/create_stats_stmt.go index d34c13632b..53c82f4290 100644 --- a/internal/sql/ast/create_stats_stmt.go +++ b/internal/sql/ast/create_stats_stmt.go @@ -3,10 +3,10 @@ package ast type CreateStatsStmt struct { Tag NodeTag[CreateStatsStmt] `json:"tag"` - Defnames *List - StatTypes *List - Exprs *List - Relations *List + Defnames *List `json:",omitempty"` + StatTypes *List `json:",omitempty"` + Exprs *List `json:",omitempty"` + Relations *List `json:",omitempty"` IfNotExists bool } diff --git a/internal/sql/ast/create_stmt.go b/internal/sql/ast/create_stmt.go index 0fb58fadf8..da0721836a 100644 --- a/internal/sql/ast/create_stmt.go +++ b/internal/sql/ast/create_stmt.go @@ -3,16 +3,16 @@ package ast type CreateStmt struct { Tag NodeTag[CreateStmt] `json:"tag"` - Relation *RangeVar - TableElts *List - InhRelations *List - Partbound *PartitionBoundSpec - Partspec *PartitionSpec - OfTypename *TypeName - Constraints *List - Options *List + Relation *RangeVar `json:",omitempty"` + TableElts *List `json:",omitempty"` + InhRelations *List `json:",omitempty"` + Partbound *PartitionBoundSpec `json:",omitempty"` + Partspec *PartitionSpec `json:",omitempty"` + OfTypename *TypeName `json:",omitempty"` + Constraints *List `json:",omitempty"` + Options *List `json:",omitempty"` Oncommit OnCommitAction - Tablespacename *string + Tablespacename *string `json:",omitempty"` IfNotExists bool } diff --git a/internal/sql/ast/create_subscription_stmt.go b/internal/sql/ast/create_subscription_stmt.go index 909feae12e..db0d14943f 100644 --- a/internal/sql/ast/create_subscription_stmt.go +++ b/internal/sql/ast/create_subscription_stmt.go @@ -3,10 +3,10 @@ package ast type CreateSubscriptionStmt struct { Tag NodeTag[CreateSubscriptionStmt] `json:"tag"` - Subname *string - Conninfo *string - Publication *List - Options *List + Subname *string `json:",omitempty"` + Conninfo *string `json:",omitempty"` + Publication *List `json:",omitempty"` + Options *List `json:",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 88183f1852..66b24a0c97 100644 --- a/internal/sql/ast/create_table_as_stmt.go +++ b/internal/sql/ast/create_table_as_stmt.go @@ -3,8 +3,8 @@ package ast type CreateTableAsStmt struct { Tag NodeTag[CreateTableAsStmt] `json:"tag"` - Query Node - Into *IntoClause + Query Node `json:",omitempty"` + Into *IntoClause `json:",omitempty"` Relkind ObjectType IsSelectInto bool IfNotExists bool diff --git a/internal/sql/ast/create_table_space_stmt.go b/internal/sql/ast/create_table_space_stmt.go index aab46db149..2a1d6925d8 100644 --- a/internal/sql/ast/create_table_space_stmt.go +++ b/internal/sql/ast/create_table_space_stmt.go @@ -3,10 +3,10 @@ package ast type CreateTableSpaceStmt struct { Tag NodeTag[CreateTableSpaceStmt] `json:"tag"` - Tablespacename *string - Owner *RoleSpec - Location *string - Options *List + Tablespacename *string `json:",omitempty"` + Owner *RoleSpec `json:",omitempty"` + Location *string `json:",omitempty"` + Options *List `json:",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 6f73e907f0..637a0193f0 100644 --- a/internal/sql/ast/create_table_stmt.go +++ b/internal/sql/ast/create_table_stmt.go @@ -6,11 +6,11 @@ type CreateTableStmt struct { Tag NodeTag[CreateTableStmt] `json:"tag"` IfNotExists bool - Name *TableName - Cols []*ColumnDef - ReferTable *TableName + Name *TableName `json:",omitempty"` + Cols []*ColumnDef `json:",omitempty"` + ReferTable *TableName `json:",omitempty"` Comment string - Inherits []*TableName + Inherits []*TableName `json:",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 @@ -19,7 +19,7 @@ type CreateTableStmt struct { // the arguments for the catalog; the statement prints as its // declaration, not as those columns. Using string - ModuleArgs []string + ModuleArgs []string `json:",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 diff --git a/internal/sql/ast/create_transform_stmt.go b/internal/sql/ast/create_transform_stmt.go index 6fc67c78ef..f771c7c3d3 100644 --- a/internal/sql/ast/create_transform_stmt.go +++ b/internal/sql/ast/create_transform_stmt.go @@ -4,10 +4,10 @@ type CreateTransformStmt struct { Tag NodeTag[CreateTransformStmt] `json:"tag"` Replace bool - TypeName *TypeName - Lang *string - Fromsql *ObjectWithArgs - Tosql *ObjectWithArgs + TypeName *TypeName `json:",omitempty"` + Lang *string `json:",omitempty"` + Fromsql *ObjectWithArgs `json:",omitempty"` + Tosql *ObjectWithArgs `json:",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 2851e4ad07..8b1b422e39 100644 --- a/internal/sql/ast/create_trig_stmt.go +++ b/internal/sql/ast/create_trig_stmt.go @@ -3,20 +3,20 @@ package ast type CreateTrigStmt struct { Tag NodeTag[CreateTrigStmt] `json:"tag"` - Trigname *string - Relation *RangeVar - Funcname *List - Args *List + Trigname *string `json:",omitempty"` + Relation *RangeVar `json:",omitempty"` + Funcname *List `json:",omitempty"` + Args *List `json:",omitempty"` Row bool Timing int16 Events int16 - Columns *List - WhenClause Node + Columns *List `json:",omitempty"` + WhenClause Node `json:",omitempty"` Isconstraint bool - TransitionRels *List + TransitionRels *List `json:",omitempty"` Deferrable bool Initdeferred bool - Constrrel *RangeVar + Constrrel *RangeVar `json:",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 8a7a251ec1..bdbb03c766 100644 --- a/internal/sql/ast/create_user_mapping_stmt.go +++ b/internal/sql/ast/create_user_mapping_stmt.go @@ -3,10 +3,10 @@ package ast type CreateUserMappingStmt struct { Tag NodeTag[CreateUserMappingStmt] `json:"tag"` - User *RoleSpec - Servername *string + User *RoleSpec `json:",omitempty"` + Servername *string `json:",omitempty"` IfNotExists bool - Options *List + Options *List `json:",omitempty"` } func (n *CreateUserMappingStmt) Pos() int { diff --git a/internal/sql/ast/createdb_stmt.go b/internal/sql/ast/createdb_stmt.go index 9d4eb82c91..bf6a578b70 100644 --- a/internal/sql/ast/createdb_stmt.go +++ b/internal/sql/ast/createdb_stmt.go @@ -3,8 +3,8 @@ package ast type CreatedbStmt struct { Tag NodeTag[CreatedbStmt] `json:"tag"` - Dbname *string - Options *List + Dbname *string `json:",omitempty"` + Options *List `json:",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 103e11c9fe..37b7ab8bb9 100644 --- a/internal/sql/ast/current_of_expr.go +++ b/internal/sql/ast/current_of_expr.go @@ -3,9 +3,9 @@ package ast type CurrentOfExpr struct { Tag NodeTag[CurrentOfExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Cvarno Index - CursorName *string + CursorName *string `json:",omitempty"` CursorParam int } diff --git a/internal/sql/ast/deallocate_stmt.go b/internal/sql/ast/deallocate_stmt.go index 46066dbecc..5d82eaf573 100644 --- a/internal/sql/ast/deallocate_stmt.go +++ b/internal/sql/ast/deallocate_stmt.go @@ -3,7 +3,7 @@ package ast type DeallocateStmt struct { Tag NodeTag[DeallocateStmt] `json:"tag"` - Name *string + Name *string `json:",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 8e2b634c13..bb3ab62575 100644 --- a/internal/sql/ast/declare_cursor_stmt.go +++ b/internal/sql/ast/declare_cursor_stmt.go @@ -3,9 +3,9 @@ package ast type DeclareCursorStmt struct { Tag NodeTag[DeclareCursorStmt] `json:"tag"` - Portalname *string + Portalname *string `json:",omitempty"` Options int - Query Node + Query Node `json:",omitempty"` } func (n *DeclareCursorStmt) Pos() int { diff --git a/internal/sql/ast/def_elem.go b/internal/sql/ast/def_elem.go index c3219a1691..d7ce1108f8 100644 --- a/internal/sql/ast/def_elem.go +++ b/internal/sql/ast/def_elem.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type DefElem struct { Tag NodeTag[DefElem] `json:"tag"` - Defnamespace *string - Defname *string - Arg Node + Defnamespace *string `json:",omitempty"` + Defname *string `json:",omitempty"` + Arg Node `json:",omitempty"` Defaction DefElemAction Location int } diff --git a/internal/sql/ast/define_stmt.go b/internal/sql/ast/define_stmt.go index 76266ac9c7..51a4a0b4a0 100644 --- a/internal/sql/ast/define_stmt.go +++ b/internal/sql/ast/define_stmt.go @@ -5,9 +5,9 @@ type DefineStmt struct { Kind ObjectType Oldstyle bool - Defnames *List - Args *List - Definition *List + Defnames *List `json:",omitempty"` + Args *List `json:",omitempty"` + Definition *List `json:",omitempty"` IfNotExists bool } diff --git a/internal/sql/ast/delete_stmt.go b/internal/sql/ast/delete_stmt.go index 8919b0e367..64bbbc810d 100644 --- a/internal/sql/ast/delete_stmt.go +++ b/internal/sql/ast/delete_stmt.go @@ -5,15 +5,15 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type DeleteStmt struct { Tag NodeTag[DeleteStmt] `json:"tag"` - Relations *List - UsingClause *List - WhereClause Node - LimitCount Node - ReturningList *List - WithClause *WithClause + Relations *List `json:",omitempty"` + UsingClause *List `json:",omitempty"` + WhereClause Node `json:",omitempty"` + LimitCount Node `json:",omitempty"` + ReturningList *List `json:",omitempty"` + WithClause *WithClause `json:",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:",omitempty"` // Tables to delete from (e.g., jt.*, pt.*) + FromClause Node `json:",omitempty"` // FROM clause with JOINs (Node to support JoinExpr) // PostgreSQL 18 RETURNING WITH (OLD AS ..., NEW AS ...) aliases ReturningOldAlias string ReturningNewAlias string diff --git a/internal/sql/ast/do_stmt.go b/internal/sql/ast/do_stmt.go index 57e51246ff..415bc801c5 100644 --- a/internal/sql/ast/do_stmt.go +++ b/internal/sql/ast/do_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type DoStmt struct { Tag NodeTag[DoStmt] `json:"tag"` - Args *List + Args *List `json:",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 9ae735cbec..87bb06d63d 100644 --- a/internal/sql/ast/drop_function_stmt.go +++ b/internal/sql/ast/drop_function_stmt.go @@ -3,7 +3,7 @@ package ast type DropFunctionStmt struct { Tag NodeTag[DropFunctionStmt] `json:"tag"` - Funcs []*FuncSpec + Funcs []*FuncSpec `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/drop_owned_stmt.go b/internal/sql/ast/drop_owned_stmt.go index f48fd0f3fa..ab33bb36fa 100644 --- a/internal/sql/ast/drop_owned_stmt.go +++ b/internal/sql/ast/drop_owned_stmt.go @@ -3,7 +3,7 @@ package ast type DropOwnedStmt struct { Tag NodeTag[DropOwnedStmt] `json:"tag"` - Roles *List + Roles *List `json:",omitempty"` Behavior DropBehavior } diff --git a/internal/sql/ast/drop_role_stmt.go b/internal/sql/ast/drop_role_stmt.go index 2640fd8ad0..985989830a 100644 --- a/internal/sql/ast/drop_role_stmt.go +++ b/internal/sql/ast/drop_role_stmt.go @@ -3,7 +3,7 @@ package ast type DropRoleStmt struct { Tag NodeTag[DropRoleStmt] `json:"tag"` - Roles *List + Roles *List `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/drop_schema_stmt.go b/internal/sql/ast/drop_schema_stmt.go index b9afdbab55..7314a32f80 100644 --- a/internal/sql/ast/drop_schema_stmt.go +++ b/internal/sql/ast/drop_schema_stmt.go @@ -3,7 +3,7 @@ package ast type DropSchemaStmt struct { Tag NodeTag[DropSchemaStmt] `json:"tag"` - Schemas []*String + Schemas []*String `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/drop_stmt.go b/internal/sql/ast/drop_stmt.go index fa6a02e1fe..7e6e3c6fac 100644 --- a/internal/sql/ast/drop_stmt.go +++ b/internal/sql/ast/drop_stmt.go @@ -3,7 +3,7 @@ package ast type DropStmt struct { Tag NodeTag[DropStmt] `json:"tag"` - Objects *List + Objects *List `json:",omitempty"` RemoveType ObjectType Behavior DropBehavior MissingOk bool diff --git a/internal/sql/ast/drop_subscription_stmt.go b/internal/sql/ast/drop_subscription_stmt.go index d4656dce41..f095a22b3d 100644 --- a/internal/sql/ast/drop_subscription_stmt.go +++ b/internal/sql/ast/drop_subscription_stmt.go @@ -3,7 +3,7 @@ package ast type DropSubscriptionStmt struct { Tag NodeTag[DropSubscriptionStmt] `json:"tag"` - Subname *string + Subname *string `json:",omitempty"` MissingOk bool Behavior DropBehavior } diff --git a/internal/sql/ast/drop_table_space_stmt.go b/internal/sql/ast/drop_table_space_stmt.go index 26d0dd1959..740857d15d 100644 --- a/internal/sql/ast/drop_table_space_stmt.go +++ b/internal/sql/ast/drop_table_space_stmt.go @@ -3,7 +3,7 @@ package ast type DropTableSpaceStmt struct { Tag NodeTag[DropTableSpaceStmt] `json:"tag"` - Tablespacename *string + Tablespacename *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/drop_table_stmt.go b/internal/sql/ast/drop_table_stmt.go index f4343e768f..3e10641b1f 100644 --- a/internal/sql/ast/drop_table_stmt.go +++ b/internal/sql/ast/drop_table_stmt.go @@ -4,7 +4,7 @@ type DropTableStmt struct { Tag NodeTag[DropTableStmt] `json:"tag"` IfExists bool - Tables []*TableName + Tables []*TableName `json:",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 3de5234a2f..48b6472abd 100644 --- a/internal/sql/ast/drop_type_stmt.go +++ b/internal/sql/ast/drop_type_stmt.go @@ -4,7 +4,7 @@ type DropTypeStmt struct { Tag NodeTag[DropTypeStmt] `json:"tag"` IfExists bool - Types []*TypeName + Types []*TypeName `json:",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 bf9cb4b36a..5ece8988c0 100644 --- a/internal/sql/ast/drop_user_mapping_stmt.go +++ b/internal/sql/ast/drop_user_mapping_stmt.go @@ -3,8 +3,8 @@ package ast type DropUserMappingStmt struct { Tag NodeTag[DropUserMappingStmt] `json:"tag"` - User *RoleSpec - Servername *string + User *RoleSpec `json:",omitempty"` + Servername *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/dropdb_stmt.go b/internal/sql/ast/dropdb_stmt.go index 1577c1f6e5..c79e1b3e63 100644 --- a/internal/sql/ast/dropdb_stmt.go +++ b/internal/sql/ast/dropdb_stmt.go @@ -3,7 +3,7 @@ package ast type DropdbStmt struct { Tag NodeTag[DropdbStmt] `json:"tag"` - Dbname *string + Dbname *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/execute_stmt.go b/internal/sql/ast/execute_stmt.go index 31e267c8c9..18887523d4 100644 --- a/internal/sql/ast/execute_stmt.go +++ b/internal/sql/ast/execute_stmt.go @@ -3,8 +3,8 @@ package ast type ExecuteStmt struct { Tag NodeTag[ExecuteStmt] `json:"tag"` - Name *string - Params *List + Name *string `json:",omitempty"` + Params *List `json:",omitempty"` } func (n *ExecuteStmt) Pos() int { diff --git a/internal/sql/ast/explain_stmt.go b/internal/sql/ast/explain_stmt.go index c25d97cb31..3640293c53 100644 --- a/internal/sql/ast/explain_stmt.go +++ b/internal/sql/ast/explain_stmt.go @@ -3,8 +3,8 @@ package ast type ExplainStmt struct { Tag NodeTag[ExplainStmt] `json:"tag"` - Query Node - Options *List + Query Node `json:",omitempty"` + Options *List `json:",omitempty"` } func (n *ExplainStmt) Pos() int { diff --git a/internal/sql/ast/fetch_stmt.go b/internal/sql/ast/fetch_stmt.go index 72ad5ba65b..911a7781f9 100644 --- a/internal/sql/ast/fetch_stmt.go +++ b/internal/sql/ast/fetch_stmt.go @@ -5,7 +5,7 @@ type FetchStmt struct { Direction FetchDirection HowMany int64 - Portalname *string + Portalname *string `json:",omitempty"` Ismove bool } diff --git a/internal/sql/ast/field_select.go b/internal/sql/ast/field_select.go index b6c36594bd..e82482877e 100644 --- a/internal/sql/ast/field_select.go +++ b/internal/sql/ast/field_select.go @@ -3,8 +3,8 @@ package ast type FieldSelect struct { Tag NodeTag[FieldSelect] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Fieldnum AttrNumber Resulttype Oid Resulttypmod int32 diff --git a/internal/sql/ast/field_store.go b/internal/sql/ast/field_store.go index 29a00aa25a..4755a9c06b 100644 --- a/internal/sql/ast/field_store.go +++ b/internal/sql/ast/field_store.go @@ -3,10 +3,10 @@ package ast type FieldStore struct { Tag NodeTag[FieldStore] `json:"tag"` - Xpr Node - Arg Node - Newvals *List - Fieldnums *List + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` + Newvals *List `json:",omitempty"` + Fieldnums *List `json:",omitempty"` Resulttype Oid } diff --git a/internal/sql/ast/from_expr.go b/internal/sql/ast/from_expr.go index df74c9a98b..2f11a9571a 100644 --- a/internal/sql/ast/from_expr.go +++ b/internal/sql/ast/from_expr.go @@ -3,8 +3,8 @@ package ast type FromExpr struct { Tag NodeTag[FromExpr] `json:"tag"` - Fromlist *List - Quals Node + Fromlist *List `json:",omitempty"` + Quals Node `json:",omitempty"` } func (n *FromExpr) Pos() int { diff --git a/internal/sql/ast/func_call.go b/internal/sql/ast/func_call.go index a38a15ee8e..c4157877fc 100644 --- a/internal/sql/ast/func_call.go +++ b/internal/sql/ast/func_call.go @@ -5,17 +5,17 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncCall struct { Tag NodeTag[FuncCall] `json:"tag"` - Func *FuncName - Funcname *List - Args *List - AggOrder *List - AggFilter Node + Func *FuncName `json:",omitempty"` + Funcname *List `json:",omitempty"` + Args *List `json:",omitempty"` + AggOrder *List `json:",omitempty"` + AggFilter Node `json:",omitempty"` AggWithinGroup bool AggStar bool AggDistinct bool FuncVariadic bool - Over *WindowDef - Separator *string // MySQL GROUP_CONCAT SEPARATOR + Over *WindowDef `json:",omitempty"` + Separator *string `json:",omitempty"` // MySQL GROUP_CONCAT SEPARATOR Location int } diff --git a/internal/sql/ast/func_expr.go b/internal/sql/ast/func_expr.go index cb580a472d..45c4e31e16 100644 --- a/internal/sql/ast/func_expr.go +++ b/internal/sql/ast/func_expr.go @@ -3,7 +3,7 @@ package ast type FuncExpr struct { Tag NodeTag[FuncExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Funcid Oid Funcresulttype Oid Funcretset bool @@ -11,7 +11,7 @@ type FuncExpr struct { Funcformat CoercionForm Funccollid Oid Inputcollid Oid - Args *List + Args *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/func_param.go b/internal/sql/ast/func_param.go index 9a95c40da9..0c52b3ebe3 100644 --- a/internal/sql/ast/func_param.go +++ b/internal/sql/ast/func_param.go @@ -16,9 +16,9 @@ const ( type FuncParam struct { Tag NodeTag[FuncParam] `json:"tag"` - Name *string - Type *TypeName - DefExpr Node // Will always be &ast.TODO + Name *string `json:",omitempty"` + Type *TypeName `json:",omitempty"` + DefExpr Node `json:",omitempty"` // Will always be &ast.TODO Mode FuncParamMode } diff --git a/internal/sql/ast/func_spec.go b/internal/sql/ast/func_spec.go index bad51b9c81..beab892975 100644 --- a/internal/sql/ast/func_spec.go +++ b/internal/sql/ast/func_spec.go @@ -3,8 +3,8 @@ package ast type FuncSpec struct { Tag NodeTag[FuncSpec] `json:"tag"` - Name *FuncName - Args []*TypeName + Name *FuncName `json:",omitempty"` + Args []*TypeName `json:",omitempty"` HasArgs bool } diff --git a/internal/sql/ast/function_parameter.go b/internal/sql/ast/function_parameter.go index 433ebfbb35..69d5e6386f 100644 --- a/internal/sql/ast/function_parameter.go +++ b/internal/sql/ast/function_parameter.go @@ -3,10 +3,10 @@ package ast type FunctionParameter struct { Tag NodeTag[FunctionParameter] `json:"tag"` - Name *string - ArgType *TypeName + Name *string `json:",omitempty"` + ArgType *TypeName `json:",omitempty"` Mode FunctionParameterMode - Defexpr Node + Defexpr Node `json:",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 e6ca89b339..32f36b779e 100644 --- a/internal/sql/ast/grant_role_stmt.go +++ b/internal/sql/ast/grant_role_stmt.go @@ -3,10 +3,10 @@ package ast type GrantRoleStmt struct { Tag NodeTag[GrantRoleStmt] `json:"tag"` - GrantedRoles *List - GranteeRoles *List + GrantedRoles *List `json:",omitempty"` + GranteeRoles *List `json:",omitempty"` IsGrant bool - Grantor *RoleSpec + Grantor *RoleSpec `json:",omitempty"` Behavior DropBehavior } diff --git a/internal/sql/ast/grant_stmt.go b/internal/sql/ast/grant_stmt.go index b25f82630c..9ff2d6dd4d 100644 --- a/internal/sql/ast/grant_stmt.go +++ b/internal/sql/ast/grant_stmt.go @@ -6,9 +6,9 @@ type GrantStmt struct { IsGrant bool Targtype GrantTargetType Objtype GrantObjectType - Objects *List - Privileges *List - Grantees *List + Objects *List `json:",omitempty"` + Privileges *List `json:",omitempty"` + Grantees *List `json:",omitempty"` GrantOption bool Behavior DropBehavior } diff --git a/internal/sql/ast/grouping_func.go b/internal/sql/ast/grouping_func.go index 1c9eb6b1de..7a52bcc5d7 100644 --- a/internal/sql/ast/grouping_func.go +++ b/internal/sql/ast/grouping_func.go @@ -3,10 +3,10 @@ package ast type GroupingFunc struct { Tag NodeTag[GroupingFunc] `json:"tag"` - Xpr Node - Args *List - Refs *List - Cols *List + Xpr Node `json:",omitempty"` + Args *List `json:",omitempty"` + Refs *List `json:",omitempty"` + Cols *List `json:",omitempty"` Agglevelsup Index Location int } diff --git a/internal/sql/ast/grouping_set.go b/internal/sql/ast/grouping_set.go index 084179efed..ddb14f436d 100644 --- a/internal/sql/ast/grouping_set.go +++ b/internal/sql/ast/grouping_set.go @@ -4,7 +4,7 @@ type GroupingSet struct { Tag NodeTag[GroupingSet] `json:"tag"` Kind GroupingSetKind - Content *List + Content *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/import_foreign_schema_stmt.go b/internal/sql/ast/import_foreign_schema_stmt.go index 25fa4ef2cd..92f7e768eb 100644 --- a/internal/sql/ast/import_foreign_schema_stmt.go +++ b/internal/sql/ast/import_foreign_schema_stmt.go @@ -3,12 +3,12 @@ package ast type ImportForeignSchemaStmt struct { Tag NodeTag[ImportForeignSchemaStmt] `json:"tag"` - ServerName *string - RemoteSchema *string - LocalSchema *string + ServerName *string `json:",omitempty"` + RemoteSchema *string `json:",omitempty"` + LocalSchema *string `json:",omitempty"` ListType ImportForeignSchemaType - TableList *List - Options *List + TableList *List `json:",omitempty"` + Options *List `json:",omitempty"` } func (n *ImportForeignSchemaStmt) Pos() int { diff --git a/internal/sql/ast/in.go b/internal/sql/ast/in.go index c3d0a0d692..7be470d022 100644 --- a/internal/sql/ast/in.go +++ b/internal/sql/ast/in.go @@ -7,13 +7,13 @@ type In struct { Tag NodeTag[In] `json:"tag"` // Expr is the value expression to be compared. - Expr Node + Expr Node `json:",omitempty"` // List is the list expression in compare list. - List []Node + List []Node `json:",omitempty"` // Not is true, the expression is "not in". Not bool // Sel is the subquery, may be rewritten to other type of expression. - Sel Node + Sel Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/index_elem.go b/internal/sql/ast/index_elem.go index d6f5c7d8d0..4b61798a1a 100644 --- a/internal/sql/ast/index_elem.go +++ b/internal/sql/ast/index_elem.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type IndexElem struct { Tag NodeTag[IndexElem] `json:"tag"` - Name *string - Expr Node - Indexcolname *string - Collation *List - Opclass *List + Name *string `json:",omitempty"` + Expr Node `json:",omitempty"` + Indexcolname *string `json:",omitempty"` + Collation *List `json:",omitempty"` + Opclass *List `json:",omitempty"` Ordering SortByDir NullsOrdering SortByNulls } diff --git a/internal/sql/ast/index_stmt.go b/internal/sql/ast/index_stmt.go index b4d96d2fd4..ec12c6ba32 100644 --- a/internal/sql/ast/index_stmt.go +++ b/internal/sql/ast/index_stmt.go @@ -3,15 +3,15 @@ package ast type IndexStmt struct { Tag NodeTag[IndexStmt] `json:"tag"` - Idxname *string - Relation *RangeVar - AccessMethod *string - TableSpace *string - IndexParams *List - Options *List - WhereClause Node - ExcludeOpNames *List - Idxcomment *string + Idxname *string `json:",omitempty"` + Relation *RangeVar `json:",omitempty"` + AccessMethod *string `json:",omitempty"` + TableSpace *string `json:",omitempty"` + IndexParams *List `json:",omitempty"` + Options *List `json:",omitempty"` + WhereClause Node `json:",omitempty"` + ExcludeOpNames *List `json:",omitempty"` + Idxcomment *string `json:",omitempty"` IndexOid Oid Unique bool Primary bool diff --git a/internal/sql/ast/infer_clause.go b/internal/sql/ast/infer_clause.go index 709b602395..d51381b0fb 100644 --- a/internal/sql/ast/infer_clause.go +++ b/internal/sql/ast/infer_clause.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type InferClause struct { Tag NodeTag[InferClause] `json:"tag"` - IndexElems *List - WhereClause Node - Conname *string + IndexElems *List `json:",omitempty"` + WhereClause Node `json:",omitempty"` + Conname *string `json:",omitempty"` Location int } diff --git a/internal/sql/ast/inference_elem.go b/internal/sql/ast/inference_elem.go index d9af3cb713..fde931e796 100644 --- a/internal/sql/ast/inference_elem.go +++ b/internal/sql/ast/inference_elem.go @@ -3,8 +3,8 @@ package ast type InferenceElem struct { Tag NodeTag[InferenceElem] `json:"tag"` - Xpr Node - Expr Node + Xpr Node `json:",omitempty"` + Expr Node `json:",omitempty"` Infercollid Oid Inferopclass Oid } diff --git a/internal/sql/ast/inline_code_block.go b/internal/sql/ast/inline_code_block.go index be7bf53c31..fc675cb4b4 100644 --- a/internal/sql/ast/inline_code_block.go +++ b/internal/sql/ast/inline_code_block.go @@ -3,7 +3,7 @@ package ast type InlineCodeBlock struct { Tag NodeTag[InlineCodeBlock] `json:"tag"` - SourceText *string + SourceText *string `json:",omitempty"` LangOid Oid LangIsTrusted bool } diff --git a/internal/sql/ast/insert_stmt.go b/internal/sql/ast/insert_stmt.go index 90329d0c3b..dd1ddb9672 100644 --- a/internal/sql/ast/insert_stmt.go +++ b/internal/sql/ast/insert_stmt.go @@ -5,13 +5,13 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type InsertStmt struct { Tag NodeTag[InsertStmt] `json:"tag"` - Relation *RangeVar - Cols *List - SelectStmt Node - OnConflictClause *OnConflictClause - OnDuplicateKeyUpdate *OnDuplicateKeyUpdate // MySQL-specific - ReturningList *List - WithClause *WithClause + Relation *RangeVar `json:",omitempty"` + Cols *List `json:",omitempty"` + SelectStmt Node `json:",omitempty"` + OnConflictClause *OnConflictClause `json:",omitempty"` + OnDuplicateKeyUpdate *OnDuplicateKeyUpdate `json:",omitempty"` // MySQL-specific + ReturningList *List `json:",omitempty"` + WithClause *WithClause `json:",omitempty"` Override OverridingKind DefaultValues bool // SQLite-specific: INSERT INTO ... DEFAULT VALUES // PostgreSQL 18 RETURNING WITH (OLD AS ..., NEW AS ...) aliases diff --git a/internal/sql/ast/interval_expr.go b/internal/sql/ast/interval_expr.go index 4bd191d505..69300c95c1 100644 --- a/internal/sql/ast/interval_expr.go +++ b/internal/sql/ast/interval_expr.go @@ -6,7 +6,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type IntervalExpr struct { Tag NodeTag[IntervalExpr] `json:"tag"` - Value Node + Value Node `json:",omitempty"` Unit string Location int } diff --git a/internal/sql/ast/into_clause.go b/internal/sql/ast/into_clause.go index ec28a7fd63..37940527bd 100644 --- a/internal/sql/ast/into_clause.go +++ b/internal/sql/ast/into_clause.go @@ -3,12 +3,12 @@ package ast type IntoClause struct { Tag NodeTag[IntoClause] `json:"tag"` - Rel *RangeVar - ColNames *List - Options *List + Rel *RangeVar `json:",omitempty"` + ColNames *List `json:",omitempty"` + Options *List `json:",omitempty"` OnCommit OnCommitAction - TableSpaceName *string - ViewQuery Node + TableSpaceName *string `json:",omitempty"` + ViewQuery Node `json:",omitempty"` SkipData bool } diff --git a/internal/sql/ast/join_expr.go b/internal/sql/ast/join_expr.go index 3713f82751..7d56b17055 100644 --- a/internal/sql/ast/join_expr.go +++ b/internal/sql/ast/join_expr.go @@ -7,11 +7,11 @@ type JoinExpr struct { Jointype JoinType IsNatural bool - Larg Node - Rarg Node - UsingClause *List - Quals Node - Alias *Alias + Larg Node `json:",omitempty"` + Rarg Node `json:",omitempty"` + UsingClause *List `json:",omitempty"` + Quals Node `json:",omitempty"` + Alias *Alias `json:",omitempty"` Rtindex int } diff --git a/internal/sql/ast/list.go b/internal/sql/ast/list.go index 0a061bbd60..27cfc4402b 100644 --- a/internal/sql/ast/list.go +++ b/internal/sql/ast/list.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type List struct { Tag NodeTag[List] `json:"tag"` - Items []Node + Items []Node `json:",omitempty"` } func (n *List) Pos() int { diff --git a/internal/sql/ast/listen_stmt.go b/internal/sql/ast/listen_stmt.go index ef33ab1903..44dcd983b5 100644 --- a/internal/sql/ast/listen_stmt.go +++ b/internal/sql/ast/listen_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ListenStmt struct { Tag NodeTag[ListenStmt] `json:"tag"` - Conditionname *string + Conditionname *string `json:",omitempty"` } func (n *ListenStmt) Pos() int { diff --git a/internal/sql/ast/load_stmt.go b/internal/sql/ast/load_stmt.go index 0ac3335156..4c1d3fc0b1 100644 --- a/internal/sql/ast/load_stmt.go +++ b/internal/sql/ast/load_stmt.go @@ -3,7 +3,7 @@ package ast type LoadStmt struct { Tag NodeTag[LoadStmt] `json:"tag"` - Filename *string + Filename *string `json:",omitempty"` } func (n *LoadStmt) Pos() int { diff --git a/internal/sql/ast/lock_stmt.go b/internal/sql/ast/lock_stmt.go index 13b84fc8aa..e965da7bdf 100644 --- a/internal/sql/ast/lock_stmt.go +++ b/internal/sql/ast/lock_stmt.go @@ -3,7 +3,7 @@ package ast type LockStmt struct { Tag NodeTag[LockStmt] `json:"tag"` - Relations *List + Relations *List `json:",omitempty"` Mode int Nowait bool } diff --git a/internal/sql/ast/locking_clause.go b/internal/sql/ast/locking_clause.go index ca0c57eacc..6ae01dd96e 100644 --- a/internal/sql/ast/locking_clause.go +++ b/internal/sql/ast/locking_clause.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type LockingClause struct { Tag NodeTag[LockingClause] `json:"tag"` - LockedRels *List + LockedRels *List `json:",omitempty"` Strength LockClauseStrength WaitPolicy LockWaitPolicy } diff --git a/internal/sql/ast/min_max_expr.go b/internal/sql/ast/min_max_expr.go index 628ac8fcb7..d256611574 100644 --- a/internal/sql/ast/min_max_expr.go +++ b/internal/sql/ast/min_max_expr.go @@ -3,12 +3,12 @@ package ast type MinMaxExpr struct { Tag NodeTag[MinMaxExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Minmaxtype Oid Minmaxcollid Oid Inputcollid Oid Op MinMaxOp - Args *List + Args *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/multi_assign_ref.go b/internal/sql/ast/multi_assign_ref.go index 68b25c99a7..4c3833563c 100644 --- a/internal/sql/ast/multi_assign_ref.go +++ b/internal/sql/ast/multi_assign_ref.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type MultiAssignRef struct { Tag NodeTag[MultiAssignRef] `json:"tag"` - Source Node + Source Node `json:",omitempty"` Colno int Ncolumns int } diff --git a/internal/sql/ast/named_arg_expr.go b/internal/sql/ast/named_arg_expr.go index de7fcccdcd..53ea100e6a 100644 --- a/internal/sql/ast/named_arg_expr.go +++ b/internal/sql/ast/named_arg_expr.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type NamedArgExpr struct { Tag NodeTag[NamedArgExpr] `json:"tag"` - Xpr Node - Arg Node - Name *string + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` + Name *string `json:",omitempty"` Argnumber int Location int } diff --git a/internal/sql/ast/next_value_expr.go b/internal/sql/ast/next_value_expr.go index 21c4034b29..4b21a3ae39 100644 --- a/internal/sql/ast/next_value_expr.go +++ b/internal/sql/ast/next_value_expr.go @@ -3,7 +3,7 @@ package ast type NextValueExpr struct { Tag NodeTag[NextValueExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Seqid Oid TypeId Oid } diff --git a/internal/sql/ast/notify_stmt.go b/internal/sql/ast/notify_stmt.go index 1ac9719d48..d915d10d2d 100644 --- a/internal/sql/ast/notify_stmt.go +++ b/internal/sql/ast/notify_stmt.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type NotifyStmt struct { Tag NodeTag[NotifyStmt] `json:"tag"` - Conditionname *string - Payload *string + Conditionname *string `json:",omitempty"` + Payload *string `json:",omitempty"` } func (n *NotifyStmt) Pos() int { diff --git a/internal/sql/ast/null_test_expr.go b/internal/sql/ast/null_test_expr.go index 8ecdce15dd..db93888623 100644 --- a/internal/sql/ast/null_test_expr.go +++ b/internal/sql/ast/null_test_expr.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type NullTest struct { Tag NodeTag[NullTest] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Nulltesttype NullTestType Argisrow bool Location int diff --git a/internal/sql/ast/object_with_args.go b/internal/sql/ast/object_with_args.go index d1f5361671..f9a0640780 100644 --- a/internal/sql/ast/object_with_args.go +++ b/internal/sql/ast/object_with_args.go @@ -3,8 +3,8 @@ package ast type ObjectWithArgs struct { Tag NodeTag[ObjectWithArgs] `json:"tag"` - Objname *List - Objargs *List + Objname *List `json:",omitempty"` + Objargs *List `json:",omitempty"` ArgsUnspecified bool } diff --git a/internal/sql/ast/on_conflict_clause.go b/internal/sql/ast/on_conflict_clause.go index 934873fbe8..55eb45b48c 100644 --- a/internal/sql/ast/on_conflict_clause.go +++ b/internal/sql/ast/on_conflict_clause.go @@ -6,9 +6,9 @@ type OnConflictClause struct { Tag NodeTag[OnConflictClause] `json:"tag"` Action OnConflictAction - Infer *InferClause - TargetList *List - WhereClause Node + Infer *InferClause `json:",omitempty"` + TargetList *List `json:",omitempty"` + WhereClause Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/on_conflict_expr.go b/internal/sql/ast/on_conflict_expr.go index c76f7794bd..07c7a31be0 100644 --- a/internal/sql/ast/on_conflict_expr.go +++ b/internal/sql/ast/on_conflict_expr.go @@ -4,13 +4,13 @@ type OnConflictExpr struct { Tag NodeTag[OnConflictExpr] `json:"tag"` Action OnConflictAction - ArbiterElems *List - ArbiterWhere Node + ArbiterElems *List `json:",omitempty"` + ArbiterWhere Node `json:",omitempty"` Constraint Oid - OnConflictSet *List - OnConflictWhere Node + OnConflictSet *List `json:",omitempty"` + OnConflictWhere Node `json:",omitempty"` ExclRelIndex int - ExclRelTlist *List + ExclRelTlist *List `json:",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 137681ef52..2b767f5545 100644 --- a/internal/sql/ast/on_duplicate_key_update.go +++ b/internal/sql/ast/on_duplicate_key_update.go @@ -7,7 +7,7 @@ type OnDuplicateKeyUpdate struct { Tag NodeTag[OnDuplicateKeyUpdate] `json:"tag"` // TargetList contains the assignments (column = value pairs) - TargetList *List + TargetList *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/op_expr.go b/internal/sql/ast/op_expr.go index 55cd391b03..ce7d352b1d 100644 --- a/internal/sql/ast/op_expr.go +++ b/internal/sql/ast/op_expr.go @@ -3,13 +3,13 @@ package ast type OpExpr struct { Tag NodeTag[OpExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Opno Oid Opresulttype Oid Opretset bool Opcollid Oid Inputcollid Oid - Args *List + Args *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/param.go b/internal/sql/ast/param.go index 14a8c73ebc..289148237c 100644 --- a/internal/sql/ast/param.go +++ b/internal/sql/ast/param.go @@ -3,7 +3,7 @@ package ast type Param struct { Tag NodeTag[Param] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Paramkind ParamKind Paramid int Paramtype Oid diff --git a/internal/sql/ast/param_exec_data.go b/internal/sql/ast/param_exec_data.go index 9f032e0a94..9221d88f1e 100644 --- a/internal/sql/ast/param_exec_data.go +++ b/internal/sql/ast/param_exec_data.go @@ -3,7 +3,7 @@ package ast type ParamExecData struct { Tag NodeTag[ParamExecData] `json:"tag"` - ExecPlan any + ExecPlan any `json:",omitempty"` Value Datum Isnull bool } diff --git a/internal/sql/ast/param_list_info_data.go b/internal/sql/ast/param_list_info_data.go index 6ec93b100b..2f28d88bdf 100644 --- a/internal/sql/ast/param_list_info_data.go +++ b/internal/sql/ast/param_list_info_data.go @@ -3,10 +3,10 @@ package ast type ParamListInfoData struct { Tag NodeTag[ParamListInfoData] `json:"tag"` - ParamFetchArg any - ParserSetupArg any + ParamFetchArg any `json:",omitempty"` + ParserSetupArg any `json:",omitempty"` NumParams int - ParamMask []uint32 + ParamMask []uint32 `json:",omitempty"` } func (n *ParamListInfoData) Pos() int { diff --git a/internal/sql/ast/paren_expr.go b/internal/sql/ast/paren_expr.go index a0b580643d..c8f2ab7f6f 100644 --- a/internal/sql/ast/paren_expr.go +++ b/internal/sql/ast/paren_expr.go @@ -6,7 +6,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ParenExpr struct { Tag NodeTag[ParenExpr] `json:"tag"` - Expr Node + Expr Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/partition_bound_spec.go b/internal/sql/ast/partition_bound_spec.go index e15fbbb7b7..830ef66e7b 100644 --- a/internal/sql/ast/partition_bound_spec.go +++ b/internal/sql/ast/partition_bound_spec.go @@ -4,9 +4,9 @@ type PartitionBoundSpec struct { Tag NodeTag[PartitionBoundSpec] `json:"tag"` Strategy byte - Listdatums *List - Lowerdatums *List - Upperdatums *List + Listdatums *List `json:",omitempty"` + Lowerdatums *List `json:",omitempty"` + Upperdatums *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/partition_cmd.go b/internal/sql/ast/partition_cmd.go index c5d28b72f9..472d884b1e 100644 --- a/internal/sql/ast/partition_cmd.go +++ b/internal/sql/ast/partition_cmd.go @@ -3,8 +3,8 @@ package ast type PartitionCmd struct { Tag NodeTag[PartitionCmd] `json:"tag"` - Name *RangeVar - Bound *PartitionBoundSpec + Name *RangeVar `json:",omitempty"` + Bound *PartitionBoundSpec `json:",omitempty"` } func (n *PartitionCmd) Pos() int { diff --git a/internal/sql/ast/partition_elem.go b/internal/sql/ast/partition_elem.go index ba39e7d13c..e53ea5cadf 100644 --- a/internal/sql/ast/partition_elem.go +++ b/internal/sql/ast/partition_elem.go @@ -3,10 +3,10 @@ package ast type PartitionElem struct { Tag NodeTag[PartitionElem] `json:"tag"` - Name *string - Expr Node - Collation *List - Opclass *List + Name *string `json:",omitempty"` + Expr Node `json:",omitempty"` + Collation *List `json:",omitempty"` + Opclass *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/partition_range_datum.go b/internal/sql/ast/partition_range_datum.go index ae519716d8..7ec4aa119f 100644 --- a/internal/sql/ast/partition_range_datum.go +++ b/internal/sql/ast/partition_range_datum.go @@ -4,7 +4,7 @@ type PartitionRangeDatum struct { Tag NodeTag[PartitionRangeDatum] `json:"tag"` Kind PartitionRangeDatumKind - Value Node + Value Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/partition_spec.go b/internal/sql/ast/partition_spec.go index 9a989a9581..7e1d2c594a 100644 --- a/internal/sql/ast/partition_spec.go +++ b/internal/sql/ast/partition_spec.go @@ -3,8 +3,8 @@ package ast type PartitionSpec struct { Tag NodeTag[PartitionSpec] `json:"tag"` - Strategy *string - PartParams *List + Strategy *string `json:",omitempty"` + PartParams *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/prepare_stmt.go b/internal/sql/ast/prepare_stmt.go index be91f3242e..cad6109be1 100644 --- a/internal/sql/ast/prepare_stmt.go +++ b/internal/sql/ast/prepare_stmt.go @@ -3,9 +3,9 @@ package ast type PrepareStmt struct { Tag NodeTag[PrepareStmt] `json:"tag"` - Name *string - Argtypes *List - Query Node + Name *string `json:",omitempty"` + Argtypes *List `json:",omitempty"` + Query Node `json:",omitempty"` } func (n *PrepareStmt) Pos() int { diff --git a/internal/sql/ast/query.go b/internal/sql/ast/query.go index 257cdc8b84..2c2248f5e8 100644 --- a/internal/sql/ast/query.go +++ b/internal/sql/ast/query.go @@ -7,7 +7,7 @@ type Query struct { QuerySource QuerySource QueryId uint32 CanSetTag bool - UtilityStmt Node + UtilityStmt Node `json:",omitempty"` ResultRelation int HasAggs bool HasWindowFuncs bool @@ -18,25 +18,25 @@ type Query struct { HasModifyingCte bool HasForUpdate bool HasRowSecurity bool - CteList *List - Rtable *List - Jointree *FromExpr - TargetList *List + CteList *List `json:",omitempty"` + Rtable *List `json:",omitempty"` + Jointree *FromExpr `json:",omitempty"` + TargetList *List `json:",omitempty"` 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 + OnConflict *OnConflictExpr `json:",omitempty"` + ReturningList *List `json:",omitempty"` + GroupClause *List `json:",omitempty"` + GroupingSets *List `json:",omitempty"` + HavingQual Node `json:",omitempty"` + WindowClause *List `json:",omitempty"` + DistinctClause *List `json:",omitempty"` + SortClause *List `json:",omitempty"` + LimitOffset Node `json:",omitempty"` + LimitCount Node `json:",omitempty"` + RowMarks *List `json:",omitempty"` + SetOperations Node `json:",omitempty"` + ConstraintDeps *List `json:",omitempty"` + WithCheckOptions *List `json:",omitempty"` StmtLocation int StmtLen int } diff --git a/internal/sql/ast/range_function.go b/internal/sql/ast/range_function.go index bcaf71ea9c..5144ec5975 100644 --- a/internal/sql/ast/range_function.go +++ b/internal/sql/ast/range_function.go @@ -8,9 +8,9 @@ type RangeFunction struct { Lateral bool Ordinality bool IsRowsfrom bool - Functions *List - Alias *Alias - Coldeflist *List + Functions *List `json:",omitempty"` + Alias *Alias `json:",omitempty"` + Coldeflist *List `json:",omitempty"` } func (n *RangeFunction) Pos() int { diff --git a/internal/sql/ast/range_subselect.go b/internal/sql/ast/range_subselect.go index e90b87365a..d51e279d2b 100644 --- a/internal/sql/ast/range_subselect.go +++ b/internal/sql/ast/range_subselect.go @@ -6,8 +6,8 @@ type RangeSubselect struct { Tag NodeTag[RangeSubselect] `json:"tag"` Lateral bool - Subquery Node - Alias *Alias + Subquery Node `json:",omitempty"` + Alias *Alias `json:",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 8ae783649d..fa858b64ce 100644 --- a/internal/sql/ast/range_table_func.go +++ b/internal/sql/ast/range_table_func.go @@ -4,11 +4,11 @@ type RangeTableFunc struct { Tag NodeTag[RangeTableFunc] `json:"tag"` Lateral bool - Docexpr Node - Rowexpr Node - Namespaces *List - Columns *List - Alias *Alias + Docexpr Node `json:",omitempty"` + Rowexpr Node `json:",omitempty"` + Namespaces *List `json:",omitempty"` + Columns *List `json:",omitempty"` + Alias *Alias `json:",omitempty"` Location int } diff --git a/internal/sql/ast/range_table_func_col.go b/internal/sql/ast/range_table_func_col.go index aefd35d155..5b23218519 100644 --- a/internal/sql/ast/range_table_func_col.go +++ b/internal/sql/ast/range_table_func_col.go @@ -3,12 +3,12 @@ package ast type RangeTableFuncCol struct { Tag NodeTag[RangeTableFuncCol] `json:"tag"` - Colname *string - TypeName *TypeName + Colname *string `json:",omitempty"` + TypeName *TypeName `json:",omitempty"` ForOrdinality bool IsNotNull bool - Colexpr Node - Coldefexpr Node + Colexpr Node `json:",omitempty"` + Coldefexpr Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/range_table_sample.go b/internal/sql/ast/range_table_sample.go index 92c1900a9f..db9f3c9c10 100644 --- a/internal/sql/ast/range_table_sample.go +++ b/internal/sql/ast/range_table_sample.go @@ -3,10 +3,10 @@ package ast type RangeTableSample struct { Tag NodeTag[RangeTableSample] `json:"tag"` - Relation Node - Method *List - Args *List - Repeatable Node + Relation Node `json:",omitempty"` + Method *List `json:",omitempty"` + Args *List `json:",omitempty"` + Repeatable Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/range_tbl_entry.go b/internal/sql/ast/range_tbl_entry.go index 5a79d9c026..5fb822048e 100644 --- a/internal/sql/ast/range_tbl_entry.go +++ b/internal/sql/ast/range_tbl_entry.go @@ -6,34 +6,34 @@ type RangeTblEntry struct { Rtekind RTEKind Relid Oid Relkind byte - Tablesample *TableSampleClause - Subquery *Query + Tablesample *TableSampleClause `json:",omitempty"` + Subquery *Query `json:",omitempty"` SecurityBarrier bool Jointype JoinType - Joinaliasvars *List - Functions *List + Joinaliasvars *List `json:",omitempty"` + Functions *List `json:",omitempty"` Funcordinality bool - Tablefunc *TableFunc - ValuesLists *List - Ctename *string + Tablefunc *TableFunc `json:",omitempty"` + ValuesLists *List `json:",omitempty"` + Ctename *string `json:",omitempty"` Ctelevelsup Index SelfReference bool - Coltypes *List - Coltypmods *List - Colcollations *List - Enrname *string + Coltypes *List `json:",omitempty"` + Coltypmods *List `json:",omitempty"` + Colcollations *List `json:",omitempty"` + Enrname *string `json:",omitempty"` Enrtuples float64 - Alias *Alias - Eref *Alias + Alias *Alias `json:",omitempty"` + Eref *Alias `json:",omitempty"` Lateral bool Inh bool InFromCl bool RequiredPerms AclMode CheckAsUser Oid - SelectedCols []uint32 - InsertedCols []uint32 - UpdatedCols []uint32 - SecurityQuals *List + SelectedCols []uint32 `json:",omitempty"` + InsertedCols []uint32 `json:",omitempty"` + UpdatedCols []uint32 `json:",omitempty"` + SecurityQuals *List `json:",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 a77bdae6a8..09412058bc 100644 --- a/internal/sql/ast/range_tbl_function.go +++ b/internal/sql/ast/range_tbl_function.go @@ -3,13 +3,13 @@ package ast type RangeTblFunction struct { Tag NodeTag[RangeTblFunction] `json:"tag"` - Funcexpr Node + Funcexpr Node `json:",omitempty"` Funccolcount int - Funccolnames *List - Funccoltypes *List - Funccoltypmods *List - Funccolcollations *List - Funcparams []uint32 + Funccolnames *List `json:",omitempty"` + Funccoltypes *List `json:",omitempty"` + Funccoltypmods *List `json:",omitempty"` + Funccolcollations *List `json:",omitempty"` + Funcparams []uint32 `json:",omitempty"` } func (n *RangeTblFunction) Pos() int { diff --git a/internal/sql/ast/range_var.go b/internal/sql/ast/range_var.go index 24b0e13214..3359a58459 100644 --- a/internal/sql/ast/range_var.go +++ b/internal/sql/ast/range_var.go @@ -5,12 +5,12 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeVar struct { Tag NodeTag[RangeVar] `json:"tag"` - Catalogname *string - Schemaname *string - Relname *string + Catalogname *string `json:",omitempty"` + Schemaname *string `json:",omitempty"` + Relname *string `json:",omitempty"` Inh bool Relpersistence byte - Alias *Alias + Alias *Alias `json:",omitempty"` Location int } diff --git a/internal/sql/ast/raw_stmt.go b/internal/sql/ast/raw_stmt.go index a037d93cbd..4b7c096159 100644 --- a/internal/sql/ast/raw_stmt.go +++ b/internal/sql/ast/raw_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RawStmt struct { Tag NodeTag[RawStmt] `json:"tag"` - Stmt Node + Stmt Node `json:",omitempty"` StmtLocation int StmtLen int } diff --git a/internal/sql/ast/reassign_owned_stmt.go b/internal/sql/ast/reassign_owned_stmt.go index 53f5306fe0..c2e903febe 100644 --- a/internal/sql/ast/reassign_owned_stmt.go +++ b/internal/sql/ast/reassign_owned_stmt.go @@ -3,8 +3,8 @@ package ast type ReassignOwnedStmt struct { Tag NodeTag[ReassignOwnedStmt] `json:"tag"` - Roles *List - Newrole *RoleSpec + Roles *List `json:",omitempty"` + Newrole *RoleSpec `json:",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 058ffa86de..e9d765ba4a 100644 --- a/internal/sql/ast/refresh_mat_view_stmt.go +++ b/internal/sql/ast/refresh_mat_view_stmt.go @@ -7,7 +7,7 @@ type RefreshMatViewStmt struct { Concurrent bool SkipData bool - Relation *RangeVar + Relation *RangeVar `json:",omitempty"` } func (n *RefreshMatViewStmt) Pos() int { diff --git a/internal/sql/ast/reindex_stmt.go b/internal/sql/ast/reindex_stmt.go index 52e33be7ea..10908aa29a 100644 --- a/internal/sql/ast/reindex_stmt.go +++ b/internal/sql/ast/reindex_stmt.go @@ -4,8 +4,8 @@ type ReindexStmt struct { Tag NodeTag[ReindexStmt] `json:"tag"` Kind ReindexObjectType - Relation *RangeVar - Name *string + Relation *RangeVar `json:",omitempty"` + Name *string `json:",omitempty"` Options int } diff --git a/internal/sql/ast/relabel_type.go b/internal/sql/ast/relabel_type.go index eccb6819e3..aa36edc7e7 100644 --- a/internal/sql/ast/relabel_type.go +++ b/internal/sql/ast/relabel_type.go @@ -3,8 +3,8 @@ package ast type RelabelType struct { Tag NodeTag[RelabelType] `json:"tag"` - Xpr Node - Arg Node + Xpr Node `json:",omitempty"` + Arg Node `json:",omitempty"` Resulttype Oid Resulttypmod int32 Resultcollid Oid diff --git a/internal/sql/ast/rename_column_stmt.go b/internal/sql/ast/rename_column_stmt.go index 2164c2b2d7..90f07c2de7 100644 --- a/internal/sql/ast/rename_column_stmt.go +++ b/internal/sql/ast/rename_column_stmt.go @@ -3,9 +3,9 @@ package ast type RenameColumnStmt struct { Tag NodeTag[RenameColumnStmt] `json:"tag"` - Table *TableName - Col *ColumnRef - NewName *string + Table *TableName `json:",omitempty"` + Col *ColumnRef `json:",omitempty"` + NewName *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/rename_stmt.go b/internal/sql/ast/rename_stmt.go index c52adb42fd..a7854f96ba 100644 --- a/internal/sql/ast/rename_stmt.go +++ b/internal/sql/ast/rename_stmt.go @@ -5,10 +5,10 @@ type RenameStmt struct { RenameType ObjectType RelationType ObjectType - Relation *RangeVar - Object Node - Subname *string - Newname *string + Relation *RangeVar `json:",omitempty"` + Object Node `json:",omitempty"` + Subname *string `json:",omitempty"` + Newname *string `json:",omitempty"` Behavior DropBehavior MissingOk bool } diff --git a/internal/sql/ast/rename_table_stmt.go b/internal/sql/ast/rename_table_stmt.go index 6a2d53b825..32ea76e9af 100644 --- a/internal/sql/ast/rename_table_stmt.go +++ b/internal/sql/ast/rename_table_stmt.go @@ -3,8 +3,8 @@ package ast type RenameTableStmt struct { Tag NodeTag[RenameTableStmt] `json:"tag"` - Table *TableName - NewName *string + Table *TableName `json:",omitempty"` + NewName *string `json:",omitempty"` MissingOk bool } diff --git a/internal/sql/ast/rename_type_stmt.go b/internal/sql/ast/rename_type_stmt.go index 0eaa0932be..1b73dbffc0 100644 --- a/internal/sql/ast/rename_type_stmt.go +++ b/internal/sql/ast/rename_type_stmt.go @@ -3,8 +3,8 @@ package ast type RenameTypeStmt struct { Tag NodeTag[RenameTypeStmt] `json:"tag"` - Type *TypeName - NewName *string + Type *TypeName `json:",omitempty"` + NewName *string `json:",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 109218aa17..ab89eadf80 100644 --- a/internal/sql/ast/replica_identity_stmt.go +++ b/internal/sql/ast/replica_identity_stmt.go @@ -4,7 +4,7 @@ type ReplicaIdentityStmt struct { Tag NodeTag[ReplicaIdentityStmt] `json:"tag"` IdentityType byte - Name *string + Name *string `json:",omitempty"` } func (n *ReplicaIdentityStmt) Pos() int { diff --git a/internal/sql/ast/res_target.go b/internal/sql/ast/res_target.go index 4afbdae02e..4e6307dec6 100644 --- a/internal/sql/ast/res_target.go +++ b/internal/sql/ast/res_target.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ResTarget struct { Tag NodeTag[ResTarget] `json:"tag"` - Name *string - Indirection *List - Val Node + Name *string `json:",omitempty"` + Indirection *List `json:",omitempty"` + Val Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/role_spec.go b/internal/sql/ast/role_spec.go index 0681e0377e..9ae819c367 100644 --- a/internal/sql/ast/role_spec.go +++ b/internal/sql/ast/role_spec.go @@ -4,7 +4,7 @@ type RoleSpec struct { Tag NodeTag[RoleSpec] `json:"tag"` Roletype RoleSpecType - Rolename *string + Rolename *string `json:",omitempty"` Location int } diff --git a/internal/sql/ast/row_compare_expr.go b/internal/sql/ast/row_compare_expr.go index e7ef6dc4c2..44fe3506e5 100644 --- a/internal/sql/ast/row_compare_expr.go +++ b/internal/sql/ast/row_compare_expr.go @@ -3,13 +3,13 @@ package ast type RowCompareExpr struct { Tag NodeTag[RowCompareExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Rctype RowCompareType - Opnos *List - Opfamilies *List - Inputcollids *List - Largs *List - Rargs *List + Opnos *List `json:",omitempty"` + Opfamilies *List `json:",omitempty"` + Inputcollids *List `json:",omitempty"` + Largs *List `json:",omitempty"` + Rargs *List `json:",omitempty"` } func (n *RowCompareExpr) Pos() int { diff --git a/internal/sql/ast/row_expr.go b/internal/sql/ast/row_expr.go index 6409a355a2..1942afe671 100644 --- a/internal/sql/ast/row_expr.go +++ b/internal/sql/ast/row_expr.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RowExpr struct { Tag NodeTag[RowExpr] `json:"tag"` - Xpr Node - Args *List + Xpr Node `json:",omitempty"` + Args *List `json:",omitempty"` RowTypeid Oid RowFormat CoercionForm - Colnames *List + Colnames *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/rule_stmt.go b/internal/sql/ast/rule_stmt.go index 0d3ad61958..dd0143e7e3 100644 --- a/internal/sql/ast/rule_stmt.go +++ b/internal/sql/ast/rule_stmt.go @@ -3,12 +3,12 @@ package ast type RuleStmt struct { Tag NodeTag[RuleStmt] `json:"tag"` - Relation *RangeVar - Rulename *string - WhereClause Node + Relation *RangeVar `json:",omitempty"` + Rulename *string `json:",omitempty"` + WhereClause Node `json:",omitempty"` Event CmdType Instead bool - Actions *List + Actions *List `json:",omitempty"` Replace bool } diff --git a/internal/sql/ast/scalar_array_op_expr.go b/internal/sql/ast/scalar_array_op_expr.go index 3163fbd988..186a9f12e1 100644 --- a/internal/sql/ast/scalar_array_op_expr.go +++ b/internal/sql/ast/scalar_array_op_expr.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ScalarArrayOpExpr struct { Tag NodeTag[ScalarArrayOpExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Opno Oid UseOr bool Inputcollid Oid - Args *List + Args *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/sec_label_stmt.go b/internal/sql/ast/sec_label_stmt.go index 39e1df1c40..b3e40cb4ff 100644 --- a/internal/sql/ast/sec_label_stmt.go +++ b/internal/sql/ast/sec_label_stmt.go @@ -4,9 +4,9 @@ type SecLabelStmt struct { Tag NodeTag[SecLabelStmt] `json:"tag"` Objtype ObjectType - Object Node - Provider *string - Label *string + Object Node `json:",omitempty"` + Provider *string `json:",omitempty"` + Label *string `json:",omitempty"` } func (n *SecLabelStmt) Pos() int { diff --git a/internal/sql/ast/select_stmt.go b/internal/sql/ast/select_stmt.go index 755647e829..b15d6e3236 100644 --- a/internal/sql/ast/select_stmt.go +++ b/internal/sql/ast/select_stmt.go @@ -7,24 +7,24 @@ import ( type SelectStmt struct { Tag NodeTag[SelectStmt] `json:"tag"` - 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 + DistinctClause *List `json:",omitempty"` + IntoClause *IntoClause `json:",omitempty"` + TargetList *List `json:",omitempty"` + FromClause *List `json:",omitempty"` + WhereClause Node `json:",omitempty"` + GroupClause *List `json:",omitempty"` + HavingClause Node `json:",omitempty"` + WindowClause *List `json:",omitempty"` + ValuesLists *List `json:",omitempty"` + SortClause *List `json:",omitempty"` + LimitOffset Node `json:",omitempty"` + LimitCount Node `json:",omitempty"` + LockingClause *List `json:",omitempty"` + WithClause *WithClause `json:",omitempty"` Op SetOperation All bool - Larg *SelectStmt - Rarg *SelectStmt + Larg *SelectStmt `json:",omitempty"` + Rarg *SelectStmt `json:",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 f96534903c..32f27184f4 100644 --- a/internal/sql/ast/set_operation_stmt.go +++ b/internal/sql/ast/set_operation_stmt.go @@ -5,12 +5,12 @@ type SetOperationStmt struct { Op SetOperation All bool - Larg Node - Rarg Node - ColTypes *List - ColTypmods *List - ColCollations *List - GroupClauses *List + Larg Node `json:",omitempty"` + Rarg Node `json:",omitempty"` + ColTypes *List `json:",omitempty"` + ColTypmods *List `json:",omitempty"` + ColCollations *List `json:",omitempty"` + GroupClauses *List `json:",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 cca5fbc7a7..100dfb2293 100644 --- a/internal/sql/ast/set_to_default.go +++ b/internal/sql/ast/set_to_default.go @@ -3,7 +3,7 @@ package ast type SetToDefault struct { Tag NodeTag[SetToDefault] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` TypeId Oid TypeMod int32 Collation Oid diff --git a/internal/sql/ast/sort_by.go b/internal/sql/ast/sort_by.go index de6c9eb2cc..31d9cf63b6 100644 --- a/internal/sql/ast/sort_by.go +++ b/internal/sql/ast/sort_by.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type SortBy struct { Tag NodeTag[SortBy] `json:"tag"` - Node Node + Node Node `json:",omitempty"` SortbyDir SortByDir SortbyNulls SortByNulls - UseOp *List + UseOp *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/sql_value_function.go b/internal/sql/ast/sql_value_function.go index c4efd63df9..570d25233b 100644 --- a/internal/sql/ast/sql_value_function.go +++ b/internal/sql/ast/sql_value_function.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type SQLValueFunction struct { Tag NodeTag[SQLValueFunction] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Op SQLValueFunctionOp Type Oid Typmod int32 diff --git a/internal/sql/ast/statement.go b/internal/sql/ast/statement.go index 3668d4530d..c62ddb1eb1 100644 --- a/internal/sql/ast/statement.go +++ b/internal/sql/ast/statement.go @@ -3,7 +3,7 @@ package ast type Statement struct { Tag NodeTag[Statement] `json:"tag"` - Raw *RawStmt + Raw *RawStmt `json:",omitempty"` } func (n *Statement) Pos() int { diff --git a/internal/sql/ast/sub_link.go b/internal/sql/ast/sub_link.go index 8645663f9d..7226874e43 100644 --- a/internal/sql/ast/sub_link.go +++ b/internal/sql/ast/sub_link.go @@ -18,12 +18,12 @@ const ( type SubLink struct { Tag NodeTag[SubLink] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` SubLinkType SubLinkType SubLinkId int - Testexpr Node - OperName *List - Subselect Node + Testexpr Node `json:",omitempty"` + OperName *List `json:",omitempty"` + Subselect Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/sub_plan.go b/internal/sql/ast/sub_plan.go index 060ba9f28e..9e6eecdea4 100644 --- a/internal/sql/ast/sub_plan.go +++ b/internal/sql/ast/sub_plan.go @@ -3,21 +3,21 @@ package ast type SubPlan struct { Tag NodeTag[SubPlan] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` SubLinkType SubLinkType - Testexpr Node - ParamIds *List + Testexpr Node `json:",omitempty"` + ParamIds *List `json:",omitempty"` PlanId int - PlanName *string + PlanName *string `json:",omitempty"` FirstColType Oid FirstColTypmod int32 FirstColCollation Oid UseHashTable bool UnknownEqFalse bool ParallelSafe bool - SetParam *List - ParParam *List - Args *List + SetParam *List `json:",omitempty"` + ParParam *List `json:",omitempty"` + Args *List `json:",omitempty"` StartupCost Cost PerCallCost Cost } diff --git a/internal/sql/ast/table_func.go b/internal/sql/ast/table_func.go index 2d341da226..cd831db75e 100644 --- a/internal/sql/ast/table_func.go +++ b/internal/sql/ast/table_func.go @@ -3,17 +3,17 @@ package ast type TableFunc struct { Tag NodeTag[TableFunc] `json:"tag"` - NsUris *List - NsNames *List - Docexpr Node - Rowexpr Node - Colnames *List - Coltypes *List - Coltypmods *List - Colcollations *List - Colexprs *List - Coldefexprs *List - Notnulls []uint32 + NsUris *List `json:",omitempty"` + NsNames *List `json:",omitempty"` + Docexpr Node `json:",omitempty"` + Rowexpr Node `json:",omitempty"` + Colnames *List `json:",omitempty"` + Coltypes *List `json:",omitempty"` + Coltypmods *List `json:",omitempty"` + Colcollations *List `json:",omitempty"` + Colexprs *List `json:",omitempty"` + Coldefexprs *List `json:",omitempty"` + Notnulls []uint32 `json:",omitempty"` Ordinalitycol int Location int } diff --git a/internal/sql/ast/table_like_clause.go b/internal/sql/ast/table_like_clause.go index 54f68dbf25..c71c1b79e2 100644 --- a/internal/sql/ast/table_like_clause.go +++ b/internal/sql/ast/table_like_clause.go @@ -3,7 +3,7 @@ package ast type TableLikeClause struct { Tag NodeTag[TableLikeClause] `json:"tag"` - Relation *RangeVar + Relation *RangeVar `json:",omitempty"` Options uint32 } diff --git a/internal/sql/ast/table_sample_clause.go b/internal/sql/ast/table_sample_clause.go index c5e78f9796..130d3ccfad 100644 --- a/internal/sql/ast/table_sample_clause.go +++ b/internal/sql/ast/table_sample_clause.go @@ -4,8 +4,8 @@ type TableSampleClause struct { Tag NodeTag[TableSampleClause] `json:"tag"` Tsmhandler Oid - Args *List - Repeatable Node + Args *List `json:",omitempty"` + Repeatable Node `json:",omitempty"` } func (n *TableSampleClause) Pos() int { diff --git a/internal/sql/ast/target_entry.go b/internal/sql/ast/target_entry.go index a35dcaa6b0..3f7247e1d5 100644 --- a/internal/sql/ast/target_entry.go +++ b/internal/sql/ast/target_entry.go @@ -3,10 +3,10 @@ package ast type TargetEntry struct { Tag NodeTag[TargetEntry] `json:"tag"` - Xpr Node - Expr Node + Xpr Node `json:",omitempty"` + Expr Node `json:",omitempty"` Resno AttrNumber - Resname *string + Resname *string `json:",omitempty"` Ressortgroupref Index Resorigtbl Oid Resorigcol AttrNumber diff --git a/internal/sql/ast/transaction_stmt.go b/internal/sql/ast/transaction_stmt.go index e22a2fb620..515adb8172 100644 --- a/internal/sql/ast/transaction_stmt.go +++ b/internal/sql/ast/transaction_stmt.go @@ -4,8 +4,8 @@ type TransactionStmt struct { Tag NodeTag[TransactionStmt] `json:"tag"` Kind TransactionStmtKind - Options *List - Gid *string + Options *List `json:",omitempty"` + Gid *string `json:",omitempty"` } func (n *TransactionStmt) Pos() int { diff --git a/internal/sql/ast/trigger_transition.go b/internal/sql/ast/trigger_transition.go index a4e177b307..d13650f948 100644 --- a/internal/sql/ast/trigger_transition.go +++ b/internal/sql/ast/trigger_transition.go @@ -3,7 +3,7 @@ package ast type TriggerTransition struct { Tag NodeTag[TriggerTransition] `json:"tag"` - Name *string + Name *string `json:",omitempty"` IsNew bool IsTable bool } diff --git a/internal/sql/ast/truncate_stmt.go b/internal/sql/ast/truncate_stmt.go index 4d07c09ac7..11d4662da9 100644 --- a/internal/sql/ast/truncate_stmt.go +++ b/internal/sql/ast/truncate_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type TruncateStmt struct { Tag NodeTag[TruncateStmt] `json:"tag"` - Relations *List + Relations *List `json:",omitempty"` RestartSeqs bool Behavior DropBehavior } diff --git a/internal/sql/ast/type_cast.go b/internal/sql/ast/type_cast.go index 299b9244dc..b909583b95 100644 --- a/internal/sql/ast/type_cast.go +++ b/internal/sql/ast/type_cast.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeCast struct { Tag NodeTag[TypeCast] `json:"tag"` - Arg Node - TypeName *TypeName + Arg Node `json:",omitempty"` + TypeName *TypeName `json:",omitempty"` Location int } diff --git a/internal/sql/ast/type_name.go b/internal/sql/ast/type_name.go index 7fee688272..4ba26dd196 100644 --- a/internal/sql/ast/type_name.go +++ b/internal/sql/ast/type_name.go @@ -15,13 +15,13 @@ type TypeName struct { Spelling string // From pg.TypeName - Names *List + Names *List `json:",omitempty"` TypeOid Oid Setof bool PctType bool - Typmods *List + Typmods *List `json:",omitempty"` Typemod int32 - ArrayBounds *List + ArrayBounds *List `json:",omitempty"` Location int } diff --git a/internal/sql/ast/unlisten_stmt.go b/internal/sql/ast/unlisten_stmt.go index 719b82ab21..99219c3836 100644 --- a/internal/sql/ast/unlisten_stmt.go +++ b/internal/sql/ast/unlisten_stmt.go @@ -3,7 +3,7 @@ package ast type UnlistenStmt struct { Tag NodeTag[UnlistenStmt] `json:"tag"` - Conditionname *string + Conditionname *string `json:",omitempty"` } func (n *UnlistenStmt) Pos() int { diff --git a/internal/sql/ast/update_stmt.go b/internal/sql/ast/update_stmt.go index 2eb5cca674..6a129631c4 100644 --- a/internal/sql/ast/update_stmt.go +++ b/internal/sql/ast/update_stmt.go @@ -9,13 +9,13 @@ import ( type UpdateStmt struct { Tag NodeTag[UpdateStmt] `json:"tag"` - Relations *List - TargetList *List - WhereClause Node - FromClause *List - LimitCount Node - ReturningList *List - WithClause *WithClause + Relations *List `json:",omitempty"` + TargetList *List `json:",omitempty"` + WhereClause Node `json:",omitempty"` + FromClause *List `json:",omitempty"` + LimitCount Node `json:",omitempty"` + ReturningList *List `json:",omitempty"` + WithClause *WithClause `json:",omitempty"` // PostgreSQL 18 RETURNING WITH (OLD AS ..., NEW AS ...) aliases ReturningOldAlias string ReturningNewAlias string diff --git a/internal/sql/ast/vacuum_stmt.go b/internal/sql/ast/vacuum_stmt.go index cf310a0943..ecc51969d9 100644 --- a/internal/sql/ast/vacuum_stmt.go +++ b/internal/sql/ast/vacuum_stmt.go @@ -4,8 +4,8 @@ type VacuumStmt struct { Tag NodeTag[VacuumStmt] `json:"tag"` Options int - Relation *RangeVar - VaCols *List + Relation *RangeVar `json:",omitempty"` + VaCols *List `json:",omitempty"` } func (n *VacuumStmt) Pos() int { diff --git a/internal/sql/ast/var.go b/internal/sql/ast/var.go index 7ba8835a7a..52b47ecefd 100644 --- a/internal/sql/ast/var.go +++ b/internal/sql/ast/var.go @@ -3,7 +3,7 @@ package ast type Var struct { Tag NodeTag[Var] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Varno Index Varattno AttrNumber Vartype Oid diff --git a/internal/sql/ast/variable_set_stmt.go b/internal/sql/ast/variable_set_stmt.go index 50c6e8f1c8..4c4760aad3 100644 --- a/internal/sql/ast/variable_set_stmt.go +++ b/internal/sql/ast/variable_set_stmt.go @@ -4,8 +4,8 @@ type VariableSetStmt struct { Tag NodeTag[VariableSetStmt] `json:"tag"` Kind VariableSetKind - Name *string - Args *List + Name *string `json:",omitempty"` + Args *List `json:",omitempty"` IsLocal bool } diff --git a/internal/sql/ast/variable_show_stmt.go b/internal/sql/ast/variable_show_stmt.go index f0b518f9ec..edbddd566b 100644 --- a/internal/sql/ast/variable_show_stmt.go +++ b/internal/sql/ast/variable_show_stmt.go @@ -3,7 +3,7 @@ package ast type VariableShowStmt struct { Tag NodeTag[VariableShowStmt] `json:"tag"` - Name *string + Name *string `json:",omitempty"` } func (n *VariableShowStmt) Pos() int { diff --git a/internal/sql/ast/view_stmt.go b/internal/sql/ast/view_stmt.go index 320c32c43e..1943db06ab 100644 --- a/internal/sql/ast/view_stmt.go +++ b/internal/sql/ast/view_stmt.go @@ -3,11 +3,11 @@ package ast type ViewStmt struct { Tag NodeTag[ViewStmt] `json:"tag"` - View *RangeVar - Aliases *List - Query Node + View *RangeVar `json:",omitempty"` + Aliases *List `json:",omitempty"` + Query Node `json:",omitempty"` Replace bool - Options *List + Options *List `json:",omitempty"` WithCheckOption ViewCheckOption } diff --git a/internal/sql/ast/window_clause.go b/internal/sql/ast/window_clause.go index 68612605b2..19460c4879 100644 --- a/internal/sql/ast/window_clause.go +++ b/internal/sql/ast/window_clause.go @@ -3,13 +3,13 @@ package ast type WindowClause struct { Tag NodeTag[WindowClause] `json:"tag"` - Name *string - Refname *string - PartitionClause *List - OrderClause *List + Name *string `json:",omitempty"` + Refname *string `json:",omitempty"` + PartitionClause *List `json:",omitempty"` + OrderClause *List `json:",omitempty"` FrameOptions int - StartOffset Node - EndOffset Node + StartOffset Node `json:",omitempty"` + EndOffset Node `json:",omitempty"` Winref Index CopiedOrder bool } diff --git a/internal/sql/ast/window_def.go b/internal/sql/ast/window_def.go index 2164a38773..6da3590776 100644 --- a/internal/sql/ast/window_def.go +++ b/internal/sql/ast/window_def.go @@ -5,13 +5,13 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type WindowDef struct { Tag NodeTag[WindowDef] `json:"tag"` - Name *string - Refname *string - PartitionClause *List - OrderClause *List + Name *string `json:",omitempty"` + Refname *string `json:",omitempty"` + PartitionClause *List `json:",omitempty"` + OrderClause *List `json:",omitempty"` FrameOptions int - StartOffset Node - EndOffset Node + StartOffset Node `json:",omitempty"` + EndOffset Node `json:",omitempty"` Location int } diff --git a/internal/sql/ast/window_func.go b/internal/sql/ast/window_func.go index 606848a9e1..6ff42c1a91 100644 --- a/internal/sql/ast/window_func.go +++ b/internal/sql/ast/window_func.go @@ -3,13 +3,13 @@ package ast type WindowFunc struct { Tag NodeTag[WindowFunc] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Winfnoid Oid Wintype Oid Wincollid Oid Inputcollid Oid - Args *List - Aggfilter Node + Args *List `json:",omitempty"` + Aggfilter Node `json:",omitempty"` Winref Index Winstar bool Winagg bool diff --git a/internal/sql/ast/with_check_option.go b/internal/sql/ast/with_check_option.go index 9448b10631..b7b085dc89 100644 --- a/internal/sql/ast/with_check_option.go +++ b/internal/sql/ast/with_check_option.go @@ -4,9 +4,9 @@ type WithCheckOption struct { Tag NodeTag[WithCheckOption] `json:"tag"` Kind WCOKind - Relname *string - Polname *string - Qual Node + Relname *string `json:",omitempty"` + Polname *string `json:",omitempty"` + Qual Node `json:",omitempty"` Cascaded bool } diff --git a/internal/sql/ast/with_clause.go b/internal/sql/ast/with_clause.go index a601970628..a9fd02c448 100644 --- a/internal/sql/ast/with_clause.go +++ b/internal/sql/ast/with_clause.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type WithClause struct { Tag NodeTag[WithClause] `json:"tag"` - Ctes *List + Ctes *List `json:",omitempty"` Recursive bool Location int } diff --git a/internal/sql/ast/xml_expr.go b/internal/sql/ast/xml_expr.go index 715e854530..0f3fd0f67d 100644 --- a/internal/sql/ast/xml_expr.go +++ b/internal/sql/ast/xml_expr.go @@ -3,12 +3,12 @@ package ast type XmlExpr struct { Tag NodeTag[XmlExpr] `json:"tag"` - Xpr Node + Xpr Node `json:",omitempty"` Op XmlExprOp - Name *string - NamedArgs *List - ArgNames *List - Args *List + Name *string `json:",omitempty"` + NamedArgs *List `json:",omitempty"` + ArgNames *List `json:",omitempty"` + Args *List `json:",omitempty"` Xmloption XmlOptionType Type Oid Typmod int32 diff --git a/internal/sql/ast/xml_serialize.go b/internal/sql/ast/xml_serialize.go index 0d06dd9d53..08df728a78 100644 --- a/internal/sql/ast/xml_serialize.go +++ b/internal/sql/ast/xml_serialize.go @@ -4,8 +4,8 @@ type XmlSerialize struct { Tag NodeTag[XmlSerialize] `json:"tag"` Xmloption XmlOptionType - Expr Node - TypeName *TypeName + Expr Node `json:",omitempty"` + TypeName *TypeName `json:",omitempty"` Location int } From fd144c61a09ed05fa0f54bd0d500bd43546364e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Aug 2026 03:51:08 +0000 Subject: [PATCH 3/4] ast: snake_case field names in JSON output Give every node field an explicit json tag with the snake_case form of its name: StmtLocation prints as stmt_location, FromClause as from_clause. The keys now read as JSON rather than as Go leaking through, and they match the names libpg_query uses for the same fields in its own JSON output, so anyone coming from pg_query's tree finds the fields where they expect them. The tags also stop the output from being coupled to the Go field names: a field rename is now a compile-time-visible decision about the JSON, not a silent output change. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01T9LCt1mwdY3mE14x3Zz5Vw --- docs/howto/parse.md | 31 ++++--- .../analyze_ast/postgresql/stdout.txt | 92 +++++++++---------- .../parse_basic/clickhouse/stdout.txt | 24 ++--- .../testdata/parse_basic/duckdb/stdout.txt | 24 ++--- .../testdata/parse_basic/googlesql/stdout.txt | 24 ++--- .../testdata/parse_basic/mssql/stdout.txt | 24 ++--- .../testdata/parse_basic/mysql/stdout.txt | 30 +++--- .../parse_basic/postgresql/stdout.txt | 48 +++++----- .../testdata/parse_basic/sqlite/stdout.txt | 32 +++---- internal/sql/ast/a_array_expr.go | 4 +- internal/sql/ast/a_const.go | 4 +- internal/sql/ast/a_expr.go | 10 +- internal/sql/ast/a_indices.go | 6 +- internal/sql/ast/a_indirection.go | 4 +- internal/sql/ast/access_priv.go | 4 +- internal/sql/ast/aggref.go | 34 +++---- internal/sql/ast/alias.go | 4 +- internal/sql/ast/alter_collation_stmt.go | 2 +- internal/sql/ast/alter_database_set_stmt.go | 4 +- internal/sql/ast/alter_database_stmt.go | 4 +- .../sql/ast/alter_default_privileges_stmt.go | 4 +- internal/sql/ast/alter_domain_stmt.go | 12 +-- internal/sql/ast/alter_enum_stmt.go | 12 +-- internal/sql/ast/alter_event_trig_stmt.go | 4 +- .../sql/ast/alter_extension_contents_stmt.go | 8 +- internal/sql/ast/alter_extension_stmt.go | 4 +- internal/sql/ast/alter_fdw_stmt.go | 6 +- internal/sql/ast/alter_foreign_server_stmt.go | 8 +- internal/sql/ast/alter_function_stmt.go | 4 +- internal/sql/ast/alter_object_depends_stmt.go | 8 +- internal/sql/ast/alter_object_schema_stmt.go | 10 +- internal/sql/ast/alter_op_family_stmt.go | 8 +- internal/sql/ast/alter_operator_stmt.go | 4 +- internal/sql/ast/alter_owner_stmt.go | 8 +- internal/sql/ast/alter_policy_stmt.go | 10 +- internal/sql/ast/alter_publication_stmt.go | 10 +- internal/sql/ast/alter_role_set_stmt.go | 6 +- internal/sql/ast/alter_role_stmt.go | 6 +- internal/sql/ast/alter_seq_stmt.go | 8 +- internal/sql/ast/alter_subscription_stmt.go | 10 +- internal/sql/ast/alter_system_stmt.go | 2 +- internal/sql/ast/alter_table_cmd.go | 12 +-- internal/sql/ast/alter_table_move_all_stmt.go | 10 +- .../sql/ast/alter_table_set_schema_stmt.go | 6 +- .../sql/ast/alter_table_space_options_stmt.go | 6 +- internal/sql/ast/alter_table_stmt.go | 12 +-- .../sql/ast/alter_ts_configuration_stmt.go | 14 +-- internal/sql/ast/alter_ts_dictionary_stmt.go | 4 +- internal/sql/ast/alter_type_add_value_stmt.go | 12 +-- .../sql/ast/alter_type_rename_value_stmt.go | 6 +- .../sql/ast/alter_type_set_schema_stmt.go | 4 +- internal/sql/ast/alter_user_mapping_stmt.go | 6 +- internal/sql/ast/alternative_sub_plan.go | 4 +- internal/sql/ast/array_coerce_expr.go | 18 ++-- internal/sql/ast/array_expr.go | 14 +-- internal/sql/ast/array_ref.go | 18 ++-- internal/sql/ast/between_expr.go | 10 +- internal/sql/ast/bit_string.go | 2 +- internal/sql/ast/block_id_data.go | 4 +- internal/sql/ast/bool_expr.go | 8 +- internal/sql/ast/boolean.go | 2 +- internal/sql/ast/boolean_test_expr.go | 8 +- internal/sql/ast/call_stmt.go | 2 +- internal/sql/ast/case_expr.go | 14 +-- internal/sql/ast/case_test_expr.go | 8 +- internal/sql/ast/case_when.go | 8 +- internal/sql/ast/close_portal_stmt.go | 2 +- internal/sql/ast/cluster_stmt.go | 6 +- internal/sql/ast/coalesce_expr.go | 10 +- internal/sql/ast/coerce_to_domain.go | 14 +-- internal/sql/ast/coerce_to_domain_value.go | 10 +- internal/sql/ast/coerce_via_io.go | 12 +-- internal/sql/ast/collate_clause.go | 6 +- internal/sql/ast/collate_expr.go | 8 +- internal/sql/ast/column_def.go | 50 +++++----- internal/sql/ast/column_ref.go | 6 +- internal/sql/ast/comment.go | 4 +- internal/sql/ast/comment_on_column_stmt.go | 6 +- internal/sql/ast/comment_on_schema_stmt.go | 4 +- internal/sql/ast/comment_on_table_stmt.go | 4 +- internal/sql/ast/comment_on_type_stmt.go | 4 +- internal/sql/ast/comment_on_view_stmt.go | 4 +- internal/sql/ast/comment_stmt.go | 6 +- internal/sql/ast/common_table_expr.go | 20 ++-- internal/sql/ast/composite_type_stmt.go | 2 +- internal/sql/ast/const.go | 18 ++-- internal/sql/ast/constraint.go | 52 +++++------ internal/sql/ast/constraints_set_stmt.go | 4 +- internal/sql/ast/convert_rowtype_expr.go | 10 +- internal/sql/ast/copy_stmt.go | 14 +-- internal/sql/ast/create_am_stmt.go | 6 +- internal/sql/ast/create_cast_stmt.go | 10 +- internal/sql/ast/create_conversion_stmt.go | 10 +- internal/sql/ast/create_domain_stmt.go | 8 +- internal/sql/ast/create_enum_stmt.go | 4 +- internal/sql/ast/create_event_trig_stmt.go | 8 +- internal/sql/ast/create_extension_stmt.go | 6 +- internal/sql/ast/create_fdw_stmt.go | 6 +- .../sql/ast/create_foreign_server_stmt.go | 12 +-- internal/sql/ast/create_foreign_table_stmt.go | 6 +- internal/sql/ast/create_function_stmt.go | 12 +-- internal/sql/ast/create_op_class_item.go | 12 +-- internal/sql/ast/create_op_class_stmt.go | 12 +-- internal/sql/ast/create_op_family_stmt.go | 4 +- internal/sql/ast/create_p_lang_stmt.go | 12 +-- internal/sql/ast/create_policy_stmt.go | 14 +-- internal/sql/ast/create_publication_stmt.go | 8 +- internal/sql/ast/create_range_stmt.go | 4 +- internal/sql/ast/create_role_stmt.go | 6 +- internal/sql/ast/create_schema_stmt.go | 8 +- internal/sql/ast/create_seq_stmt.go | 10 +- internal/sql/ast/create_stats_stmt.go | 10 +- internal/sql/ast/create_stmt.go | 22 ++--- internal/sql/ast/create_subscription_stmt.go | 8 +- internal/sql/ast/create_table_as_stmt.go | 10 +- internal/sql/ast/create_table_space_stmt.go | 8 +- internal/sql/ast/create_table_stmt.go | 20 ++-- internal/sql/ast/create_transform_stmt.go | 10 +- internal/sql/ast/create_trig_stmt.go | 28 +++--- internal/sql/ast/create_user_mapping_stmt.go | 8 +- internal/sql/ast/createdb_stmt.go | 4 +- internal/sql/ast/current_of_expr.go | 8 +- internal/sql/ast/deallocate_stmt.go | 2 +- internal/sql/ast/declare_cursor_stmt.go | 6 +- internal/sql/ast/def_elem.go | 10 +- internal/sql/ast/define_stmt.go | 12 +-- internal/sql/ast/delete_stmt.go | 20 ++-- internal/sql/ast/discard_stmt.go | 2 +- internal/sql/ast/do_stmt.go | 2 +- internal/sql/ast/drop_function_stmt.go | 4 +- internal/sql/ast/drop_owned_stmt.go | 4 +- internal/sql/ast/drop_role_stmt.go | 4 +- internal/sql/ast/drop_schema_stmt.go | 4 +- internal/sql/ast/drop_stmt.go | 10 +- internal/sql/ast/drop_subscription_stmt.go | 6 +- internal/sql/ast/drop_table_space_stmt.go | 4 +- internal/sql/ast/drop_table_stmt.go | 4 +- internal/sql/ast/drop_type_stmt.go | 4 +- internal/sql/ast/drop_user_mapping_stmt.go | 6 +- internal/sql/ast/dropdb_stmt.go | 4 +- internal/sql/ast/execute_stmt.go | 4 +- internal/sql/ast/explain_stmt.go | 4 +- internal/sql/ast/fetch_stmt.go | 8 +- internal/sql/ast/field_select.go | 12 +-- internal/sql/ast/field_store.go | 10 +- internal/sql/ast/float.go | 2 +- internal/sql/ast/from_expr.go | 4 +- internal/sql/ast/func_call.go | 24 ++--- internal/sql/ast/func_expr.go | 20 ++-- internal/sql/ast/func_name.go | 6 +- internal/sql/ast/func_param.go | 8 +- internal/sql/ast/func_spec.go | 6 +- internal/sql/ast/function_parameter.go | 8 +- internal/sql/ast/grant_role_stmt.go | 10 +- internal/sql/ast/grant_stmt.go | 16 ++-- internal/sql/ast/grouping_func.go | 12 +-- internal/sql/ast/grouping_set.go | 6 +- .../sql/ast/import_foreign_schema_stmt.go | 12 +-- internal/sql/ast/in.go | 10 +- internal/sql/ast/index_elem.go | 14 +-- internal/sql/ast/index_stmt.go | 36 ++++---- internal/sql/ast/infer_clause.go | 8 +- internal/sql/ast/inference_elem.go | 8 +- internal/sql/ast/inline_code_block.go | 6 +- internal/sql/ast/insert_stmt.go | 22 ++--- internal/sql/ast/integer.go | 2 +- internal/sql/ast/interval_expr.go | 6 +- internal/sql/ast/into_clause.go | 14 +-- internal/sql/ast/join_expr.go | 16 ++-- internal/sql/ast/list.go | 2 +- internal/sql/ast/listen_stmt.go | 2 +- internal/sql/ast/load_stmt.go | 2 +- internal/sql/ast/lock_stmt.go | 6 +- internal/sql/ast/locking_clause.go | 6 +- internal/sql/ast/min_max_expr.go | 14 +-- internal/sql/ast/multi_assign_ref.go | 6 +- internal/sql/ast/named_arg_expr.go | 10 +- internal/sql/ast/next_value_expr.go | 6 +- internal/sql/ast/notify_stmt.go | 4 +- internal/sql/ast/null_test_expr.go | 10 +- internal/sql/ast/object_with_args.go | 6 +- internal/sql/ast/on_conflict_clause.go | 10 +- internal/sql/ast/on_conflict_expr.go | 16 ++-- internal/sql/ast/on_duplicate_key_update.go | 4 +- internal/sql/ast/op_expr.go | 16 ++-- internal/sql/ast/param.go | 14 +-- internal/sql/ast/param_exec_data.go | 6 +- internal/sql/ast/param_extern_data.go | 8 +- internal/sql/ast/param_list_info_data.go | 8 +- internal/sql/ast/param_ref.go | 6 +- internal/sql/ast/paren_expr.go | 4 +- internal/sql/ast/partition_bound_spec.go | 10 +- internal/sql/ast/partition_cmd.go | 4 +- internal/sql/ast/partition_elem.go | 10 +- internal/sql/ast/partition_range_datum.go | 6 +- internal/sql/ast/partition_spec.go | 6 +- internal/sql/ast/prepare_stmt.go | 6 +- internal/sql/ast/query.go | 72 +++++++-------- internal/sql/ast/range_function.go | 12 +-- internal/sql/ast/range_subselect.go | 6 +- internal/sql/ast/range_table_func.go | 14 +-- internal/sql/ast/range_table_func_col.go | 14 +-- internal/sql/ast/range_table_sample.go | 10 +- internal/sql/ast/range_tbl_entry.go | 62 ++++++------- internal/sql/ast/range_tbl_function.go | 14 +-- internal/sql/ast/range_tbl_ref.go | 2 +- internal/sql/ast/range_var.go | 14 +-- internal/sql/ast/raw_stmt.go | 6 +- internal/sql/ast/reassign_owned_stmt.go | 4 +- internal/sql/ast/refresh_mat_view_stmt.go | 6 +- internal/sql/ast/reindex_stmt.go | 8 +- internal/sql/ast/relabel_type.go | 14 +-- internal/sql/ast/rename_column_stmt.go | 8 +- internal/sql/ast/rename_stmt.go | 16 ++-- internal/sql/ast/rename_table_stmt.go | 6 +- internal/sql/ast/rename_type_stmt.go | 4 +- internal/sql/ast/replica_identity_stmt.go | 4 +- internal/sql/ast/res_target.go | 8 +- internal/sql/ast/role_spec.go | 6 +- internal/sql/ast/row_compare_expr.go | 14 +-- internal/sql/ast/row_expr.go | 12 +-- internal/sql/ast/row_mark_clause.go | 8 +- internal/sql/ast/rule_stmt.go | 14 +-- internal/sql/ast/scalar_array_op_expr.go | 12 +-- internal/sql/ast/sec_label_stmt.go | 8 +- internal/sql/ast/select_stmt.go | 36 ++++---- internal/sql/ast/set_operation_stmt.go | 16 ++-- internal/sql/ast/set_to_default.go | 10 +- internal/sql/ast/sort_by.go | 10 +- internal/sql/ast/sort_group_clause.go | 10 +- internal/sql/ast/sql_value_function.go | 10 +- internal/sql/ast/statement.go | 2 +- internal/sql/ast/string.go | 2 +- internal/sql/ast/sub_link.go | 14 +-- internal/sql/ast/sub_plan.go | 34 +++---- internal/sql/ast/table_func.go | 26 +++--- internal/sql/ast/table_like_clause.go | 4 +- internal/sql/ast/table_name.go | 6 +- internal/sql/ast/table_sample_clause.go | 6 +- internal/sql/ast/target_entry.go | 16 ++-- internal/sql/ast/transaction_stmt.go | 6 +- internal/sql/ast/trigger_transition.go | 6 +- internal/sql/ast/truncate_stmt.go | 6 +- internal/sql/ast/type_cast.go | 6 +- internal/sql/ast/type_name.go | 24 ++--- internal/sql/ast/unlisten_stmt.go | 2 +- internal/sql/ast/update_stmt.go | 18 ++-- internal/sql/ast/vacuum_stmt.go | 6 +- internal/sql/ast/var.go | 20 ++-- internal/sql/ast/variable_expr.go | 4 +- internal/sql/ast/variable_set_stmt.go | 8 +- internal/sql/ast/variable_show_stmt.go | 2 +- internal/sql/ast/view_stmt.go | 12 +-- internal/sql/ast/window_clause.go | 18 ++-- internal/sql/ast/window_def.go | 16 ++-- internal/sql/ast/window_func.go | 22 ++--- internal/sql/ast/with_check_option.go | 10 +- internal/sql/ast/with_clause.go | 6 +- internal/sql/ast/xml_expr.go | 20 ++-- internal/sql/ast/xml_serialize.go | 8 +- 260 files changed, 1397 insertions(+), 1396 deletions(-) diff --git a/docs/howto/parse.md b/docs/howto/parse.md index a4fd10c6d5..d46d35f394 100644 --- a/docs/howto/parse.md +++ b/docs/howto/parse.md @@ -49,18 +49,19 @@ The output is a JSON array with one object per statement: "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "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 @@ -69,18 +70,18 @@ fields of their own, so without it a star, a null literal and an untranslated clause would all print as `{}`. ```json -"Val": { +"val": { "tag": "ColumnRef", - "Name": "", - "Fields": { + "name": "", + "fields": { "tag": "List", - "Items": [ + "items": [ { "tag": "A_Star" } ] }, - "Location": 93 + "location": 93 } ``` @@ -94,17 +95,17 @@ 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": { +"val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "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: `StmtLocation` is 0 for the first statement in a file, and -`LIMIT 0` parses to an `Ival` of 0. +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 ab257bea23..1473a99cc5 100644 --- a/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt +++ b/internal/endtoend/testdata/analyze_ast/postgresql/stdout.txt @@ -25,112 +25,112 @@ ], "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "DistinctClause": { + "distinct_clause": { "tag": "List" }, - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Indirection": { + "indirection": { "tag": "List" }, - "Val": { + "val": { "tag": "ColumnRef", - "Name": "", - "Fields": { + "name": "", + "fields": { "tag": "List", - "Items": [ + "items": [ { "tag": "String", - "Str": "name" + "str": "name" } ] }, - "Location": 35 + "location": 35 }, - "Location": 35 + "location": 35 } ] }, - "FromClause": { + "from_clause": { "tag": "List", - "Items": [ + "items": [ { "tag": "RangeVar", - "Relname": "authors", - "Inh": true, - "Relpersistence": 112, - "Location": 45 + "relname": "authors", + "inh": true, + "relpersistence": 112, + "location": 45 } ] }, - "WhereClause": { + "where_clause": { "tag": "A_Expr", - "Kind": 1, - "Name": { + "kind": 1, + "name": { "tag": "List", - "Items": [ + "items": [ { "tag": "String", - "Str": "=" + "str": "=" } ] }, - "Lexpr": { + "lexpr": { "tag": "ColumnRef", - "Name": "", - "Fields": { + "name": "", + "fields": { "tag": "List", - "Items": [ + "items": [ { "tag": "String", - "Str": "id" + "str": "id" } ] }, - "Location": 59 + "location": 59 }, - "Rexpr": { + "rexpr": { "tag": "ParamRef", - "Number": 1, - "Location": 64, - "Dollar": true + "number": 1, + "location": 64, + "dollar": true }, - "Location": 62 + "location": 62 }, - "GroupClause": { + "group_clause": { "tag": "List" }, - "HavingClause": { + "having_clause": { "tag": "TODO" }, - "WindowClause": { + "window_clause": { "tag": "List" }, - "ValuesLists": { + "values_lists": { "tag": "List" }, - "SortClause": { + "sort_clause": { "tag": "List" }, - "LimitOffset": { + "limit_offset": { "tag": "TODO" }, - "LimitCount": { + "limit_count": { "tag": "TODO" }, - "LockingClause": { + "locking_clause": { "tag": "List" }, - "Op": 0, - "All": false + "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 8b2e6a9f56..82c35f9819 100644 --- a/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/clickhouse/stdout.txt @@ -4,30 +4,30 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 31 + "location": 31 }, - "Location": 31 + "location": 31 } ] }, - "Op": 0, - "All": false + "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 cae0296ac7..9c48f6b87e 100644 --- a/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/duckdb/stdout.txt @@ -4,30 +4,30 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "Op": 0, - "All": false + "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 715536dec9..f1d543432e 100644 --- a/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/googlesql/stdout.txt @@ -4,30 +4,30 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "Op": 0, - "All": false + "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 39e5aa0df6..a317604268 100644 --- a/internal/endtoend/testdata/parse_basic/mssql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mssql/stdout.txt @@ -4,30 +4,30 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "Op": 0, - "All": false + "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 90b2f25822..baad161901 100644 --- a/internal/endtoend/testdata/parse_basic/mysql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/mysql/stdout.txt @@ -4,39 +4,39 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": { + "from_clause": { "tag": "List" }, - "GroupClause": { + "group_clause": { "tag": "List" }, - "WindowClause": { + "window_clause": { "tag": "List" }, - "Op": 0, - "All": false + "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 deaaea7d6c..da9c2f9040 100644 --- a/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/postgresql/stdout.txt @@ -4,66 +4,66 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "DistinctClause": { + "distinct_clause": { "tag": "List" }, - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Indirection": { + "indirection": { "tag": "List" }, - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": { + "from_clause": { "tag": "List" }, - "WhereClause": { + "where_clause": { "tag": "TODO" }, - "GroupClause": { + "group_clause": { "tag": "List" }, - "HavingClause": { + "having_clause": { "tag": "TODO" }, - "WindowClause": { + "window_clause": { "tag": "List" }, - "ValuesLists": { + "values_lists": { "tag": "List" }, - "SortClause": { + "sort_clause": { "tag": "List" }, - "LimitOffset": { + "limit_offset": { "tag": "TODO" }, - "LimitCount": { + "limit_count": { "tag": "TODO" }, - "LockingClause": { + "locking_clause": { "tag": "List" }, - "Op": 0, - "All": false + "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 50d4c72330..8cbf077101 100644 --- a/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt +++ b/internal/endtoend/testdata/parse_basic/sqlite/stdout.txt @@ -4,42 +4,42 @@ "cmd": ":one", "ast": { "tag": "RawStmt", - "Stmt": { + "stmt": { "tag": "SelectStmt", - "TargetList": { + "target_list": { "tag": "List", - "Items": [ + "items": [ { "tag": "ResTarget", - "Val": { + "val": { "tag": "A_Const", - "Val": { + "val": { "tag": "Integer", - "Ival": 1 + "ival": 1 }, - "Location": 30 + "location": 30 }, - "Location": 30 + "location": 30 } ] }, - "FromClause": { + "from_clause": { "tag": "List" }, - "GroupClause": { + "group_clause": { "tag": "List" }, - "WindowClause": { + "window_clause": { "tag": "List" }, - "ValuesLists": { + "values_lists": { "tag": "List" }, - "Op": 0, - "All": false + "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 57db49109a..ed11abf998 100644 --- a/internal/sql/ast/a_array_expr.go +++ b/internal/sql/ast/a_array_expr.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_ArrayExpr struct { Tag NodeTag[A_ArrayExpr] `json:"tag"` - Elements *List `json:",omitempty"` - Location int + 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 d98c00ced5..0f507d99e3 100644 --- a/internal/sql/ast/a_const.go +++ b/internal/sql/ast/a_const.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Const struct { Tag NodeTag[A_Const] `json:"tag"` - Val Node `json:",omitempty"` - Location int + 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 b1f7d28e52..7501ff0eb6 100644 --- a/internal/sql/ast/a_expr.go +++ b/internal/sql/ast/a_expr.go @@ -9,7 +9,7 @@ import ( type A_Expr struct { Tag NodeTag[A_Expr] `json:"tag"` - Kind A_Expr_Kind + 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 @@ -17,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 `json:",omitempty"` - Lexpr Node `json:",omitempty"` - Rexpr Node `json:",omitempty"` - 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 57f9428dac..2f7715e8c7 100644 --- a/internal/sql/ast/a_indices.go +++ b/internal/sql/ast/a_indices.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type A_Indices struct { Tag NodeTag[A_Indices] `json:"tag"` - IsSlice bool - Lidx Node `json:",omitempty"` - Uidx Node `json:",omitempty"` + 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 10fe4cdd64..df682bb285 100644 --- a/internal/sql/ast/a_indirection.go +++ b/internal/sql/ast/a_indirection.go @@ -3,8 +3,8 @@ package ast type A_Indirection struct { Tag NodeTag[A_Indirection] `json:"tag"` - Arg Node `json:",omitempty"` - Indirection *List `json:",omitempty"` + Arg Node `json:"arg,omitempty"` + Indirection *List `json:"indirection,omitempty"` } func (n *A_Indirection) Pos() int { diff --git a/internal/sql/ast/access_priv.go b/internal/sql/ast/access_priv.go index bade930a67..ab16946db3 100644 --- a/internal/sql/ast/access_priv.go +++ b/internal/sql/ast/access_priv.go @@ -3,8 +3,8 @@ package ast type AccessPriv struct { Tag NodeTag[AccessPriv] `json:"tag"` - PrivName *string `json:",omitempty"` - Cols *List `json:",omitempty"` + 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 990b8b8932..f9c8a0833a 100644 --- a/internal/sql/ast/aggref.go +++ b/internal/sql/ast/aggref.go @@ -3,23 +3,23 @@ package ast type Aggref struct { Tag NodeTag[Aggref] `json:"tag"` - Xpr Node `json:",omitempty"` - Aggfnoid Oid - Aggtype Oid - Aggcollid Oid - Inputcollid Oid - Aggargtypes *List `json:",omitempty"` - Aggdirectargs *List `json:",omitempty"` - Args *List `json:",omitempty"` - Aggorder *List `json:",omitempty"` - Aggdistinct *List `json:",omitempty"` - Aggfilter Node `json:",omitempty"` - Aggstar bool - Aggvariadic bool - Aggkind byte - Agglevelsup Index - Aggsplit AggSplit - Location int + 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 00a2d1c8f0..198120f5d0 100644 --- a/internal/sql/ast/alias.go +++ b/internal/sql/ast/alias.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type Alias struct { Tag NodeTag[Alias] `json:"tag"` - Aliasname *string `json:",omitempty"` - Colnames *List `json:",omitempty"` + 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 d52f18fd5e..fedcf5a9d1 100644 --- a/internal/sql/ast/alter_collation_stmt.go +++ b/internal/sql/ast/alter_collation_stmt.go @@ -3,7 +3,7 @@ package ast type AlterCollationStmt struct { Tag NodeTag[AlterCollationStmt] `json:"tag"` - Collname *List `json:",omitempty"` + 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 607d98df57..14d485eb30 100644 --- a/internal/sql/ast/alter_database_set_stmt.go +++ b/internal/sql/ast/alter_database_set_stmt.go @@ -3,8 +3,8 @@ package ast type AlterDatabaseSetStmt struct { Tag NodeTag[AlterDatabaseSetStmt] `json:"tag"` - Dbname *string `json:",omitempty"` - Setstmt *VariableSetStmt `json:",omitempty"` + 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 a4144d9619..9eb3dae54d 100644 --- a/internal/sql/ast/alter_database_stmt.go +++ b/internal/sql/ast/alter_database_stmt.go @@ -3,8 +3,8 @@ package ast type AlterDatabaseStmt struct { Tag NodeTag[AlterDatabaseStmt] `json:"tag"` - Dbname *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 ec4c19c2b4..f72a412eb1 100644 --- a/internal/sql/ast/alter_default_privileges_stmt.go +++ b/internal/sql/ast/alter_default_privileges_stmt.go @@ -3,8 +3,8 @@ package ast type AlterDefaultPrivilegesStmt struct { Tag NodeTag[AlterDefaultPrivilegesStmt] `json:"tag"` - Options *List `json:",omitempty"` - Action *GrantStmt `json:",omitempty"` + 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 33fd6e3b48..669b7a5337 100644 --- a/internal/sql/ast/alter_domain_stmt.go +++ b/internal/sql/ast/alter_domain_stmt.go @@ -3,12 +3,12 @@ package ast type AlterDomainStmt struct { Tag NodeTag[AlterDomainStmt] `json:"tag"` - Subtype byte - TypeName *List `json:",omitempty"` - Name *string `json:",omitempty"` - Def Node `json:",omitempty"` - Behavior DropBehavior - MissingOk bool + 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 cbca3a362e..70a6a850bd 100644 --- a/internal/sql/ast/alter_enum_stmt.go +++ b/internal/sql/ast/alter_enum_stmt.go @@ -3,12 +3,12 @@ package ast type AlterEnumStmt struct { Tag NodeTag[AlterEnumStmt] `json:"tag"` - TypeName *List `json:",omitempty"` - OldVal *string `json:",omitempty"` - NewVal *string `json:",omitempty"` - NewValNeighbor *string `json:",omitempty"` - NewValIsAfter bool - SkipIfNewValExists bool + 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 287d4e6228..14356fabe7 100644 --- a/internal/sql/ast/alter_event_trig_stmt.go +++ b/internal/sql/ast/alter_event_trig_stmt.go @@ -3,8 +3,8 @@ package ast type AlterEventTrigStmt struct { Tag NodeTag[AlterEventTrigStmt] `json:"tag"` - Trigname *string `json:",omitempty"` - Tgenabled byte + 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 b92cd38993..3821812720 100644 --- a/internal/sql/ast/alter_extension_contents_stmt.go +++ b/internal/sql/ast/alter_extension_contents_stmt.go @@ -3,10 +3,10 @@ package ast type AlterExtensionContentsStmt struct { Tag NodeTag[AlterExtensionContentsStmt] `json:"tag"` - Extname *string `json:",omitempty"` - Action int - Objtype ObjectType - Object Node `json:",omitempty"` + 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 3a11ceb6b8..c1daf85e91 100644 --- a/internal/sql/ast/alter_extension_stmt.go +++ b/internal/sql/ast/alter_extension_stmt.go @@ -3,8 +3,8 @@ package ast type AlterExtensionStmt struct { Tag NodeTag[AlterExtensionStmt] `json:"tag"` - Extname *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 be52b57b8c..6a74137bfb 100644 --- a/internal/sql/ast/alter_fdw_stmt.go +++ b/internal/sql/ast/alter_fdw_stmt.go @@ -3,9 +3,9 @@ package ast type AlterFdwStmt struct { Tag NodeTag[AlterFdwStmt] `json:"tag"` - Fdwname *string `json:",omitempty"` - FuncOptions *List `json:",omitempty"` - Options *List `json:",omitempty"` + 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 7f8281b86d..fcdbad116f 100644 --- a/internal/sql/ast/alter_foreign_server_stmt.go +++ b/internal/sql/ast/alter_foreign_server_stmt.go @@ -3,10 +3,10 @@ package ast type AlterForeignServerStmt struct { Tag NodeTag[AlterForeignServerStmt] `json:"tag"` - Servername *string `json:",omitempty"` - Version *string `json:",omitempty"` - Options *List `json:",omitempty"` - HasVersion bool + 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 9d37870de5..93d393111d 100644 --- a/internal/sql/ast/alter_function_stmt.go +++ b/internal/sql/ast/alter_function_stmt.go @@ -3,8 +3,8 @@ package ast type AlterFunctionStmt struct { Tag NodeTag[AlterFunctionStmt] `json:"tag"` - Func *ObjectWithArgs `json:",omitempty"` - Actions *List `json:",omitempty"` + 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 656ffc257a..f7b46aeeab 100644 --- a/internal/sql/ast/alter_object_depends_stmt.go +++ b/internal/sql/ast/alter_object_depends_stmt.go @@ -3,10 +3,10 @@ package ast type AlterObjectDependsStmt struct { Tag NodeTag[AlterObjectDependsStmt] `json:"tag"` - ObjectType ObjectType - Relation *RangeVar `json:",omitempty"` - Object Node `json:",omitempty"` - Extname Node `json:",omitempty"` + 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 49d7dfe67b..3a5a5bd332 100644 --- a/internal/sql/ast/alter_object_schema_stmt.go +++ b/internal/sql/ast/alter_object_schema_stmt.go @@ -3,11 +3,11 @@ package ast type AlterObjectSchemaStmt struct { Tag NodeTag[AlterObjectSchemaStmt] `json:"tag"` - ObjectType ObjectType - Relation *RangeVar `json:",omitempty"` - Object Node `json:",omitempty"` - Newschema *string `json:",omitempty"` - MissingOk bool + 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 8211cbe347..7d287d5a26 100644 --- a/internal/sql/ast/alter_op_family_stmt.go +++ b/internal/sql/ast/alter_op_family_stmt.go @@ -3,10 +3,10 @@ package ast type AlterOpFamilyStmt struct { Tag NodeTag[AlterOpFamilyStmt] `json:"tag"` - Opfamilyname *List `json:",omitempty"` - Amname *string `json:",omitempty"` - IsDrop bool - Items *List `json:",omitempty"` + 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 51a56b4277..0d61c657a6 100644 --- a/internal/sql/ast/alter_operator_stmt.go +++ b/internal/sql/ast/alter_operator_stmt.go @@ -3,8 +3,8 @@ package ast type AlterOperatorStmt struct { Tag NodeTag[AlterOperatorStmt] `json:"tag"` - Opername *ObjectWithArgs `json:",omitempty"` - Options *List `json:",omitempty"` + 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 0463e6e5da..041c0d4d67 100644 --- a/internal/sql/ast/alter_owner_stmt.go +++ b/internal/sql/ast/alter_owner_stmt.go @@ -3,10 +3,10 @@ package ast type AlterOwnerStmt struct { Tag NodeTag[AlterOwnerStmt] `json:"tag"` - ObjectType ObjectType - Relation *RangeVar `json:",omitempty"` - Object Node `json:",omitempty"` - Newowner *RoleSpec `json:",omitempty"` + 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 e599c8eba9..b7f9d7be4f 100644 --- a/internal/sql/ast/alter_policy_stmt.go +++ b/internal/sql/ast/alter_policy_stmt.go @@ -3,11 +3,11 @@ package ast type AlterPolicyStmt struct { Tag NodeTag[AlterPolicyStmt] `json:"tag"` - PolicyName *string `json:",omitempty"` - Table *RangeVar `json:",omitempty"` - Roles *List `json:",omitempty"` - Qual Node `json:",omitempty"` - WithCheck Node `json:",omitempty"` + 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 8bd61b93ae..718368fd26 100644 --- a/internal/sql/ast/alter_publication_stmt.go +++ b/internal/sql/ast/alter_publication_stmt.go @@ -3,11 +3,11 @@ package ast type AlterPublicationStmt struct { Tag NodeTag[AlterPublicationStmt] `json:"tag"` - Pubname *string `json:",omitempty"` - Options *List `json:",omitempty"` - Tables *List `json:",omitempty"` - ForAllTables bool - TableAction DefElemAction + 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 2e1ce504d4..a973ccb4a4 100644 --- a/internal/sql/ast/alter_role_set_stmt.go +++ b/internal/sql/ast/alter_role_set_stmt.go @@ -3,9 +3,9 @@ package ast type AlterRoleSetStmt struct { Tag NodeTag[AlterRoleSetStmt] `json:"tag"` - Role *RoleSpec `json:",omitempty"` - Database *string `json:",omitempty"` - Setstmt *VariableSetStmt `json:",omitempty"` + 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 3b7e02411a..3c7d60767c 100644 --- a/internal/sql/ast/alter_role_stmt.go +++ b/internal/sql/ast/alter_role_stmt.go @@ -3,9 +3,9 @@ package ast type AlterRoleStmt struct { Tag NodeTag[AlterRoleStmt] `json:"tag"` - Role *RoleSpec `json:",omitempty"` - Options *List `json:",omitempty"` - Action int + 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 e27072f133..53e46d47c4 100644 --- a/internal/sql/ast/alter_seq_stmt.go +++ b/internal/sql/ast/alter_seq_stmt.go @@ -3,10 +3,10 @@ package ast type AlterSeqStmt struct { Tag NodeTag[AlterSeqStmt] `json:"tag"` - Sequence *RangeVar `json:",omitempty"` - Options *List `json:",omitempty"` - ForIdentity bool - MissingOk bool + 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 7d0ecc18cb..3b54140fe7 100644 --- a/internal/sql/ast/alter_subscription_stmt.go +++ b/internal/sql/ast/alter_subscription_stmt.go @@ -3,11 +3,11 @@ package ast type AlterSubscriptionStmt struct { Tag NodeTag[AlterSubscriptionStmt] `json:"tag"` - Kind AlterSubscriptionType - Subname *string `json:",omitempty"` - Conninfo *string `json:",omitempty"` - Publication *List `json:",omitempty"` - Options *List `json:",omitempty"` + 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 d3ff7e59b1..724ad8f3a7 100644 --- a/internal/sql/ast/alter_system_stmt.go +++ b/internal/sql/ast/alter_system_stmt.go @@ -3,7 +3,7 @@ package ast type AlterSystemStmt struct { Tag NodeTag[AlterSystemStmt] `json:"tag"` - Setstmt *VariableSetStmt `json:",omitempty"` + 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 88ea854a1f..b357605dd8 100644 --- a/internal/sql/ast/alter_table_cmd.go +++ b/internal/sql/ast/alter_table_cmd.go @@ -32,12 +32,12 @@ func (t AlterTableType) String() string { type AlterTableCmd struct { Tag NodeTag[AlterTableCmd] `json:"tag"` - Subtype AlterTableType - Name *string `json:",omitempty"` - Def *ColumnDef `json:",omitempty"` - Newowner *RoleSpec `json:",omitempty"` - Behavior DropBehavior - MissingOk bool + 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 bc6ad1ac09..ac028a06aa 100644 --- a/internal/sql/ast/alter_table_move_all_stmt.go +++ b/internal/sql/ast/alter_table_move_all_stmt.go @@ -3,11 +3,11 @@ package ast type AlterTableMoveAllStmt struct { Tag NodeTag[AlterTableMoveAllStmt] `json:"tag"` - OrigTablespacename *string `json:",omitempty"` - Objtype ObjectType - Roles *List `json:",omitempty"` - NewTablespacename *string `json:",omitempty"` - Nowait bool + 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 9f0d25b1cb..d7f62bf334 100644 --- a/internal/sql/ast/alter_table_set_schema_stmt.go +++ b/internal/sql/ast/alter_table_set_schema_stmt.go @@ -3,9 +3,9 @@ package ast type AlterTableSetSchemaStmt struct { Tag NodeTag[AlterTableSetSchemaStmt] `json:"tag"` - Table *TableName `json:",omitempty"` - NewSchema *string `json:",omitempty"` - MissingOk bool + 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 47642533a3..f9b97b2d2f 100644 --- a/internal/sql/ast/alter_table_space_options_stmt.go +++ b/internal/sql/ast/alter_table_space_options_stmt.go @@ -3,9 +3,9 @@ package ast type AlterTableSpaceOptionsStmt struct { Tag NodeTag[AlterTableSpaceOptionsStmt] `json:"tag"` - Tablespacename *string `json:",omitempty"` - Options *List `json:",omitempty"` - IsReset bool + 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 74a358b15a..5e541023f1 100644 --- a/internal/sql/ast/alter_table_stmt.go +++ b/internal/sql/ast/alter_table_stmt.go @@ -6,15 +6,15 @@ type AlterTableStmt struct { Tag NodeTag[AlterTableStmt] `json:"tag"` // TODO: Only TableName or Relation should be defined - Relation *RangeVar `json:",omitempty"` - Table *TableName `json:",omitempty"` - Cmds *List `json:",omitempty"` - 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 ed1faa69cd..9ecd8bc2bb 100644 --- a/internal/sql/ast/alter_ts_configuration_stmt.go +++ b/internal/sql/ast/alter_ts_configuration_stmt.go @@ -3,13 +3,13 @@ package ast type AlterTSConfigurationStmt struct { Tag NodeTag[AlterTSConfigurationStmt] `json:"tag"` - Kind AlterTSConfigType - Cfgname *List `json:",omitempty"` - Tokentype *List `json:",omitempty"` - Dicts *List `json:",omitempty"` - Override bool - Replace bool - MissingOk bool + 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 401785f2ac..6c89127cca 100644 --- a/internal/sql/ast/alter_ts_dictionary_stmt.go +++ b/internal/sql/ast/alter_ts_dictionary_stmt.go @@ -3,8 +3,8 @@ package ast type AlterTSDictionaryStmt struct { Tag NodeTag[AlterTSDictionaryStmt] `json:"tag"` - Dictname *List `json:",omitempty"` - Options *List `json:",omitempty"` + 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 470304fbb5..a8878d6153 100644 --- a/internal/sql/ast/alter_type_add_value_stmt.go +++ b/internal/sql/ast/alter_type_add_value_stmt.go @@ -3,12 +3,12 @@ package ast type AlterTypeAddValueStmt struct { Tag NodeTag[AlterTypeAddValueStmt] `json:"tag"` - Type *TypeName `json:",omitempty"` - NewValue *string `json:",omitempty"` - NewValHasNeighbor bool - NewValNeighbor *string `json:",omitempty"` - NewValIsAfter bool - SkipIfNewValExists bool + 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 aa5c6961d6..52e59d40d1 100644 --- a/internal/sql/ast/alter_type_rename_value_stmt.go +++ b/internal/sql/ast/alter_type_rename_value_stmt.go @@ -3,9 +3,9 @@ package ast type AlterTypeRenameValueStmt struct { Tag NodeTag[AlterTypeRenameValueStmt] `json:"tag"` - Type *TypeName `json:",omitempty"` - OldValue *string `json:",omitempty"` - NewValue *string `json:",omitempty"` + 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 c0abb42144..46d312beaa 100644 --- a/internal/sql/ast/alter_type_set_schema_stmt.go +++ b/internal/sql/ast/alter_type_set_schema_stmt.go @@ -3,8 +3,8 @@ package ast type AlterTypeSetSchemaStmt struct { Tag NodeTag[AlterTypeSetSchemaStmt] `json:"tag"` - Type *TypeName `json:",omitempty"` - NewSchema *string `json:",omitempty"` + 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 3041a45df3..ab85751f10 100644 --- a/internal/sql/ast/alter_user_mapping_stmt.go +++ b/internal/sql/ast/alter_user_mapping_stmt.go @@ -3,9 +3,9 @@ package ast type AlterUserMappingStmt struct { Tag NodeTag[AlterUserMappingStmt] `json:"tag"` - User *RoleSpec `json:",omitempty"` - Servername *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 68b51e235d..ad374d1d76 100644 --- a/internal/sql/ast/alternative_sub_plan.go +++ b/internal/sql/ast/alternative_sub_plan.go @@ -3,8 +3,8 @@ package ast type AlternativeSubPlan struct { Tag NodeTag[AlternativeSubPlan] `json:"tag"` - Xpr Node `json:",omitempty"` - Subplans *List `json:",omitempty"` + 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 2cef349648..ce8c95200f 100644 --- a/internal/sql/ast/array_coerce_expr.go +++ b/internal/sql/ast/array_coerce_expr.go @@ -3,15 +3,15 @@ package ast type ArrayCoerceExpr struct { Tag NodeTag[ArrayCoerceExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Elemfuncid Oid - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid - IsExplicit bool - Coerceformat CoercionForm - Location int + 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 c6a0d2b773..753ed0f782 100644 --- a/internal/sql/ast/array_expr.go +++ b/internal/sql/ast/array_expr.go @@ -3,13 +3,13 @@ package ast type ArrayExpr struct { Tag NodeTag[ArrayExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - ArrayTypeid Oid - ArrayCollid Oid - ElementTypeid Oid - Elements *List `json:",omitempty"` - Multidims bool - Location int + 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 19cadc1c40..9fb4a35f5b 100644 --- a/internal/sql/ast/array_ref.go +++ b/internal/sql/ast/array_ref.go @@ -3,15 +3,15 @@ package ast type ArrayRef struct { Tag NodeTag[ArrayRef] `json:"tag"` - Xpr Node `json:",omitempty"` - Refarraytype Oid - Refelemtype Oid - Reftypmod int32 - Refcollid Oid - Refupperindexpr *List `json:",omitempty"` - Reflowerindexpr *List `json:",omitempty"` - Refexpr Node `json:",omitempty"` - Refassgnexpr Node `json:",omitempty"` + 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 2c4d69dc7c..f1e4508006 100644 --- a/internal/sql/ast/between_expr.go +++ b/internal/sql/ast/between_expr.go @@ -6,14 +6,14 @@ type BetweenExpr struct { Tag NodeTag[BetweenExpr] `json:"tag"` // Expr is the value expression to be compared. - Expr Node `json:",omitempty"` + Expr Node `json:"expr,omitempty"` // Left is the left expression in the between statement. - Left Node `json:",omitempty"` + Left Node `json:"left,omitempty"` // Right is the right expression in the between statement. - Right Node `json:",omitempty"` + 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 253a3f8d0e..fb53f2d765 100644 --- a/internal/sql/ast/bit_string.go +++ b/internal/sql/ast/bit_string.go @@ -3,7 +3,7 @@ package ast type BitString struct { Tag NodeTag[BitString] `json:"tag"` - Str string + 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 2212e61e80..bcb5171924 100644 --- a/internal/sql/ast/block_id_data.go +++ b/internal/sql/ast/block_id_data.go @@ -3,8 +3,8 @@ package ast type BlockIdData struct { Tag NodeTag[BlockIdData] `json:"tag"` - BiHi uint16 - BiLo uint16 + 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 50491a234d..9efea3de12 100644 --- a/internal/sql/ast/bool_expr.go +++ b/internal/sql/ast/bool_expr.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type BoolExpr struct { Tag NodeTag[BoolExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Boolop BoolExprType - Args *List `json:",omitempty"` - Location int + 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 efb40e7c5d..b5a7502986 100644 --- a/internal/sql/ast/boolean.go +++ b/internal/sql/ast/boolean.go @@ -9,7 +9,7 @@ import ( type Boolean struct { Tag NodeTag[Boolean] `json:"tag"` - Boolval bool + 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 cec077c7be..f6f3d90680 100644 --- a/internal/sql/ast/boolean_test_expr.go +++ b/internal/sql/ast/boolean_test_expr.go @@ -3,10 +3,10 @@ package ast type BooleanTest struct { Tag NodeTag[BooleanTest] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Booltesttype BoolTestType - Location int + 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 39213a7f66..c64b5a8aa4 100644 --- a/internal/sql/ast/call_stmt.go +++ b/internal/sql/ast/call_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CallStmt struct { Tag NodeTag[CallStmt] `json:"tag"` - FuncCall *FuncCall `json:",omitempty"` + 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 9f69eeb893..4d9b6181a5 100644 --- a/internal/sql/ast/case_expr.go +++ b/internal/sql/ast/case_expr.go @@ -5,13 +5,13 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseExpr struct { Tag NodeTag[CaseExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Casetype Oid - Casecollid Oid - Arg Node `json:",omitempty"` - Args *List `json:",omitempty"` - Defresult Node `json:",omitempty"` - Location int + 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 876556b52b..493293e93f 100644 --- a/internal/sql/ast/case_test_expr.go +++ b/internal/sql/ast/case_test_expr.go @@ -3,10 +3,10 @@ package ast type CaseTestExpr struct { Tag NodeTag[CaseTestExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - TypeId Oid - TypeMod int32 - Collation Oid + 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 1124a95ce0..fb39c4e269 100644 --- a/internal/sql/ast/case_when.go +++ b/internal/sql/ast/case_when.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CaseWhen struct { Tag NodeTag[CaseWhen] `json:"tag"` - Xpr Node `json:",omitempty"` - Expr Node `json:",omitempty"` - Result Node `json:",omitempty"` - Location int + 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/close_portal_stmt.go b/internal/sql/ast/close_portal_stmt.go index a3b5d9c082..d690543df9 100644 --- a/internal/sql/ast/close_portal_stmt.go +++ b/internal/sql/ast/close_portal_stmt.go @@ -3,7 +3,7 @@ package ast type ClosePortalStmt struct { Tag NodeTag[ClosePortalStmt] `json:"tag"` - Portalname *string `json:",omitempty"` + 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 d2c9cde18f..f2b4588d51 100644 --- a/internal/sql/ast/cluster_stmt.go +++ b/internal/sql/ast/cluster_stmt.go @@ -3,9 +3,9 @@ package ast type ClusterStmt struct { Tag NodeTag[ClusterStmt] `json:"tag"` - Relation *RangeVar `json:",omitempty"` - Indexname *string `json:",omitempty"` - Verbose bool + 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 f4401c17fe..f51c2c5c8e 100644 --- a/internal/sql/ast/coalesce_expr.go +++ b/internal/sql/ast/coalesce_expr.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CoalesceExpr struct { Tag NodeTag[CoalesceExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Coalescetype Oid - Coalescecollid Oid - Args *List `json:",omitempty"` - Location int + 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 ebb2acde23..09e681b537 100644 --- a/internal/sql/ast/coerce_to_domain.go +++ b/internal/sql/ast/coerce_to_domain.go @@ -3,13 +3,13 @@ package ast type CoerceToDomain struct { Tag NodeTag[CoerceToDomain] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid - Coercionformat CoercionForm - Location int + 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 7f76aaf256..d78b3bf89c 100644 --- a/internal/sql/ast/coerce_to_domain_value.go +++ b/internal/sql/ast/coerce_to_domain_value.go @@ -3,11 +3,11 @@ package ast type CoerceToDomainValue struct { Tag NodeTag[CoerceToDomainValue] `json:"tag"` - Xpr Node `json:",omitempty"` - TypeId Oid - TypeMod int32 - Collation Oid - Location int + 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 01e0f7e8c3..5c9f80970c 100644 --- a/internal/sql/ast/coerce_via_io.go +++ b/internal/sql/ast/coerce_via_io.go @@ -3,12 +3,12 @@ package ast type CoerceViaIO struct { Tag NodeTag[CoerceViaIO] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Resulttype Oid - Resultcollid Oid - Coerceformat CoercionForm - Location int + 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 8854456b2e..494b3e1f7b 100644 --- a/internal/sql/ast/collate_clause.go +++ b/internal/sql/ast/collate_clause.go @@ -3,9 +3,9 @@ package ast type CollateClause struct { Tag NodeTag[CollateClause] `json:"tag"` - Arg Node `json:",omitempty"` - Collname *List `json:",omitempty"` - Location int + 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 0ea98d3826..c5643584b8 100644 --- a/internal/sql/ast/collate_expr.go +++ b/internal/sql/ast/collate_expr.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CollateExpr struct { Tag NodeTag[CollateExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - CollOid Oid - Location int + 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 566e05dbac..bc6687d4cb 100644 --- a/internal/sql/ast/column_def.go +++ b/internal/sql/ast/column_def.go @@ -5,40 +5,40 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ColumnDef struct { Tag NodeTag[ColumnDef] `json:"tag"` - Colname string + 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 `json:",omitempty"` - Typeless bool - IsNotNull bool - IsUnsigned bool - IsArray bool - ArrayDims int - Vals *List `json:",omitempty"` - Length *int `json:",omitempty"` - 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 `json:",omitempty"` - CookedDefault Node `json:",omitempty"` - Identity byte - CollClause *CollateClause `json:",omitempty"` - CollOid Oid - Constraints *List `json:",omitempty"` - Fdwoptions *List `json:",omitempty"` - 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 8abd2947bd..f04c7b406d 100644 --- a/internal/sql/ast/column_ref.go +++ b/internal/sql/ast/column_ref.go @@ -9,11 +9,11 @@ import ( type ColumnRef struct { Tag NodeTag[ColumnRef] `json:"tag"` - Name string + Name string `json:"name"` // From pg.ColumnRef - Fields *List `json:",omitempty"` - Location int + Fields *List `json:"fields,omitempty"` + Location int `json:"location"` } func (n *ColumnRef) Pos() int { diff --git a/internal/sql/ast/comment.go b/internal/sql/ast/comment.go index e97be453f6..ea877328b0 100644 --- a/internal/sql/ast/comment.go +++ b/internal/sql/ast/comment.go @@ -12,8 +12,8 @@ import ( // Roslyn's terminology — return it from ParseFile, so the formatter gets // statements and comments from one lexer pass. type File struct { - Stmts []Statement `json:",omitempty"` - Comments []Comment `json:",omitempty"` + Stmts []Statement + Comments []Comment } // Comment is a single SQL comment, positioned by byte offsets into the diff --git a/internal/sql/ast/comment_on_column_stmt.go b/internal/sql/ast/comment_on_column_stmt.go index 6074555258..c35517ee27 100644 --- a/internal/sql/ast/comment_on_column_stmt.go +++ b/internal/sql/ast/comment_on_column_stmt.go @@ -3,9 +3,9 @@ package ast type CommentOnColumnStmt struct { Tag NodeTag[CommentOnColumnStmt] `json:"tag"` - Table *TableName `json:",omitempty"` - Col *ColumnRef `json:",omitempty"` - Comment *string `json:",omitempty"` + 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 9edd4d7b4a..aac64c4cac 100644 --- a/internal/sql/ast/comment_on_schema_stmt.go +++ b/internal/sql/ast/comment_on_schema_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnSchemaStmt struct { Tag NodeTag[CommentOnSchemaStmt] `json:"tag"` - Schema *String `json:",omitempty"` - Comment *string `json:",omitempty"` + 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 3fd4059217..d6056fa170 100644 --- a/internal/sql/ast/comment_on_table_stmt.go +++ b/internal/sql/ast/comment_on_table_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnTableStmt struct { Tag NodeTag[CommentOnTableStmt] `json:"tag"` - Table *TableName `json:",omitempty"` - Comment *string `json:",omitempty"` + 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 e85823d195..616fca31cc 100644 --- a/internal/sql/ast/comment_on_type_stmt.go +++ b/internal/sql/ast/comment_on_type_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnTypeStmt struct { Tag NodeTag[CommentOnTypeStmt] `json:"tag"` - Type *TypeName `json:",omitempty"` - Comment *string `json:",omitempty"` + 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 2a2592c27a..c857f77c4c 100644 --- a/internal/sql/ast/comment_on_view_stmt.go +++ b/internal/sql/ast/comment_on_view_stmt.go @@ -3,8 +3,8 @@ package ast type CommentOnViewStmt struct { Tag NodeTag[CommentOnViewStmt] `json:"tag"` - View *TableName `json:",omitempty"` - Comment *string `json:",omitempty"` + 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 48ba85ce4f..61f6269ac1 100644 --- a/internal/sql/ast/comment_stmt.go +++ b/internal/sql/ast/comment_stmt.go @@ -3,9 +3,9 @@ package ast type CommentStmt struct { Tag NodeTag[CommentStmt] `json:"tag"` - Objtype ObjectType - Object Node `json:",omitempty"` - Comment *string `json:",omitempty"` + 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 480ae73432..84f7db47af 100644 --- a/internal/sql/ast/common_table_expr.go +++ b/internal/sql/ast/common_table_expr.go @@ -5,16 +5,16 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CommonTableExpr struct { Tag NodeTag[CommonTableExpr] `json:"tag"` - Ctename *string `json:",omitempty"` - Aliascolnames *List `json:",omitempty"` - Ctequery Node `json:",omitempty"` - Location int - Cterecursive bool - Cterefcount int - Ctecolnames *List `json:",omitempty"` - Ctecoltypes *List `json:",omitempty"` - Ctecoltypmods *List `json:",omitempty"` - Ctecolcollations *List `json:",omitempty"` + 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 3ec95e8285..eab6f7f4cc 100644 --- a/internal/sql/ast/composite_type_stmt.go +++ b/internal/sql/ast/composite_type_stmt.go @@ -3,7 +3,7 @@ package ast type CompositeTypeStmt struct { Tag NodeTag[CompositeTypeStmt] `json:"tag"` - TypeName *TypeName `json:",omitempty"` + 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 0c114b6a40..58d33e9920 100644 --- a/internal/sql/ast/const.go +++ b/internal/sql/ast/const.go @@ -3,15 +3,15 @@ package ast type Const struct { Tag NodeTag[Const] `json:"tag"` - Xpr Node `json:",omitempty"` - Consttype Oid - Consttypmod int32 - Constcollid Oid - Constlen int - Constvalue Datum - Constisnull bool - Constbyval bool - Location int + 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 7b8017741e..bd9c7348f1 100644 --- a/internal/sql/ast/constraint.go +++ b/internal/sql/ast/constraint.go @@ -3,32 +3,32 @@ package ast type Constraint struct { Tag NodeTag[Constraint] `json:"tag"` - Contype ConstrType - Conname *string `json:",omitempty"` - Deferrable bool - Initdeferred bool - Location int - IsNoInherit bool - RawExpr Node `json:",omitempty"` - CookedExpr *string `json:",omitempty"` - GeneratedWhen byte - Keys *List `json:",omitempty"` - Exclusions *List `json:",omitempty"` - Options *List `json:",omitempty"` - Indexname *string `json:",omitempty"` - Indexspace *string `json:",omitempty"` - AccessMethod *string `json:",omitempty"` - WhereClause Node `json:",omitempty"` - Pktable *RangeVar `json:",omitempty"` - FkAttrs *List `json:",omitempty"` - PkAttrs *List `json:",omitempty"` - FkMatchtype byte - FkUpdAction byte - FkDelAction byte - OldConpfeqop *List `json:",omitempty"` - OldPktableOid Oid - SkipValidation bool - InitiallyValid bool + 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 71dadf8437..b677dca751 100644 --- a/internal/sql/ast/constraints_set_stmt.go +++ b/internal/sql/ast/constraints_set_stmt.go @@ -3,8 +3,8 @@ package ast type ConstraintsSetStmt struct { Tag NodeTag[ConstraintsSetStmt] `json:"tag"` - Constraints *List `json:",omitempty"` - Deferred bool + 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 24461d467d..60c3f12c1d 100644 --- a/internal/sql/ast/convert_rowtype_expr.go +++ b/internal/sql/ast/convert_rowtype_expr.go @@ -3,11 +3,11 @@ package ast type ConvertRowtypeExpr struct { Tag NodeTag[ConvertRowtypeExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Resulttype Oid - Convertformat CoercionForm - Location int + 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 7c68f023a0..93d83d6fde 100644 --- a/internal/sql/ast/copy_stmt.go +++ b/internal/sql/ast/copy_stmt.go @@ -3,13 +3,13 @@ package ast type CopyStmt struct { Tag NodeTag[CopyStmt] `json:"tag"` - Relation *RangeVar `json:",omitempty"` - Query Node `json:",omitempty"` - Attlist *List `json:",omitempty"` - IsFrom bool - IsProgram bool - Filename *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 8b7c361a13..8f0859067b 100644 --- a/internal/sql/ast/create_am_stmt.go +++ b/internal/sql/ast/create_am_stmt.go @@ -3,9 +3,9 @@ package ast type CreateAmStmt struct { Tag NodeTag[CreateAmStmt] `json:"tag"` - Amname *string `json:",omitempty"` - HandlerName *List `json:",omitempty"` - Amtype byte + 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 839826879c..188d633c8c 100644 --- a/internal/sql/ast/create_cast_stmt.go +++ b/internal/sql/ast/create_cast_stmt.go @@ -3,11 +3,11 @@ package ast type CreateCastStmt struct { Tag NodeTag[CreateCastStmt] `json:"tag"` - Sourcetype *TypeName `json:",omitempty"` - Targettype *TypeName `json:",omitempty"` - Func *ObjectWithArgs `json:",omitempty"` - Context CoercionContext - Inout bool + 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 5a9dfcca86..38be006520 100644 --- a/internal/sql/ast/create_conversion_stmt.go +++ b/internal/sql/ast/create_conversion_stmt.go @@ -3,11 +3,11 @@ package ast type CreateConversionStmt struct { Tag NodeTag[CreateConversionStmt] `json:"tag"` - ConversionName *List `json:",omitempty"` - ForEncodingName *string `json:",omitempty"` - ToEncodingName *string `json:",omitempty"` - FuncName *List `json:",omitempty"` - Def bool + 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 f9351cd8ee..8cc2324c35 100644 --- a/internal/sql/ast/create_domain_stmt.go +++ b/internal/sql/ast/create_domain_stmt.go @@ -3,10 +3,10 @@ package ast type CreateDomainStmt struct { Tag NodeTag[CreateDomainStmt] `json:"tag"` - Domainname *List `json:",omitempty"` - TypeName *TypeName `json:",omitempty"` - CollClause *CollateClause `json:",omitempty"` - Constraints *List `json:",omitempty"` + 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 fd952b2cd9..f38316b4aa 100644 --- a/internal/sql/ast/create_enum_stmt.go +++ b/internal/sql/ast/create_enum_stmt.go @@ -3,8 +3,8 @@ package ast type CreateEnumStmt struct { Tag NodeTag[CreateEnumStmt] `json:"tag"` - TypeName *TypeName `json:",omitempty"` - Vals *List `json:",omitempty"` + 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 d716436b42..eea8012286 100644 --- a/internal/sql/ast/create_event_trig_stmt.go +++ b/internal/sql/ast/create_event_trig_stmt.go @@ -3,10 +3,10 @@ package ast type CreateEventTrigStmt struct { Tag NodeTag[CreateEventTrigStmt] `json:"tag"` - Trigname *string `json:",omitempty"` - Eventname *string `json:",omitempty"` - Whenclause *List `json:",omitempty"` - Funcname *List `json:",omitempty"` + 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 a9bfa557d9..d73aed8308 100644 --- a/internal/sql/ast/create_extension_stmt.go +++ b/internal/sql/ast/create_extension_stmt.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateExtensionStmt struct { Tag NodeTag[CreateExtensionStmt] `json:"tag"` - Extname *string `json:",omitempty"` - IfNotExists bool - Options *List `json:",omitempty"` + 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 6f1bd9421d..74cb794294 100644 --- a/internal/sql/ast/create_fdw_stmt.go +++ b/internal/sql/ast/create_fdw_stmt.go @@ -3,9 +3,9 @@ package ast type CreateFdwStmt struct { Tag NodeTag[CreateFdwStmt] `json:"tag"` - Fdwname *string `json:",omitempty"` - FuncOptions *List `json:",omitempty"` - Options *List `json:",omitempty"` + 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 bd8d936eff..da9d78a58e 100644 --- a/internal/sql/ast/create_foreign_server_stmt.go +++ b/internal/sql/ast/create_foreign_server_stmt.go @@ -3,12 +3,12 @@ package ast type CreateForeignServerStmt struct { Tag NodeTag[CreateForeignServerStmt] `json:"tag"` - Servername *string `json:",omitempty"` - Servertype *string `json:",omitempty"` - Version *string `json:",omitempty"` - Fdwname *string `json:",omitempty"` - IfNotExists bool - Options *List `json:",omitempty"` + 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 4e0b8e5089..764e72996d 100644 --- a/internal/sql/ast/create_foreign_table_stmt.go +++ b/internal/sql/ast/create_foreign_table_stmt.go @@ -3,9 +3,9 @@ package ast type CreateForeignTableStmt struct { Tag NodeTag[CreateForeignTableStmt] `json:"tag"` - Base *CreateStmt `json:",omitempty"` - Servername *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 71af48da39..3fb3bb79fa 100644 --- a/internal/sql/ast/create_function_stmt.go +++ b/internal/sql/ast/create_function_stmt.go @@ -5,13 +5,13 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateFunctionStmt struct { Tag NodeTag[CreateFunctionStmt] `json:"tag"` - Replace bool - Params *List `json:",omitempty"` - ReturnType *TypeName `json:",omitempty"` - Func *FuncName `json:",omitempty"` + 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 `json:",omitempty"` - WithClause *List `json:",omitempty"` + 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 e1709856a5..0b1f4ad728 100644 --- a/internal/sql/ast/create_op_class_item.go +++ b/internal/sql/ast/create_op_class_item.go @@ -3,12 +3,12 @@ package ast type CreateOpClassItem struct { Tag NodeTag[CreateOpClassItem] `json:"tag"` - Itemtype int - Name *ObjectWithArgs `json:",omitempty"` - Number int - OrderFamily *List `json:",omitempty"` - ClassArgs *List `json:",omitempty"` - Storedtype *TypeName `json:",omitempty"` + 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 a4b62f4129..9b606c4610 100644 --- a/internal/sql/ast/create_op_class_stmt.go +++ b/internal/sql/ast/create_op_class_stmt.go @@ -3,12 +3,12 @@ package ast type CreateOpClassStmt struct { Tag NodeTag[CreateOpClassStmt] `json:"tag"` - Opclassname *List `json:",omitempty"` - Opfamilyname *List `json:",omitempty"` - Amname *string `json:",omitempty"` - Datatype *TypeName `json:",omitempty"` - Items *List `json:",omitempty"` - IsDefault bool + 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 4e4a497004..4db1cc411b 100644 --- a/internal/sql/ast/create_op_family_stmt.go +++ b/internal/sql/ast/create_op_family_stmt.go @@ -3,8 +3,8 @@ package ast type CreateOpFamilyStmt struct { Tag NodeTag[CreateOpFamilyStmt] `json:"tag"` - Opfamilyname *List `json:",omitempty"` - Amname *string `json:",omitempty"` + 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 f3b9ab9fda..f6d43980e9 100644 --- a/internal/sql/ast/create_p_lang_stmt.go +++ b/internal/sql/ast/create_p_lang_stmt.go @@ -3,12 +3,12 @@ package ast type CreatePLangStmt struct { Tag NodeTag[CreatePLangStmt] `json:"tag"` - Replace bool - Plname *string `json:",omitempty"` - Plhandler *List `json:",omitempty"` - Plinline *List `json:",omitempty"` - Plvalidator *List `json:",omitempty"` - Pltrusted bool + 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 e945edbfc8..3d191a2480 100644 --- a/internal/sql/ast/create_policy_stmt.go +++ b/internal/sql/ast/create_policy_stmt.go @@ -3,13 +3,13 @@ package ast type CreatePolicyStmt struct { Tag NodeTag[CreatePolicyStmt] `json:"tag"` - PolicyName *string `json:",omitempty"` - Table *RangeVar `json:",omitempty"` - CmdName *string `json:",omitempty"` - Permissive bool - Roles *List `json:",omitempty"` - Qual Node `json:",omitempty"` - WithCheck Node `json:",omitempty"` + 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 e20a133d03..90e0c737af 100644 --- a/internal/sql/ast/create_publication_stmt.go +++ b/internal/sql/ast/create_publication_stmt.go @@ -3,10 +3,10 @@ package ast type CreatePublicationStmt struct { Tag NodeTag[CreatePublicationStmt] `json:"tag"` - Pubname *string `json:",omitempty"` - Options *List `json:",omitempty"` - Tables *List `json:",omitempty"` - ForAllTables bool + 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 f832d5ba2f..7ac3b8a353 100644 --- a/internal/sql/ast/create_range_stmt.go +++ b/internal/sql/ast/create_range_stmt.go @@ -3,8 +3,8 @@ package ast type CreateRangeStmt struct { Tag NodeTag[CreateRangeStmt] `json:"tag"` - TypeName *List `json:",omitempty"` - Params *List `json:",omitempty"` + 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 a9787e33ad..667d702dd9 100644 --- a/internal/sql/ast/create_role_stmt.go +++ b/internal/sql/ast/create_role_stmt.go @@ -3,9 +3,9 @@ package ast type CreateRoleStmt struct { Tag NodeTag[CreateRoleStmt] `json:"tag"` - StmtType RoleStmtType - Role *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 aaec484f10..e07dafaffd 100644 --- a/internal/sql/ast/create_schema_stmt.go +++ b/internal/sql/ast/create_schema_stmt.go @@ -3,10 +3,10 @@ package ast type CreateSchemaStmt struct { Tag NodeTag[CreateSchemaStmt] `json:"tag"` - Name *string `json:",omitempty"` - SchemaElts *List `json:",omitempty"` - Authrole *RoleSpec `json:",omitempty"` - IfNotExists bool + 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 2293841ed8..66c35a7080 100644 --- a/internal/sql/ast/create_seq_stmt.go +++ b/internal/sql/ast/create_seq_stmt.go @@ -3,11 +3,11 @@ package ast type CreateSeqStmt struct { Tag NodeTag[CreateSeqStmt] `json:"tag"` - Sequence *RangeVar `json:",omitempty"` - Options *List `json:",omitempty"` - OwnerId Oid - ForIdentity bool - IfNotExists bool + 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 53c82f4290..17b8af22a3 100644 --- a/internal/sql/ast/create_stats_stmt.go +++ b/internal/sql/ast/create_stats_stmt.go @@ -3,11 +3,11 @@ package ast type CreateStatsStmt struct { Tag NodeTag[CreateStatsStmt] `json:"tag"` - Defnames *List `json:",omitempty"` - StatTypes *List `json:",omitempty"` - Exprs *List `json:",omitempty"` - Relations *List `json:",omitempty"` - IfNotExists bool + 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 da0721836a..5d69e7bb16 100644 --- a/internal/sql/ast/create_stmt.go +++ b/internal/sql/ast/create_stmt.go @@ -3,17 +3,17 @@ package ast type CreateStmt struct { Tag NodeTag[CreateStmt] `json:"tag"` - Relation *RangeVar `json:",omitempty"` - TableElts *List `json:",omitempty"` - InhRelations *List `json:",omitempty"` - Partbound *PartitionBoundSpec `json:",omitempty"` - Partspec *PartitionSpec `json:",omitempty"` - OfTypename *TypeName `json:",omitempty"` - Constraints *List `json:",omitempty"` - Options *List `json:",omitempty"` - Oncommit OnCommitAction - Tablespacename *string `json:",omitempty"` - IfNotExists bool + 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 db0d14943f..d4c3c678a4 100644 --- a/internal/sql/ast/create_subscription_stmt.go +++ b/internal/sql/ast/create_subscription_stmt.go @@ -3,10 +3,10 @@ package ast type CreateSubscriptionStmt struct { Tag NodeTag[CreateSubscriptionStmt] `json:"tag"` - Subname *string `json:",omitempty"` - Conninfo *string `json:",omitempty"` - Publication *List `json:",omitempty"` - Options *List `json:",omitempty"` + 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 66b24a0c97..862d0c45d0 100644 --- a/internal/sql/ast/create_table_as_stmt.go +++ b/internal/sql/ast/create_table_as_stmt.go @@ -3,11 +3,11 @@ package ast type CreateTableAsStmt struct { Tag NodeTag[CreateTableAsStmt] `json:"tag"` - Query Node `json:",omitempty"` - Into *IntoClause `json:",omitempty"` - Relkind ObjectType - IsSelectInto bool - IfNotExists bool + 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 2a1d6925d8..7c55d5d86a 100644 --- a/internal/sql/ast/create_table_space_stmt.go +++ b/internal/sql/ast/create_table_space_stmt.go @@ -3,10 +3,10 @@ package ast type CreateTableSpaceStmt struct { Tag NodeTag[CreateTableSpaceStmt] `json:"tag"` - Tablespacename *string `json:",omitempty"` - Owner *RoleSpec `json:",omitempty"` - Location *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 637a0193f0..4abe5d09fb 100644 --- a/internal/sql/ast/create_table_stmt.go +++ b/internal/sql/ast/create_table_stmt.go @@ -5,12 +5,12 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type CreateTableStmt struct { Tag NodeTag[CreateTableStmt] `json:"tag"` - IfNotExists bool - Name *TableName `json:",omitempty"` - Cols []*ColumnDef `json:",omitempty"` - ReferTable *TableName `json:",omitempty"` - Comment string - Inherits []*TableName `json:",omitempty"` + 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 @@ -18,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 `json:",omitempty"` + 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 f771c7c3d3..20b0c633fc 100644 --- a/internal/sql/ast/create_transform_stmt.go +++ b/internal/sql/ast/create_transform_stmt.go @@ -3,11 +3,11 @@ package ast type CreateTransformStmt struct { Tag NodeTag[CreateTransformStmt] `json:"tag"` - Replace bool - TypeName *TypeName `json:",omitempty"` - Lang *string `json:",omitempty"` - Fromsql *ObjectWithArgs `json:",omitempty"` - Tosql *ObjectWithArgs `json:",omitempty"` + 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 8b1b422e39..b0c81d6891 100644 --- a/internal/sql/ast/create_trig_stmt.go +++ b/internal/sql/ast/create_trig_stmt.go @@ -3,20 +3,20 @@ package ast type CreateTrigStmt struct { Tag NodeTag[CreateTrigStmt] `json:"tag"` - Trigname *string `json:",omitempty"` - Relation *RangeVar `json:",omitempty"` - Funcname *List `json:",omitempty"` - Args *List `json:",omitempty"` - Row bool - Timing int16 - Events int16 - Columns *List `json:",omitempty"` - WhenClause Node `json:",omitempty"` - Isconstraint bool - TransitionRels *List `json:",omitempty"` - Deferrable bool - Initdeferred bool - Constrrel *RangeVar `json:",omitempty"` + 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 bdbb03c766..e67bd62302 100644 --- a/internal/sql/ast/create_user_mapping_stmt.go +++ b/internal/sql/ast/create_user_mapping_stmt.go @@ -3,10 +3,10 @@ package ast type CreateUserMappingStmt struct { Tag NodeTag[CreateUserMappingStmt] `json:"tag"` - User *RoleSpec `json:",omitempty"` - Servername *string `json:",omitempty"` - IfNotExists bool - Options *List `json:",omitempty"` + 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 bf6a578b70..ee08567a07 100644 --- a/internal/sql/ast/createdb_stmt.go +++ b/internal/sql/ast/createdb_stmt.go @@ -3,8 +3,8 @@ package ast type CreatedbStmt struct { Tag NodeTag[CreatedbStmt] `json:"tag"` - Dbname *string `json:",omitempty"` - Options *List `json:",omitempty"` + 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 37b7ab8bb9..ac9eb35b3f 100644 --- a/internal/sql/ast/current_of_expr.go +++ b/internal/sql/ast/current_of_expr.go @@ -3,10 +3,10 @@ package ast type CurrentOfExpr struct { Tag NodeTag[CurrentOfExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Cvarno Index - CursorName *string `json:",omitempty"` - CursorParam int + 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 5d82eaf573..c51908fb82 100644 --- a/internal/sql/ast/deallocate_stmt.go +++ b/internal/sql/ast/deallocate_stmt.go @@ -3,7 +3,7 @@ package ast type DeallocateStmt struct { Tag NodeTag[DeallocateStmt] `json:"tag"` - Name *string `json:",omitempty"` + 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 bb3ab62575..52c8a226d5 100644 --- a/internal/sql/ast/declare_cursor_stmt.go +++ b/internal/sql/ast/declare_cursor_stmt.go @@ -3,9 +3,9 @@ package ast type DeclareCursorStmt struct { Tag NodeTag[DeclareCursorStmt] `json:"tag"` - Portalname *string `json:",omitempty"` - Options int - Query Node `json:",omitempty"` + 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 d7ce1108f8..9ccf44366a 100644 --- a/internal/sql/ast/def_elem.go +++ b/internal/sql/ast/def_elem.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type DefElem struct { Tag NodeTag[DefElem] `json:"tag"` - Defnamespace *string `json:",omitempty"` - Defname *string `json:",omitempty"` - Arg Node `json:",omitempty"` - Defaction DefElemAction - Location int + 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 51a4a0b4a0..9ac5e7a1e8 100644 --- a/internal/sql/ast/define_stmt.go +++ b/internal/sql/ast/define_stmt.go @@ -3,12 +3,12 @@ package ast type DefineStmt struct { Tag NodeTag[DefineStmt] `json:"tag"` - Kind ObjectType - Oldstyle bool - Defnames *List `json:",omitempty"` - Args *List `json:",omitempty"` - Definition *List `json:",omitempty"` - IfNotExists bool + 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 64bbbc810d..5d584b6d0c 100644 --- a/internal/sql/ast/delete_stmt.go +++ b/internal/sql/ast/delete_stmt.go @@ -5,18 +5,18 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type DeleteStmt struct { Tag NodeTag[DeleteStmt] `json:"tag"` - Relations *List `json:",omitempty"` - UsingClause *List `json:",omitempty"` - WhereClause Node `json:",omitempty"` - LimitCount Node `json:",omitempty"` - ReturningList *List `json:",omitempty"` - WithClause *WithClause `json:",omitempty"` + 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 `json:",omitempty"` // Tables to delete from (e.g., jt.*, pt.*) - FromClause Node `json:",omitempty"` // 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 cc5b9c55f2..6831f7df81 100644 --- a/internal/sql/ast/discard_stmt.go +++ b/internal/sql/ast/discard_stmt.go @@ -3,7 +3,7 @@ package ast type DiscardStmt struct { Tag NodeTag[DiscardStmt] `json:"tag"` - Target DiscardMode + 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 415bc801c5..f21bafe8c5 100644 --- a/internal/sql/ast/do_stmt.go +++ b/internal/sql/ast/do_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type DoStmt struct { Tag NodeTag[DoStmt] `json:"tag"` - Args *List `json:",omitempty"` + 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 87bb06d63d..e5fec40469 100644 --- a/internal/sql/ast/drop_function_stmt.go +++ b/internal/sql/ast/drop_function_stmt.go @@ -3,8 +3,8 @@ package ast type DropFunctionStmt struct { Tag NodeTag[DropFunctionStmt] `json:"tag"` - Funcs []*FuncSpec `json:",omitempty"` - MissingOk bool + 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 ab33bb36fa..ab988187a0 100644 --- a/internal/sql/ast/drop_owned_stmt.go +++ b/internal/sql/ast/drop_owned_stmt.go @@ -3,8 +3,8 @@ package ast type DropOwnedStmt struct { Tag NodeTag[DropOwnedStmt] `json:"tag"` - Roles *List `json:",omitempty"` - Behavior DropBehavior + 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 985989830a..2bdcffd2ab 100644 --- a/internal/sql/ast/drop_role_stmt.go +++ b/internal/sql/ast/drop_role_stmt.go @@ -3,8 +3,8 @@ package ast type DropRoleStmt struct { Tag NodeTag[DropRoleStmt] `json:"tag"` - Roles *List `json:",omitempty"` - MissingOk bool + 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 7314a32f80..f5d9f1e7ca 100644 --- a/internal/sql/ast/drop_schema_stmt.go +++ b/internal/sql/ast/drop_schema_stmt.go @@ -3,8 +3,8 @@ package ast type DropSchemaStmt struct { Tag NodeTag[DropSchemaStmt] `json:"tag"` - Schemas []*String `json:",omitempty"` - MissingOk bool + 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 7e6e3c6fac..3305e16bf5 100644 --- a/internal/sql/ast/drop_stmt.go +++ b/internal/sql/ast/drop_stmt.go @@ -3,11 +3,11 @@ package ast type DropStmt struct { Tag NodeTag[DropStmt] `json:"tag"` - Objects *List `json:",omitempty"` - RemoveType ObjectType - Behavior DropBehavior - MissingOk bool - Concurrent bool + 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 f095a22b3d..3fbd8528e4 100644 --- a/internal/sql/ast/drop_subscription_stmt.go +++ b/internal/sql/ast/drop_subscription_stmt.go @@ -3,9 +3,9 @@ package ast type DropSubscriptionStmt struct { Tag NodeTag[DropSubscriptionStmt] `json:"tag"` - Subname *string `json:",omitempty"` - MissingOk bool - Behavior DropBehavior + 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 740857d15d..8093e7331c 100644 --- a/internal/sql/ast/drop_table_space_stmt.go +++ b/internal/sql/ast/drop_table_space_stmt.go @@ -3,8 +3,8 @@ package ast type DropTableSpaceStmt struct { Tag NodeTag[DropTableSpaceStmt] `json:"tag"` - Tablespacename *string `json:",omitempty"` - MissingOk bool + 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 3e10641b1f..4687b7cbe3 100644 --- a/internal/sql/ast/drop_table_stmt.go +++ b/internal/sql/ast/drop_table_stmt.go @@ -3,8 +3,8 @@ package ast type DropTableStmt struct { Tag NodeTag[DropTableStmt] `json:"tag"` - IfExists bool - Tables []*TableName `json:",omitempty"` + 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 48b6472abd..dcef895f1b 100644 --- a/internal/sql/ast/drop_type_stmt.go +++ b/internal/sql/ast/drop_type_stmt.go @@ -3,8 +3,8 @@ package ast type DropTypeStmt struct { Tag NodeTag[DropTypeStmt] `json:"tag"` - IfExists bool - Types []*TypeName `json:",omitempty"` + 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 5ece8988c0..9503d8a259 100644 --- a/internal/sql/ast/drop_user_mapping_stmt.go +++ b/internal/sql/ast/drop_user_mapping_stmt.go @@ -3,9 +3,9 @@ package ast type DropUserMappingStmt struct { Tag NodeTag[DropUserMappingStmt] `json:"tag"` - User *RoleSpec `json:",omitempty"` - Servername *string `json:",omitempty"` - MissingOk bool + 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 c79e1b3e63..da6eb860bb 100644 --- a/internal/sql/ast/dropdb_stmt.go +++ b/internal/sql/ast/dropdb_stmt.go @@ -3,8 +3,8 @@ package ast type DropdbStmt struct { Tag NodeTag[DropdbStmt] `json:"tag"` - Dbname *string `json:",omitempty"` - MissingOk bool + 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 18887523d4..4ede4f42ca 100644 --- a/internal/sql/ast/execute_stmt.go +++ b/internal/sql/ast/execute_stmt.go @@ -3,8 +3,8 @@ package ast type ExecuteStmt struct { Tag NodeTag[ExecuteStmt] `json:"tag"` - Name *string `json:",omitempty"` - Params *List `json:",omitempty"` + 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 3640293c53..66c5608035 100644 --- a/internal/sql/ast/explain_stmt.go +++ b/internal/sql/ast/explain_stmt.go @@ -3,8 +3,8 @@ package ast type ExplainStmt struct { Tag NodeTag[ExplainStmt] `json:"tag"` - Query Node `json:",omitempty"` - Options *List `json:",omitempty"` + Query Node `json:"query,omitempty"` + Options *List `json:"options,omitempty"` } func (n *ExplainStmt) Pos() int { diff --git a/internal/sql/ast/fetch_stmt.go b/internal/sql/ast/fetch_stmt.go index 911a7781f9..7a59569e37 100644 --- a/internal/sql/ast/fetch_stmt.go +++ b/internal/sql/ast/fetch_stmt.go @@ -3,10 +3,10 @@ package ast type FetchStmt struct { Tag NodeTag[FetchStmt] `json:"tag"` - Direction FetchDirection - HowMany int64 - Portalname *string `json:",omitempty"` - Ismove bool + 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 e82482877e..57f77a6794 100644 --- a/internal/sql/ast/field_select.go +++ b/internal/sql/ast/field_select.go @@ -3,12 +3,12 @@ package ast type FieldSelect struct { Tag NodeTag[FieldSelect] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Fieldnum AttrNumber - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid + 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 4755a9c06b..505c924a9c 100644 --- a/internal/sql/ast/field_store.go +++ b/internal/sql/ast/field_store.go @@ -3,11 +3,11 @@ package ast type FieldStore struct { Tag NodeTag[FieldStore] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Newvals *List `json:",omitempty"` - Fieldnums *List `json:",omitempty"` - Resulttype Oid + 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 2b29dbee87..a91b89a273 100644 --- a/internal/sql/ast/float.go +++ b/internal/sql/ast/float.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type Float struct { Tag NodeTag[Float] `json:"tag"` - Str string + 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 2f11a9571a..021ac30cf8 100644 --- a/internal/sql/ast/from_expr.go +++ b/internal/sql/ast/from_expr.go @@ -3,8 +3,8 @@ package ast type FromExpr struct { Tag NodeTag[FromExpr] `json:"tag"` - Fromlist *List `json:",omitempty"` - Quals Node `json:",omitempty"` + 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 c4157877fc..f7e041f3cd 100644 --- a/internal/sql/ast/func_call.go +++ b/internal/sql/ast/func_call.go @@ -5,18 +5,18 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncCall struct { Tag NodeTag[FuncCall] `json:"tag"` - Func *FuncName `json:",omitempty"` - Funcname *List `json:",omitempty"` - Args *List `json:",omitempty"` - AggOrder *List `json:",omitempty"` - AggFilter Node `json:",omitempty"` - AggWithinGroup bool - AggStar bool - AggDistinct bool - FuncVariadic bool - Over *WindowDef `json:",omitempty"` - Separator *string `json:",omitempty"` // MySQL GROUP_CONCAT SEPARATOR - Location int + 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 45c4e31e16..39dee6f0ae 100644 --- a/internal/sql/ast/func_expr.go +++ b/internal/sql/ast/func_expr.go @@ -3,16 +3,16 @@ package ast type FuncExpr struct { Tag NodeTag[FuncExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Funcid Oid - Funcresulttype Oid - Funcretset bool - Funcvariadic bool - Funcformat CoercionForm - Funccollid Oid - Inputcollid Oid - Args *List `json:",omitempty"` - Location int + 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 58f32de754..0c1d6fb7a3 100644 --- a/internal/sql/ast/func_name.go +++ b/internal/sql/ast/func_name.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type FuncName struct { Tag NodeTag[FuncName] `json:"tag"` - Catalog string - Schema string - Name string + 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 0c52b3ebe3..ae353f36d9 100644 --- a/internal/sql/ast/func_param.go +++ b/internal/sql/ast/func_param.go @@ -16,10 +16,10 @@ const ( type FuncParam struct { Tag NodeTag[FuncParam] `json:"tag"` - Name *string `json:",omitempty"` - Type *TypeName `json:",omitempty"` - DefExpr Node `json:",omitempty"` // Will always be &ast.TODO - Mode FuncParamMode + 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 beab892975..019bac9218 100644 --- a/internal/sql/ast/func_spec.go +++ b/internal/sql/ast/func_spec.go @@ -3,9 +3,9 @@ package ast type FuncSpec struct { Tag NodeTag[FuncSpec] `json:"tag"` - Name *FuncName `json:",omitempty"` - Args []*TypeName `json:",omitempty"` - HasArgs bool + 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 69d5e6386f..3bbb086713 100644 --- a/internal/sql/ast/function_parameter.go +++ b/internal/sql/ast/function_parameter.go @@ -3,10 +3,10 @@ package ast type FunctionParameter struct { Tag NodeTag[FunctionParameter] `json:"tag"` - Name *string `json:",omitempty"` - ArgType *TypeName `json:",omitempty"` - Mode FunctionParameterMode - Defexpr Node `json:",omitempty"` + 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 32f36b779e..0dd26f9cc3 100644 --- a/internal/sql/ast/grant_role_stmt.go +++ b/internal/sql/ast/grant_role_stmt.go @@ -3,11 +3,11 @@ package ast type GrantRoleStmt struct { Tag NodeTag[GrantRoleStmt] `json:"tag"` - GrantedRoles *List `json:",omitempty"` - GranteeRoles *List `json:",omitempty"` - IsGrant bool - Grantor *RoleSpec `json:",omitempty"` - Behavior DropBehavior + 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 9ff2d6dd4d..964395c146 100644 --- a/internal/sql/ast/grant_stmt.go +++ b/internal/sql/ast/grant_stmt.go @@ -3,14 +3,14 @@ package ast type GrantStmt struct { Tag NodeTag[GrantStmt] `json:"tag"` - IsGrant bool - Targtype GrantTargetType - Objtype GrantObjectType - Objects *List `json:",omitempty"` - Privileges *List `json:",omitempty"` - Grantees *List `json:",omitempty"` - GrantOption bool - Behavior DropBehavior + 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 7a52bcc5d7..80f8471560 100644 --- a/internal/sql/ast/grouping_func.go +++ b/internal/sql/ast/grouping_func.go @@ -3,12 +3,12 @@ package ast type GroupingFunc struct { Tag NodeTag[GroupingFunc] `json:"tag"` - Xpr Node `json:",omitempty"` - Args *List `json:",omitempty"` - Refs *List `json:",omitempty"` - Cols *List `json:",omitempty"` - Agglevelsup Index - Location int + 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 ddb14f436d..10c5098f82 100644 --- a/internal/sql/ast/grouping_set.go +++ b/internal/sql/ast/grouping_set.go @@ -3,9 +3,9 @@ package ast type GroupingSet struct { Tag NodeTag[GroupingSet] `json:"tag"` - Kind GroupingSetKind - Content *List `json:",omitempty"` - Location int + 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 92f7e768eb..7d824bdbf3 100644 --- a/internal/sql/ast/import_foreign_schema_stmt.go +++ b/internal/sql/ast/import_foreign_schema_stmt.go @@ -3,12 +3,12 @@ package ast type ImportForeignSchemaStmt struct { Tag NodeTag[ImportForeignSchemaStmt] `json:"tag"` - ServerName *string `json:",omitempty"` - RemoteSchema *string `json:",omitempty"` - LocalSchema *string `json:",omitempty"` - ListType ImportForeignSchemaType - TableList *List `json:",omitempty"` - Options *List `json:",omitempty"` + 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 7be470d022..6afa9fcaf0 100644 --- a/internal/sql/ast/in.go +++ b/internal/sql/ast/in.go @@ -7,14 +7,14 @@ type In struct { Tag NodeTag[In] `json:"tag"` // Expr is the value expression to be compared. - Expr Node `json:",omitempty"` + Expr Node `json:"expr,omitempty"` // List is the list expression in compare list. - List []Node `json:",omitempty"` + 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 `json:",omitempty"` - 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 4b61798a1a..e49ea05c28 100644 --- a/internal/sql/ast/index_elem.go +++ b/internal/sql/ast/index_elem.go @@ -5,13 +5,13 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type IndexElem struct { Tag NodeTag[IndexElem] `json:"tag"` - Name *string `json:",omitempty"` - Expr Node `json:",omitempty"` - Indexcolname *string `json:",omitempty"` - Collation *List `json:",omitempty"` - Opclass *List `json:",omitempty"` - Ordering SortByDir - NullsOrdering SortByNulls + 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 ec12c6ba32..5eafbcb95f 100644 --- a/internal/sql/ast/index_stmt.go +++ b/internal/sql/ast/index_stmt.go @@ -3,24 +3,24 @@ package ast type IndexStmt struct { Tag NodeTag[IndexStmt] `json:"tag"` - Idxname *string `json:",omitempty"` - Relation *RangeVar `json:",omitempty"` - AccessMethod *string `json:",omitempty"` - TableSpace *string `json:",omitempty"` - IndexParams *List `json:",omitempty"` - Options *List `json:",omitempty"` - WhereClause Node `json:",omitempty"` - ExcludeOpNames *List `json:",omitempty"` - Idxcomment *string `json:",omitempty"` - IndexOid Oid - Unique bool - Primary bool - Isconstraint bool - Deferrable bool - Initdeferred bool - Transformed bool - Concurrent bool - IfNotExists bool + 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 d51381b0fb..f4dc4bc46d 100644 --- a/internal/sql/ast/infer_clause.go +++ b/internal/sql/ast/infer_clause.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type InferClause struct { Tag NodeTag[InferClause] `json:"tag"` - IndexElems *List `json:",omitempty"` - WhereClause Node `json:",omitempty"` - Conname *string `json:",omitempty"` - Location int + 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 fde931e796..be27eb88a8 100644 --- a/internal/sql/ast/inference_elem.go +++ b/internal/sql/ast/inference_elem.go @@ -3,10 +3,10 @@ package ast type InferenceElem struct { Tag NodeTag[InferenceElem] `json:"tag"` - Xpr Node `json:",omitempty"` - Expr Node `json:",omitempty"` - Infercollid Oid - Inferopclass Oid + 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 fc675cb4b4..6698334d1e 100644 --- a/internal/sql/ast/inline_code_block.go +++ b/internal/sql/ast/inline_code_block.go @@ -3,9 +3,9 @@ package ast type InlineCodeBlock struct { Tag NodeTag[InlineCodeBlock] `json:"tag"` - SourceText *string `json:",omitempty"` - LangOid Oid - LangIsTrusted bool + 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 dd1ddb9672..e6d3d3a190 100644 --- a/internal/sql/ast/insert_stmt.go +++ b/internal/sql/ast/insert_stmt.go @@ -5,18 +5,18 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type InsertStmt struct { Tag NodeTag[InsertStmt] `json:"tag"` - Relation *RangeVar `json:",omitempty"` - Cols *List `json:",omitempty"` - SelectStmt Node `json:",omitempty"` - OnConflictClause *OnConflictClause `json:",omitempty"` - OnDuplicateKeyUpdate *OnDuplicateKeyUpdate `json:",omitempty"` // MySQL-specific - ReturningList *List `json:",omitempty"` - WithClause *WithClause `json:",omitempty"` - Override OverridingKind - DefaultValues bool // SQLite-specific: INSERT INTO ... DEFAULT VALUES + 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 45481f5c09..30c270572b 100644 --- a/internal/sql/ast/integer.go +++ b/internal/sql/ast/integer.go @@ -9,7 +9,7 @@ import ( type Integer struct { Tag NodeTag[Integer] `json:"tag"` - Ival int64 + 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 69300c95c1..f89ceed80c 100644 --- a/internal/sql/ast/interval_expr.go +++ b/internal/sql/ast/interval_expr.go @@ -6,9 +6,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type IntervalExpr struct { Tag NodeTag[IntervalExpr] `json:"tag"` - Value Node `json:",omitempty"` - Unit string - Location int + 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 37940527bd..1a74d37bf4 100644 --- a/internal/sql/ast/into_clause.go +++ b/internal/sql/ast/into_clause.go @@ -3,13 +3,13 @@ package ast type IntoClause struct { Tag NodeTag[IntoClause] `json:"tag"` - Rel *RangeVar `json:",omitempty"` - ColNames *List `json:",omitempty"` - Options *List `json:",omitempty"` - OnCommit OnCommitAction - TableSpaceName *string `json:",omitempty"` - ViewQuery Node `json:",omitempty"` - SkipData bool + 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 7d56b17055..59df9b3aee 100644 --- a/internal/sql/ast/join_expr.go +++ b/internal/sql/ast/join_expr.go @@ -5,14 +5,14 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type JoinExpr struct { Tag NodeTag[JoinExpr] `json:"tag"` - Jointype JoinType - IsNatural bool - Larg Node `json:",omitempty"` - Rarg Node `json:",omitempty"` - UsingClause *List `json:",omitempty"` - Quals Node `json:",omitempty"` - Alias *Alias `json:",omitempty"` - Rtindex int + 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 27cfc4402b..86a3fe00dc 100644 --- a/internal/sql/ast/list.go +++ b/internal/sql/ast/list.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type List struct { Tag NodeTag[List] `json:"tag"` - Items []Node `json:",omitempty"` + 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 44dcd983b5..3989225754 100644 --- a/internal/sql/ast/listen_stmt.go +++ b/internal/sql/ast/listen_stmt.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ListenStmt struct { Tag NodeTag[ListenStmt] `json:"tag"` - Conditionname *string `json:",omitempty"` + 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 4c1d3fc0b1..276f05a134 100644 --- a/internal/sql/ast/load_stmt.go +++ b/internal/sql/ast/load_stmt.go @@ -3,7 +3,7 @@ package ast type LoadStmt struct { Tag NodeTag[LoadStmt] `json:"tag"` - Filename *string `json:",omitempty"` + 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 e965da7bdf..82f2481640 100644 --- a/internal/sql/ast/lock_stmt.go +++ b/internal/sql/ast/lock_stmt.go @@ -3,9 +3,9 @@ package ast type LockStmt struct { Tag NodeTag[LockStmt] `json:"tag"` - Relations *List `json:",omitempty"` - Mode int - Nowait bool + 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 6ae01dd96e..00a3848f03 100644 --- a/internal/sql/ast/locking_clause.go +++ b/internal/sql/ast/locking_clause.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type LockingClause struct { Tag NodeTag[LockingClause] `json:"tag"` - LockedRels *List `json:",omitempty"` - Strength LockClauseStrength - WaitPolicy LockWaitPolicy + 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 d256611574..56da82aed1 100644 --- a/internal/sql/ast/min_max_expr.go +++ b/internal/sql/ast/min_max_expr.go @@ -3,13 +3,13 @@ package ast type MinMaxExpr struct { Tag NodeTag[MinMaxExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Minmaxtype Oid - Minmaxcollid Oid - Inputcollid Oid - Op MinMaxOp - Args *List `json:",omitempty"` - Location int + 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 4c3833563c..c1a7e30fc6 100644 --- a/internal/sql/ast/multi_assign_ref.go +++ b/internal/sql/ast/multi_assign_ref.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type MultiAssignRef struct { Tag NodeTag[MultiAssignRef] `json:"tag"` - Source Node `json:",omitempty"` - Colno int - Ncolumns int + 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 53ea100e6a..ec3d5a187e 100644 --- a/internal/sql/ast/named_arg_expr.go +++ b/internal/sql/ast/named_arg_expr.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type NamedArgExpr struct { Tag NodeTag[NamedArgExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Name *string `json:",omitempty"` - Argnumber int - Location int + 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 4b21a3ae39..6832e40449 100644 --- a/internal/sql/ast/next_value_expr.go +++ b/internal/sql/ast/next_value_expr.go @@ -3,9 +3,9 @@ package ast type NextValueExpr struct { Tag NodeTag[NextValueExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Seqid Oid - TypeId Oid + 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/notify_stmt.go b/internal/sql/ast/notify_stmt.go index d915d10d2d..1f2df47a9f 100644 --- a/internal/sql/ast/notify_stmt.go +++ b/internal/sql/ast/notify_stmt.go @@ -5,8 +5,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type NotifyStmt struct { Tag NodeTag[NotifyStmt] `json:"tag"` - Conditionname *string `json:",omitempty"` - Payload *string `json:",omitempty"` + Conditionname *string `json:"conditionname,omitempty"` + Payload *string `json:"payload,omitempty"` } func (n *NotifyStmt) Pos() int { diff --git a/internal/sql/ast/null_test_expr.go b/internal/sql/ast/null_test_expr.go index db93888623..ed0d1fddaf 100644 --- a/internal/sql/ast/null_test_expr.go +++ b/internal/sql/ast/null_test_expr.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type NullTest struct { Tag NodeTag[NullTest] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Nulltesttype NullTestType - Argisrow bool - Location int + 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 f9a0640780..05b0a0ce07 100644 --- a/internal/sql/ast/object_with_args.go +++ b/internal/sql/ast/object_with_args.go @@ -3,9 +3,9 @@ package ast type ObjectWithArgs struct { Tag NodeTag[ObjectWithArgs] `json:"tag"` - Objname *List `json:",omitempty"` - Objargs *List `json:",omitempty"` - ArgsUnspecified bool + 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 55eb45b48c..bbf01d6a82 100644 --- a/internal/sql/ast/on_conflict_clause.go +++ b/internal/sql/ast/on_conflict_clause.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type OnConflictClause struct { Tag NodeTag[OnConflictClause] `json:"tag"` - Action OnConflictAction - Infer *InferClause `json:",omitempty"` - TargetList *List `json:",omitempty"` - WhereClause Node `json:",omitempty"` - Location int + 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 07c7a31be0..5bd559e1c8 100644 --- a/internal/sql/ast/on_conflict_expr.go +++ b/internal/sql/ast/on_conflict_expr.go @@ -3,14 +3,14 @@ package ast type OnConflictExpr struct { Tag NodeTag[OnConflictExpr] `json:"tag"` - Action OnConflictAction - ArbiterElems *List `json:",omitempty"` - ArbiterWhere Node `json:",omitempty"` - Constraint Oid - OnConflictSet *List `json:",omitempty"` - OnConflictWhere Node `json:",omitempty"` - ExclRelIndex int - ExclRelTlist *List `json:",omitempty"` + 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 2b767f5545..bc1dbf4d13 100644 --- a/internal/sql/ast/on_duplicate_key_update.go +++ b/internal/sql/ast/on_duplicate_key_update.go @@ -7,8 +7,8 @@ type OnDuplicateKeyUpdate struct { Tag NodeTag[OnDuplicateKeyUpdate] `json:"tag"` // TargetList contains the assignments (column = value pairs) - TargetList *List `json:",omitempty"` - 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 ce7d352b1d..0d81af54ab 100644 --- a/internal/sql/ast/op_expr.go +++ b/internal/sql/ast/op_expr.go @@ -3,14 +3,14 @@ package ast type OpExpr struct { Tag NodeTag[OpExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Opno Oid - Opresulttype Oid - Opretset bool - Opcollid Oid - Inputcollid Oid - Args *List `json:",omitempty"` - Location int + 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 289148237c..d9121de50e 100644 --- a/internal/sql/ast/param.go +++ b/internal/sql/ast/param.go @@ -3,13 +3,13 @@ package ast type Param struct { Tag NodeTag[Param] `json:"tag"` - Xpr Node `json:",omitempty"` - Paramkind ParamKind - Paramid int - Paramtype Oid - Paramtypmod int32 - Paramcollid Oid - Location int + 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 9221d88f1e..6f151ea20a 100644 --- a/internal/sql/ast/param_exec_data.go +++ b/internal/sql/ast/param_exec_data.go @@ -3,9 +3,9 @@ package ast type ParamExecData struct { Tag NodeTag[ParamExecData] `json:"tag"` - ExecPlan any `json:",omitempty"` - Value Datum - Isnull bool + 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 c221a4bf8f..4da009ff3f 100644 --- a/internal/sql/ast/param_extern_data.go +++ b/internal/sql/ast/param_extern_data.go @@ -3,10 +3,10 @@ package ast type ParamExternData struct { Tag NodeTag[ParamExternData] `json:"tag"` - Value Datum - Isnull bool - Pflags uint16 - Ptype Oid + 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 2f28d88bdf..30e34d0bed 100644 --- a/internal/sql/ast/param_list_info_data.go +++ b/internal/sql/ast/param_list_info_data.go @@ -3,10 +3,10 @@ package ast type ParamListInfoData struct { Tag NodeTag[ParamListInfoData] `json:"tag"` - ParamFetchArg any `json:",omitempty"` - ParserSetupArg any `json:",omitempty"` - NumParams int - ParamMask []uint32 `json:",omitempty"` + 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 c35bc4e49b..2b7ec5c527 100644 --- a/internal/sql/ast/param_ref.go +++ b/internal/sql/ast/param_ref.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ParamRef struct { Tag NodeTag[ParamRef] `json:"tag"` - Number int - Location int - Dollar bool + 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 c8f2ab7f6f..79cb15b42b 100644 --- a/internal/sql/ast/paren_expr.go +++ b/internal/sql/ast/paren_expr.go @@ -6,8 +6,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ParenExpr struct { Tag NodeTag[ParenExpr] `json:"tag"` - Expr Node `json:",omitempty"` - Location int + 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 830ef66e7b..6f45517835 100644 --- a/internal/sql/ast/partition_bound_spec.go +++ b/internal/sql/ast/partition_bound_spec.go @@ -3,11 +3,11 @@ package ast type PartitionBoundSpec struct { Tag NodeTag[PartitionBoundSpec] `json:"tag"` - Strategy byte - Listdatums *List `json:",omitempty"` - Lowerdatums *List `json:",omitempty"` - Upperdatums *List `json:",omitempty"` - Location int + 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 472d884b1e..931b809172 100644 --- a/internal/sql/ast/partition_cmd.go +++ b/internal/sql/ast/partition_cmd.go @@ -3,8 +3,8 @@ package ast type PartitionCmd struct { Tag NodeTag[PartitionCmd] `json:"tag"` - Name *RangeVar `json:",omitempty"` - Bound *PartitionBoundSpec `json:",omitempty"` + 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 e53ea5cadf..1fe38fccb2 100644 --- a/internal/sql/ast/partition_elem.go +++ b/internal/sql/ast/partition_elem.go @@ -3,11 +3,11 @@ package ast type PartitionElem struct { Tag NodeTag[PartitionElem] `json:"tag"` - Name *string `json:",omitempty"` - Expr Node `json:",omitempty"` - Collation *List `json:",omitempty"` - Opclass *List `json:",omitempty"` - Location int + 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 7ec4aa119f..d827ced496 100644 --- a/internal/sql/ast/partition_range_datum.go +++ b/internal/sql/ast/partition_range_datum.go @@ -3,9 +3,9 @@ package ast type PartitionRangeDatum struct { Tag NodeTag[PartitionRangeDatum] `json:"tag"` - Kind PartitionRangeDatumKind - Value Node `json:",omitempty"` - Location int + 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 7e1d2c594a..1d0b17400d 100644 --- a/internal/sql/ast/partition_spec.go +++ b/internal/sql/ast/partition_spec.go @@ -3,9 +3,9 @@ package ast type PartitionSpec struct { Tag NodeTag[PartitionSpec] `json:"tag"` - Strategy *string `json:",omitempty"` - PartParams *List `json:",omitempty"` - Location int + 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 cad6109be1..a31633d1c8 100644 --- a/internal/sql/ast/prepare_stmt.go +++ b/internal/sql/ast/prepare_stmt.go @@ -3,9 +3,9 @@ package ast type PrepareStmt struct { Tag NodeTag[PrepareStmt] `json:"tag"` - Name *string `json:",omitempty"` - Argtypes *List `json:",omitempty"` - Query Node `json:",omitempty"` + 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 2c2248f5e8..7ace8aa9d9 100644 --- a/internal/sql/ast/query.go +++ b/internal/sql/ast/query.go @@ -3,42 +3,42 @@ package ast type Query struct { Tag NodeTag[Query] `json:"tag"` - CommandType CmdType - QuerySource QuerySource - QueryId uint32 - CanSetTag bool - UtilityStmt Node `json:",omitempty"` - ResultRelation int - HasAggs bool - HasWindowFuncs bool - HasTargetSrfs bool - HasSubLinks bool - HasDistinctOn bool - HasRecursive bool - HasModifyingCte bool - HasForUpdate bool - HasRowSecurity bool - CteList *List `json:",omitempty"` - Rtable *List `json:",omitempty"` - Jointree *FromExpr `json:",omitempty"` - TargetList *List `json:",omitempty"` - Override OverridingKind - OnConflict *OnConflictExpr `json:",omitempty"` - ReturningList *List `json:",omitempty"` - GroupClause *List `json:",omitempty"` - GroupingSets *List `json:",omitempty"` - HavingQual Node `json:",omitempty"` - WindowClause *List `json:",omitempty"` - DistinctClause *List `json:",omitempty"` - SortClause *List `json:",omitempty"` - LimitOffset Node `json:",omitempty"` - LimitCount Node `json:",omitempty"` - RowMarks *List `json:",omitempty"` - SetOperations Node `json:",omitempty"` - ConstraintDeps *List `json:",omitempty"` - WithCheckOptions *List `json:",omitempty"` - StmtLocation int - StmtLen int + 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 5144ec5975..3d1b6d0c30 100644 --- a/internal/sql/ast/range_function.go +++ b/internal/sql/ast/range_function.go @@ -5,12 +5,12 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeFunction struct { Tag NodeTag[RangeFunction] `json:"tag"` - Lateral bool - Ordinality bool - IsRowsfrom bool - Functions *List `json:",omitempty"` - Alias *Alias `json:",omitempty"` - Coldeflist *List `json:",omitempty"` + 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 d51e279d2b..8f2efe9b1e 100644 --- a/internal/sql/ast/range_subselect.go +++ b/internal/sql/ast/range_subselect.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeSubselect struct { Tag NodeTag[RangeSubselect] `json:"tag"` - Lateral bool - Subquery Node `json:",omitempty"` - Alias *Alias `json:",omitempty"` + 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 fa858b64ce..7758339c96 100644 --- a/internal/sql/ast/range_table_func.go +++ b/internal/sql/ast/range_table_func.go @@ -3,13 +3,13 @@ package ast type RangeTableFunc struct { Tag NodeTag[RangeTableFunc] `json:"tag"` - Lateral bool - Docexpr Node `json:",omitempty"` - Rowexpr Node `json:",omitempty"` - Namespaces *List `json:",omitempty"` - Columns *List `json:",omitempty"` - Alias *Alias `json:",omitempty"` - Location int + 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 5b23218519..d3fc620f3b 100644 --- a/internal/sql/ast/range_table_func_col.go +++ b/internal/sql/ast/range_table_func_col.go @@ -3,13 +3,13 @@ package ast type RangeTableFuncCol struct { Tag NodeTag[RangeTableFuncCol] `json:"tag"` - Colname *string `json:",omitempty"` - TypeName *TypeName `json:",omitempty"` - ForOrdinality bool - IsNotNull bool - Colexpr Node `json:",omitempty"` - Coldefexpr Node `json:",omitempty"` - Location int + 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 db9f3c9c10..cf4c41f5b8 100644 --- a/internal/sql/ast/range_table_sample.go +++ b/internal/sql/ast/range_table_sample.go @@ -3,11 +3,11 @@ package ast type RangeTableSample struct { Tag NodeTag[RangeTableSample] `json:"tag"` - Relation Node `json:",omitempty"` - Method *List `json:",omitempty"` - Args *List `json:",omitempty"` - Repeatable Node `json:",omitempty"` - Location int + 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 5fb822048e..e3dbf2b39f 100644 --- a/internal/sql/ast/range_tbl_entry.go +++ b/internal/sql/ast/range_tbl_entry.go @@ -3,37 +3,37 @@ package ast type RangeTblEntry struct { Tag NodeTag[RangeTblEntry] `json:"tag"` - Rtekind RTEKind - Relid Oid - Relkind byte - Tablesample *TableSampleClause `json:",omitempty"` - Subquery *Query `json:",omitempty"` - SecurityBarrier bool - Jointype JoinType - Joinaliasvars *List `json:",omitempty"` - Functions *List `json:",omitempty"` - Funcordinality bool - Tablefunc *TableFunc `json:",omitempty"` - ValuesLists *List `json:",omitempty"` - Ctename *string `json:",omitempty"` - Ctelevelsup Index - SelfReference bool - Coltypes *List `json:",omitempty"` - Coltypmods *List `json:",omitempty"` - Colcollations *List `json:",omitempty"` - Enrname *string `json:",omitempty"` - Enrtuples float64 - Alias *Alias `json:",omitempty"` - Eref *Alias `json:",omitempty"` - Lateral bool - Inh bool - InFromCl bool - RequiredPerms AclMode - CheckAsUser Oid - SelectedCols []uint32 `json:",omitempty"` - InsertedCols []uint32 `json:",omitempty"` - UpdatedCols []uint32 `json:",omitempty"` - SecurityQuals *List `json:",omitempty"` + 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 09412058bc..c4f54e1d55 100644 --- a/internal/sql/ast/range_tbl_function.go +++ b/internal/sql/ast/range_tbl_function.go @@ -3,13 +3,13 @@ package ast type RangeTblFunction struct { Tag NodeTag[RangeTblFunction] `json:"tag"` - Funcexpr Node `json:",omitempty"` - Funccolcount int - Funccolnames *List `json:",omitempty"` - Funccoltypes *List `json:",omitempty"` - Funccoltypmods *List `json:",omitempty"` - Funccolcollations *List `json:",omitempty"` - Funcparams []uint32 `json:",omitempty"` + 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 20951e062d..e3e1cc2a22 100644 --- a/internal/sql/ast/range_tbl_ref.go +++ b/internal/sql/ast/range_tbl_ref.go @@ -3,7 +3,7 @@ package ast type RangeTblRef struct { Tag NodeTag[RangeTblRef] `json:"tag"` - Rtindex int + 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 3359a58459..ce70c97114 100644 --- a/internal/sql/ast/range_var.go +++ b/internal/sql/ast/range_var.go @@ -5,13 +5,13 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RangeVar struct { Tag NodeTag[RangeVar] `json:"tag"` - Catalogname *string `json:",omitempty"` - Schemaname *string `json:",omitempty"` - Relname *string `json:",omitempty"` - Inh bool - Relpersistence byte - Alias *Alias `json:",omitempty"` - Location int + 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 4b7c096159..73e50d508e 100644 --- a/internal/sql/ast/raw_stmt.go +++ b/internal/sql/ast/raw_stmt.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RawStmt struct { Tag NodeTag[RawStmt] `json:"tag"` - Stmt Node `json:",omitempty"` - StmtLocation int - StmtLen int + 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 c2e903febe..d062e7826c 100644 --- a/internal/sql/ast/reassign_owned_stmt.go +++ b/internal/sql/ast/reassign_owned_stmt.go @@ -3,8 +3,8 @@ package ast type ReassignOwnedStmt struct { Tag NodeTag[ReassignOwnedStmt] `json:"tag"` - Roles *List `json:",omitempty"` - Newrole *RoleSpec `json:",omitempty"` + 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 e9d765ba4a..d8c76e55f7 100644 --- a/internal/sql/ast/refresh_mat_view_stmt.go +++ b/internal/sql/ast/refresh_mat_view_stmt.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RefreshMatViewStmt struct { Tag NodeTag[RefreshMatViewStmt] `json:"tag"` - Concurrent bool - SkipData bool - Relation *RangeVar `json:",omitempty"` + 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 10908aa29a..7261134655 100644 --- a/internal/sql/ast/reindex_stmt.go +++ b/internal/sql/ast/reindex_stmt.go @@ -3,10 +3,10 @@ package ast type ReindexStmt struct { Tag NodeTag[ReindexStmt] `json:"tag"` - Kind ReindexObjectType - Relation *RangeVar `json:",omitempty"` - Name *string `json:",omitempty"` - Options int + 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 aa36edc7e7..efaf74250c 100644 --- a/internal/sql/ast/relabel_type.go +++ b/internal/sql/ast/relabel_type.go @@ -3,13 +3,13 @@ package ast type RelabelType struct { Tag NodeTag[RelabelType] `json:"tag"` - Xpr Node `json:",omitempty"` - Arg Node `json:",omitempty"` - Resulttype Oid - Resulttypmod int32 - Resultcollid Oid - Relabelformat CoercionForm - Location int + 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 90f07c2de7..e677ce4661 100644 --- a/internal/sql/ast/rename_column_stmt.go +++ b/internal/sql/ast/rename_column_stmt.go @@ -3,10 +3,10 @@ package ast type RenameColumnStmt struct { Tag NodeTag[RenameColumnStmt] `json:"tag"` - Table *TableName `json:",omitempty"` - Col *ColumnRef `json:",omitempty"` - NewName *string `json:",omitempty"` - MissingOk bool + 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 a7854f96ba..47865132c8 100644 --- a/internal/sql/ast/rename_stmt.go +++ b/internal/sql/ast/rename_stmt.go @@ -3,14 +3,14 @@ package ast type RenameStmt struct { Tag NodeTag[RenameStmt] `json:"tag"` - RenameType ObjectType - RelationType ObjectType - Relation *RangeVar `json:",omitempty"` - Object Node `json:",omitempty"` - Subname *string `json:",omitempty"` - Newname *string `json:",omitempty"` - Behavior DropBehavior - MissingOk bool + 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 32ea76e9af..a8473e0310 100644 --- a/internal/sql/ast/rename_table_stmt.go +++ b/internal/sql/ast/rename_table_stmt.go @@ -3,9 +3,9 @@ package ast type RenameTableStmt struct { Tag NodeTag[RenameTableStmt] `json:"tag"` - Table *TableName `json:",omitempty"` - NewName *string `json:",omitempty"` - MissingOk bool + 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 1b73dbffc0..fced204dc8 100644 --- a/internal/sql/ast/rename_type_stmt.go +++ b/internal/sql/ast/rename_type_stmt.go @@ -3,8 +3,8 @@ package ast type RenameTypeStmt struct { Tag NodeTag[RenameTypeStmt] `json:"tag"` - Type *TypeName `json:",omitempty"` - NewName *string `json:",omitempty"` + 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 ab89eadf80..abe08e05e4 100644 --- a/internal/sql/ast/replica_identity_stmt.go +++ b/internal/sql/ast/replica_identity_stmt.go @@ -3,8 +3,8 @@ package ast type ReplicaIdentityStmt struct { Tag NodeTag[ReplicaIdentityStmt] `json:"tag"` - IdentityType byte - Name *string `json:",omitempty"` + 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 4e6307dec6..58a7e1dac5 100644 --- a/internal/sql/ast/res_target.go +++ b/internal/sql/ast/res_target.go @@ -5,10 +5,10 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ResTarget struct { Tag NodeTag[ResTarget] `json:"tag"` - Name *string `json:",omitempty"` - Indirection *List `json:",omitempty"` - Val Node `json:",omitempty"` - Location int + 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 9ae819c367..154ddf3ce4 100644 --- a/internal/sql/ast/role_spec.go +++ b/internal/sql/ast/role_spec.go @@ -3,9 +3,9 @@ package ast type RoleSpec struct { Tag NodeTag[RoleSpec] `json:"tag"` - Roletype RoleSpecType - Rolename *string `json:",omitempty"` - Location int + 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 44fe3506e5..bbab320eda 100644 --- a/internal/sql/ast/row_compare_expr.go +++ b/internal/sql/ast/row_compare_expr.go @@ -3,13 +3,13 @@ package ast type RowCompareExpr struct { Tag NodeTag[RowCompareExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Rctype RowCompareType - Opnos *List `json:",omitempty"` - Opfamilies *List `json:",omitempty"` - Inputcollids *List `json:",omitempty"` - Largs *List `json:",omitempty"` - Rargs *List `json:",omitempty"` + 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 1942afe671..d898086da6 100644 --- a/internal/sql/ast/row_expr.go +++ b/internal/sql/ast/row_expr.go @@ -5,12 +5,12 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type RowExpr struct { Tag NodeTag[RowExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Args *List `json:",omitempty"` - RowTypeid Oid - RowFormat CoercionForm - Colnames *List `json:",omitempty"` - Location int + 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 d57f9aea2f..121174e6ba 100644 --- a/internal/sql/ast/row_mark_clause.go +++ b/internal/sql/ast/row_mark_clause.go @@ -3,10 +3,10 @@ package ast type RowMarkClause struct { Tag NodeTag[RowMarkClause] `json:"tag"` - Rti Index - Strength LockClauseStrength - WaitPolicy LockWaitPolicy - PushedDown bool + 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 dd0143e7e3..7821866d58 100644 --- a/internal/sql/ast/rule_stmt.go +++ b/internal/sql/ast/rule_stmt.go @@ -3,13 +3,13 @@ package ast type RuleStmt struct { Tag NodeTag[RuleStmt] `json:"tag"` - Relation *RangeVar `json:",omitempty"` - Rulename *string `json:",omitempty"` - WhereClause Node `json:",omitempty"` - Event CmdType - Instead bool - Actions *List `json:",omitempty"` - Replace bool + 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 186a9f12e1..a427fd0e67 100644 --- a/internal/sql/ast/scalar_array_op_expr.go +++ b/internal/sql/ast/scalar_array_op_expr.go @@ -5,12 +5,12 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type ScalarArrayOpExpr struct { Tag NodeTag[ScalarArrayOpExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Opno Oid - UseOr bool - Inputcollid Oid - Args *List `json:",omitempty"` - Location int + 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 b3e40cb4ff..3a00bee0c4 100644 --- a/internal/sql/ast/sec_label_stmt.go +++ b/internal/sql/ast/sec_label_stmt.go @@ -3,10 +3,10 @@ package ast type SecLabelStmt struct { Tag NodeTag[SecLabelStmt] `json:"tag"` - Objtype ObjectType - Object Node `json:",omitempty"` - Provider *string `json:",omitempty"` - Label *string `json:",omitempty"` + 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 b15d6e3236..ad9e10f9a1 100644 --- a/internal/sql/ast/select_stmt.go +++ b/internal/sql/ast/select_stmt.go @@ -7,24 +7,24 @@ import ( type SelectStmt struct { Tag NodeTag[SelectStmt] `json:"tag"` - DistinctClause *List `json:",omitempty"` - IntoClause *IntoClause `json:",omitempty"` - TargetList *List `json:",omitempty"` - FromClause *List `json:",omitempty"` - WhereClause Node `json:",omitempty"` - GroupClause *List `json:",omitempty"` - HavingClause Node `json:",omitempty"` - WindowClause *List `json:",omitempty"` - ValuesLists *List `json:",omitempty"` - SortClause *List `json:",omitempty"` - LimitOffset Node `json:",omitempty"` - LimitCount Node `json:",omitempty"` - LockingClause *List `json:",omitempty"` - WithClause *WithClause `json:",omitempty"` - Op SetOperation - All bool - Larg *SelectStmt `json:",omitempty"` - Rarg *SelectStmt `json:",omitempty"` + 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 32f27184f4..975460facb 100644 --- a/internal/sql/ast/set_operation_stmt.go +++ b/internal/sql/ast/set_operation_stmt.go @@ -3,14 +3,14 @@ package ast type SetOperationStmt struct { Tag NodeTag[SetOperationStmt] `json:"tag"` - Op SetOperation - All bool - Larg Node `json:",omitempty"` - Rarg Node `json:",omitempty"` - ColTypes *List `json:",omitempty"` - ColTypmods *List `json:",omitempty"` - ColCollations *List `json:",omitempty"` - GroupClauses *List `json:",omitempty"` + 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 100dfb2293..6ae1d066c4 100644 --- a/internal/sql/ast/set_to_default.go +++ b/internal/sql/ast/set_to_default.go @@ -3,11 +3,11 @@ package ast type SetToDefault struct { Tag NodeTag[SetToDefault] `json:"tag"` - Xpr Node `json:",omitempty"` - TypeId Oid - TypeMod int32 - Collation Oid - Location int + 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 31d9cf63b6..f1e241cc54 100644 --- a/internal/sql/ast/sort_by.go +++ b/internal/sql/ast/sort_by.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type SortBy struct { Tag NodeTag[SortBy] `json:"tag"` - Node Node `json:",omitempty"` - SortbyDir SortByDir - SortbyNulls SortByNulls - UseOp *List `json:",omitempty"` - Location int + 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 47395bf690..e28cc89a8b 100644 --- a/internal/sql/ast/sort_group_clause.go +++ b/internal/sql/ast/sort_group_clause.go @@ -3,11 +3,11 @@ package ast type SortGroupClause struct { Tag NodeTag[SortGroupClause] `json:"tag"` - TleSortGroupRef Index - Eqop Oid - Sortop Oid - NullsFirst bool - Hashable bool + 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 570d25233b..4c9fd2b670 100644 --- a/internal/sql/ast/sql_value_function.go +++ b/internal/sql/ast/sql_value_function.go @@ -5,11 +5,11 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type SQLValueFunction struct { Tag NodeTag[SQLValueFunction] `json:"tag"` - Xpr Node `json:",omitempty"` - Op SQLValueFunctionOp - Type Oid - Typmod int32 - Location int + 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 c62ddb1eb1..dff54d6fb8 100644 --- a/internal/sql/ast/statement.go +++ b/internal/sql/ast/statement.go @@ -3,7 +3,7 @@ package ast type Statement struct { Tag NodeTag[Statement] `json:"tag"` - Raw *RawStmt `json:",omitempty"` + 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 9ad7fde90c..b2ebe3b211 100644 --- a/internal/sql/ast/string.go +++ b/internal/sql/ast/string.go @@ -5,7 +5,7 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type String struct { Tag NodeTag[String] `json:"tag"` - Str string + 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 7226874e43..184f36c96f 100644 --- a/internal/sql/ast/sub_link.go +++ b/internal/sql/ast/sub_link.go @@ -18,13 +18,13 @@ const ( type SubLink struct { Tag NodeTag[SubLink] `json:"tag"` - Xpr Node `json:",omitempty"` - SubLinkType SubLinkType - SubLinkId int - Testexpr Node `json:",omitempty"` - OperName *List `json:",omitempty"` - Subselect Node `json:",omitempty"` - Location int + 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 9e6eecdea4..50908c7134 100644 --- a/internal/sql/ast/sub_plan.go +++ b/internal/sql/ast/sub_plan.go @@ -3,23 +3,23 @@ package ast type SubPlan struct { Tag NodeTag[SubPlan] `json:"tag"` - Xpr Node `json:",omitempty"` - SubLinkType SubLinkType - Testexpr Node `json:",omitempty"` - ParamIds *List `json:",omitempty"` - PlanId int - PlanName *string `json:",omitempty"` - FirstColType Oid - FirstColTypmod int32 - FirstColCollation Oid - UseHashTable bool - UnknownEqFalse bool - ParallelSafe bool - SetParam *List `json:",omitempty"` - ParParam *List `json:",omitempty"` - Args *List `json:",omitempty"` - StartupCost Cost - PerCallCost Cost + 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 cd831db75e..d2a22e365e 100644 --- a/internal/sql/ast/table_func.go +++ b/internal/sql/ast/table_func.go @@ -3,19 +3,19 @@ package ast type TableFunc struct { Tag NodeTag[TableFunc] `json:"tag"` - NsUris *List `json:",omitempty"` - NsNames *List `json:",omitempty"` - Docexpr Node `json:",omitempty"` - Rowexpr Node `json:",omitempty"` - Colnames *List `json:",omitempty"` - Coltypes *List `json:",omitempty"` - Coltypmods *List `json:",omitempty"` - Colcollations *List `json:",omitempty"` - Colexprs *List `json:",omitempty"` - Coldefexprs *List `json:",omitempty"` - Notnulls []uint32 `json:",omitempty"` - Ordinalitycol int - Location int + 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 c71c1b79e2..8a5af1d5e2 100644 --- a/internal/sql/ast/table_like_clause.go +++ b/internal/sql/ast/table_like_clause.go @@ -3,8 +3,8 @@ package ast type TableLikeClause struct { Tag NodeTag[TableLikeClause] `json:"tag"` - Relation *RangeVar `json:",omitempty"` - Options uint32 + 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 399faee295..1dfe61fd4f 100644 --- a/internal/sql/ast/table_name.go +++ b/internal/sql/ast/table_name.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type TableName struct { Tag NodeTag[TableName] `json:"tag"` - Catalog string - Schema string - Name string + 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 130d3ccfad..c8d05779ea 100644 --- a/internal/sql/ast/table_sample_clause.go +++ b/internal/sql/ast/table_sample_clause.go @@ -3,9 +3,9 @@ package ast type TableSampleClause struct { Tag NodeTag[TableSampleClause] `json:"tag"` - Tsmhandler Oid - Args *List `json:",omitempty"` - Repeatable Node `json:",omitempty"` + 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 3f7247e1d5..eeb5a33d00 100644 --- a/internal/sql/ast/target_entry.go +++ b/internal/sql/ast/target_entry.go @@ -3,14 +3,14 @@ package ast type TargetEntry struct { Tag NodeTag[TargetEntry] `json:"tag"` - Xpr Node `json:",omitempty"` - Expr Node `json:",omitempty"` - Resno AttrNumber - Resname *string `json:",omitempty"` - Ressortgroupref Index - Resorigtbl Oid - Resorigcol AttrNumber - Resjunk bool + 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/transaction_stmt.go b/internal/sql/ast/transaction_stmt.go index 515adb8172..60dbe32e0d 100644 --- a/internal/sql/ast/transaction_stmt.go +++ b/internal/sql/ast/transaction_stmt.go @@ -3,9 +3,9 @@ package ast type TransactionStmt struct { Tag NodeTag[TransactionStmt] `json:"tag"` - Kind TransactionStmtKind - Options *List `json:",omitempty"` - Gid *string `json:",omitempty"` + 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 d13650f948..1d09a9547d 100644 --- a/internal/sql/ast/trigger_transition.go +++ b/internal/sql/ast/trigger_transition.go @@ -3,9 +3,9 @@ package ast type TriggerTransition struct { Tag NodeTag[TriggerTransition] `json:"tag"` - Name *string `json:",omitempty"` - IsNew bool - IsTable bool + 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 11d4662da9..9a7a21dee1 100644 --- a/internal/sql/ast/truncate_stmt.go +++ b/internal/sql/ast/truncate_stmt.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type TruncateStmt struct { Tag NodeTag[TruncateStmt] `json:"tag"` - Relations *List `json:",omitempty"` - RestartSeqs bool - Behavior DropBehavior + 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 b909583b95..56c8fbb55f 100644 --- a/internal/sql/ast/type_cast.go +++ b/internal/sql/ast/type_cast.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeCast struct { Tag NodeTag[TypeCast] `json:"tag"` - Arg Node `json:",omitempty"` - TypeName *TypeName `json:",omitempty"` - Location int + 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 4ba26dd196..9a557707b8 100644 --- a/internal/sql/ast/type_name.go +++ b/internal/sql/ast/type_name.go @@ -5,24 +5,24 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type TypeName struct { Tag NodeTag[TypeName] `json:"tag"` - Catalog string - Schema string - Name string + 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 `json:",omitempty"` - TypeOid Oid - Setof bool - PctType bool - Typmods *List `json:",omitempty"` - Typemod int32 - ArrayBounds *List `json:",omitempty"` - 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 99219c3836..8c57881ca4 100644 --- a/internal/sql/ast/unlisten_stmt.go +++ b/internal/sql/ast/unlisten_stmt.go @@ -3,7 +3,7 @@ package ast type UnlistenStmt struct { Tag NodeTag[UnlistenStmt] `json:"tag"` - Conditionname *string `json:",omitempty"` + 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 6a129631c4..dc154cfd35 100644 --- a/internal/sql/ast/update_stmt.go +++ b/internal/sql/ast/update_stmt.go @@ -9,16 +9,16 @@ import ( type UpdateStmt struct { Tag NodeTag[UpdateStmt] `json:"tag"` - Relations *List `json:",omitempty"` - TargetList *List `json:",omitempty"` - WhereClause Node `json:",omitempty"` - FromClause *List `json:",omitempty"` - LimitCount Node `json:",omitempty"` - ReturningList *List `json:",omitempty"` - WithClause *WithClause `json:",omitempty"` + 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 ecc51969d9..c04ebc6662 100644 --- a/internal/sql/ast/vacuum_stmt.go +++ b/internal/sql/ast/vacuum_stmt.go @@ -3,9 +3,9 @@ package ast type VacuumStmt struct { Tag NodeTag[VacuumStmt] `json:"tag"` - Options int - Relation *RangeVar `json:",omitempty"` - VaCols *List `json:",omitempty"` + 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 52b47ecefd..97d707f999 100644 --- a/internal/sql/ast/var.go +++ b/internal/sql/ast/var.go @@ -3,16 +3,16 @@ package ast type Var struct { Tag NodeTag[Var] `json:"tag"` - Xpr Node `json:",omitempty"` - Varno Index - Varattno AttrNumber - Vartype Oid - Vartypmod int32 - Varcollid Oid - Varlevelsup Index - Varnoold Index - Varoattno AttrNumber - Location int + 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 fb4b6c9faf..84026a1103 100644 --- a/internal/sql/ast/variable_expr.go +++ b/internal/sql/ast/variable_expr.go @@ -7,8 +7,8 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type VariableExpr struct { Tag NodeTag[VariableExpr] `json:"tag"` - Name string - Location int + 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 4c4760aad3..74cf712b7f 100644 --- a/internal/sql/ast/variable_set_stmt.go +++ b/internal/sql/ast/variable_set_stmt.go @@ -3,10 +3,10 @@ package ast type VariableSetStmt struct { Tag NodeTag[VariableSetStmt] `json:"tag"` - Kind VariableSetKind - Name *string `json:",omitempty"` - Args *List `json:",omitempty"` - IsLocal bool + 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 edbddd566b..e697115229 100644 --- a/internal/sql/ast/variable_show_stmt.go +++ b/internal/sql/ast/variable_show_stmt.go @@ -3,7 +3,7 @@ package ast type VariableShowStmt struct { Tag NodeTag[VariableShowStmt] `json:"tag"` - Name *string `json:",omitempty"` + 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 1943db06ab..ec99b66730 100644 --- a/internal/sql/ast/view_stmt.go +++ b/internal/sql/ast/view_stmt.go @@ -3,12 +3,12 @@ package ast type ViewStmt struct { Tag NodeTag[ViewStmt] `json:"tag"` - View *RangeVar `json:",omitempty"` - Aliases *List `json:",omitempty"` - Query Node `json:",omitempty"` - Replace bool - Options *List `json:",omitempty"` - WithCheckOption ViewCheckOption + 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 19460c4879..6f5a826c51 100644 --- a/internal/sql/ast/window_clause.go +++ b/internal/sql/ast/window_clause.go @@ -3,15 +3,15 @@ package ast type WindowClause struct { Tag NodeTag[WindowClause] `json:"tag"` - Name *string `json:",omitempty"` - Refname *string `json:",omitempty"` - PartitionClause *List `json:",omitempty"` - OrderClause *List `json:",omitempty"` - FrameOptions int - StartOffset Node `json:",omitempty"` - EndOffset Node `json:",omitempty"` - Winref Index - CopiedOrder bool + 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 6da3590776..7a04800353 100644 --- a/internal/sql/ast/window_def.go +++ b/internal/sql/ast/window_def.go @@ -5,14 +5,14 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type WindowDef struct { Tag NodeTag[WindowDef] `json:"tag"` - Name *string `json:",omitempty"` - Refname *string `json:",omitempty"` - PartitionClause *List `json:",omitempty"` - OrderClause *List `json:",omitempty"` - FrameOptions int - StartOffset Node `json:",omitempty"` - EndOffset Node `json:",omitempty"` - Location int + 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 6ff42c1a91..4202b48f79 100644 --- a/internal/sql/ast/window_func.go +++ b/internal/sql/ast/window_func.go @@ -3,17 +3,17 @@ package ast type WindowFunc struct { Tag NodeTag[WindowFunc] `json:"tag"` - Xpr Node `json:",omitempty"` - Winfnoid Oid - Wintype Oid - Wincollid Oid - Inputcollid Oid - Args *List `json:",omitempty"` - Aggfilter Node `json:",omitempty"` - Winref Index - Winstar bool - Winagg bool - Location int + 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 b7b085dc89..416c92d0e7 100644 --- a/internal/sql/ast/with_check_option.go +++ b/internal/sql/ast/with_check_option.go @@ -3,11 +3,11 @@ package ast type WithCheckOption struct { Tag NodeTag[WithCheckOption] `json:"tag"` - Kind WCOKind - Relname *string `json:",omitempty"` - Polname *string `json:",omitempty"` - Qual Node `json:",omitempty"` - Cascaded bool + 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 a9fd02c448..0124661b59 100644 --- a/internal/sql/ast/with_clause.go +++ b/internal/sql/ast/with_clause.go @@ -5,9 +5,9 @@ import "github.com/sqlc-dev/sqlc/internal/sql/format" type WithClause struct { Tag NodeTag[WithClause] `json:"tag"` - Ctes *List `json:",omitempty"` - Recursive bool - Location int + 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 0f3fd0f67d..42497118a9 100644 --- a/internal/sql/ast/xml_expr.go +++ b/internal/sql/ast/xml_expr.go @@ -3,16 +3,16 @@ package ast type XmlExpr struct { Tag NodeTag[XmlExpr] `json:"tag"` - Xpr Node `json:",omitempty"` - Op XmlExprOp - Name *string `json:",omitempty"` - NamedArgs *List `json:",omitempty"` - ArgNames *List `json:",omitempty"` - Args *List `json:",omitempty"` - Xmloption XmlOptionType - Type Oid - Typmod int32 - Location int + 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 08df728a78..e514db5480 100644 --- a/internal/sql/ast/xml_serialize.go +++ b/internal/sql/ast/xml_serialize.go @@ -3,10 +3,10 @@ package ast type XmlSerialize struct { Tag NodeTag[XmlSerialize] `json:"tag"` - Xmloption XmlOptionType - Expr Node `json:",omitempty"` - TypeName *TypeName `json:",omitempty"` - Location int + Xmloption XmlOptionType `json:"xmloption"` + Expr Node `json:"expr,omitempty"` + TypeName *TypeName `json:"type_name,omitempty"` + Location int `json:"location"` } func (n *XmlSerialize) Pos() int { From 31e5cfcbf623c1861ec7d2c33052f3b948a97cb6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Aug 2026 04:39:55 +0000 Subject: [PATCH 4/4] ast: remove the node tag guard test The source-level test checked that every node struct declares the Tag marker with the right type parameter. Drop it: the end-to-end goldens pin the output that matters, and the declarations are one convention, not behavior. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01T9LCt1mwdY3mE14x3Zz5Vw --- internal/sql/ast/node_tag.go | 3 +- internal/sql/ast/node_tag_test.go | 92 ------------------------------- 2 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 internal/sql/ast/node_tag_test.go diff --git a/internal/sql/ast/node_tag.go b/internal/sql/ast/node_tag.go index 55355892a6..5b3f43b90a 100644 --- a/internal/sql/ast/node_tag.go +++ b/internal/sql/ast/node_tag.go @@ -18,8 +18,7 @@ import ( // 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. A test checks -// that every node declares the field and that its type parameter matches. +// parameter carries the node's identity to it at compile time. type NodeTag[T any] struct{} func (NodeTag[T]) MarshalJSON() ([]byte, error) { diff --git a/internal/sql/ast/node_tag_test.go b/internal/sql/ast/node_tag_test.go deleted file mode 100644 index a36fd071d0..0000000000 --- a/internal/sql/ast/node_tag_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package ast - -import ( - "go/ast" - "go/parser" - "go/token" - "strings" - "testing" -) - -// TestNodeTagFields guards the JSON encoding: every node struct must declare -// Tag NodeTag[T] as its first field with T naming the struct itself, and no -// node may declare another field that collides with the "tag" key. Nothing in -// the language enforces either — the field is copy-pasted between node files, -// so its type parameter can silently name the wrong node, and encoding/json -// matches field names case-insensitively on decode, so a second field named -// Tag would capture the tag string. -// -// This is a unit test because the invariant is about the declarations in this -// package, not about anything sqlc produces. No SQL input can exercise a node -// that has not been written yet, so the end-to-end tests cannot catch the day -// someone adds one without the field. -func TestNodeTagFields(t *testing.T) { - fset := token.NewFileSet() - pkgs, err := parser.ParseDir(fset, ".", nil, 0) - if err != nil { - t.Fatalf("parsing package: %s", err) - } - pkg := pkgs["ast"] - - // The node set: struct types with their own pointer-receiver Pos method. - nodes := map[string]bool{} - for _, file := range pkg.Files { - for _, decl := range file.Decls { - fn, ok := decl.(*ast.FuncDecl) - if !ok || fn.Name.Name != "Pos" || fn.Recv == nil { - continue - } - if star, ok := fn.Recv.List[0].Type.(*ast.StarExpr); ok { - if ident, ok := star.X.(*ast.Ident); ok { - nodes[ident.Name] = true - } - } - } - } - if len(nodes) == 0 { - t.Fatal("found no Pos methods; the test is broken") - } - - for _, file := range pkg.Files { - ast.Inspect(file, func(n ast.Node) bool { - spec, ok := n.(*ast.TypeSpec) - if !ok { - return true - } - structType, ok := spec.Type.(*ast.StructType) - if !ok || !nodes[spec.Name.Name] { - return true - } - name := spec.Name.Name - - fields := structType.Fields.List - if len(fields) == 0 || len(fields[0].Names) != 1 || fields[0].Names[0].Name != "Tag" { - t.Errorf("%s: first field must be Tag NodeTag[%s]", name, name) - return true - } - index, ok := fields[0].Type.(*ast.IndexExpr) - if !ok { - t.Errorf("%s: Tag field must have type NodeTag[%s]", name, name) - return true - } - base, _ := index.X.(*ast.Ident) - arg, _ := index.Index.(*ast.Ident) - if base == nil || base.Name != "NodeTag" || arg == nil { - t.Errorf("%s: Tag field must have type NodeTag[%s]", name, name) - return true - } - if arg.Name != name { - t.Errorf("%s: Tag field is NodeTag[%s]; its type parameter must name the containing struct", name, arg.Name) - } - - for _, field := range fields[1:] { - for _, fname := range field.Names { - if strings.EqualFold(fname.Name, "tag") { - t.Errorf("%s declares a second field %q, which collides with the tag field on JSON decode", name, fname.Name) - } - } - } - return true - }) - } -}