From 98e1170dea408c19bcbbb2215d60ebd43d7dbf10 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Fri, 7 Jan 2022 21:56:12 -0500 Subject: [PATCH] update lib-pg-query (#174) fixes #172 --- CHANGELOG.md | 7 + Cargo.lock | 213 ++- cli/Cargo.toml | 2 +- linter/src/lib.rs | 4 +- linter/src/rules/adding_field_with_default.rs | 6 +- .../rules/adding_foreign_key_constraint.rs | 6 +- linter/src/rules/adding_not_null_field.rs | 6 +- .../rules/adding_primary_key_constraint.rs | 6 +- linter/src/rules/bad_drop_database.rs | 6 +- linter/src/rules/ban_char_field.rs | 8 +- linter/src/rules/ban_drop_column.rs | 6 +- linter/src/rules/changing_column_type.rs | 6 +- .../src/rules/constraint_missing_not_valid.rs | 13 +- .../src/rules/disallow_unique_constraint.rs | 8 +- linter/src/rules/prefer_robust_stmts.rs | 6 +- linter/src/rules/prefer_text_field.rs | 10 +- linter/src/rules/renaming_column.rs | 6 +- linter/src/rules/renaming_table.rs | 6 +- .../require_concurrent_index_creation.rs | 8 +- linter/src/rules/utils.rs | 8 +- package.json | 2 +- parser/Cargo.toml | 2 +- parser/src/ast.rs | 317 ++-- parser/src/parse.rs | 28 +- ..._tests__adding_index_non_concurrently.snap | 184 +-- ...s__alter_column_default_with_function.snap | 92 +- ...er__parse__tests__alter_database_stmt.snap | 238 ++- ..._tests__alter_default_privileges_stmt.snap | 130 +- ...parser__parse__tests__alter_enum_stmt.snap | 56 +- ...arse__tests__alter_event_trigger_stmt.snap | 34 +- ...ests__alter_extension_contents_stmt-2.snap | 132 +- ..._tests__alter_extension_contents_stmt.snap | 44 +- ...se__tests__alter_foreign_data_wrapper.snap | 100 +- ...rse__tests__alter_foreign_server_stmt.snap | 100 +- ...er__parse__tests__alter_function_stmt.snap | 554 +++---- ...rse__tests__alter_object_depends_stmt.snap | 196 ++- ...er__parse__tests__alter_op_class_stmt.snap | 174 +- ...r__parse__tests__alter_op_family_stmt.snap | 1464 ++++++++--------- ...er__parse__tests__alter_operator_stmt.snap | 500 +++--- ...er__parse__tests__alter_policy_stmt-2.snap | 148 +- ...rser__parse__tests__alter_policy_stmt.snap | 60 +- ...rser__parse__tests__alter_publication.snap | 200 ++- ...er__parse__tests__alter_role_set_stmt.snap | 86 +- ...parser__parse__tests__alter_role_stmt.snap | 114 +- ...er__parse__tests__alter_sequence_stmt.snap | 80 +- ...parse__tests__alter_subscription_stmt.snap | 122 +- ...rser__parse__tests__alter_system_stmt.snap | 100 +- ...__parse__tests__alter_table_extension.snap | 66 +- ..._parse__tests__alter_table_space_stmt.snap | 38 +- ...e__tests__alter_ts_configuration_stmt.snap | 124 +- ...arse__tests__alter_ts_dictionary_stmt.snap | 98 +- ...parse__tests__alter_user_mapping_stmt.snap | 80 +- ...uawk_parser__parse__tests__checkpoint.snap | 20 +- ...rser__parse__tests__close_portal_stmt.snap | 28 +- ...wk_parser__parse__tests__cluster_stmt.snap | 124 +- ...parser__parse__tests__comment_on_stmt.snap | 104 +- ...er__parse__tests__composite_type_stmt.snap | 178 +- ...rse__tests__create_access_method_stmt.snap | 50 +- ...arser__parse__tests__create_cast_stmt.snap | 182 +- ..._parse__tests__create_conversion_stmt.snap | 66 +- ...r__parse__tests__create_database_stmt.snap | 228 ++- ...ser__parse__tests__create_domain_stmt.snap | 250 ++- ...arser__parse__tests__create_enum_stmt.snap | 78 +- ...rse__tests__create_event_trigger_stmt.snap | 50 +- ...arser__parse__tests__create_extension.snap | 28 +- ...e__tests__create_foreign_data_wrapper.snap | 28 +- ...se__tests__create_foreign_server_stmt.snap | 140 +- ...rse__tests__create_foriegn_table_stmt.snap | 636 ++++--- ...r__parse__tests__create_function_stmt.snap | 158 +- ...ests__create_index_without_index_name.snap | 88 +- ...r__parse__tests__create_op_class_stmt.snap | 1388 ++++++++-------- ...rser__parse__tests__create_plang_stmt.snap | 66 +- ...ser__parse__tests__create_policy_stmt.snap | 82 +- ...__parse__tests__create_procedure_stmt.snap | 4 +- ...parse__tests__create_publication_stmt.snap | 192 ++- ...rser__parse__tests__create_range_stmt.snap | 154 +- ...arser__parse__tests__create_role_stmt.snap | 147 +- ...r__parse__tests__create_sequence_stmt.snap | 80 +- ...rser__parse__tests__create_stats_stmt.snap | 148 +- ...arse__tests__create_subscription_stmt.snap | 62 +- ...r__parse__tests__create_table_as_stmt.snap | 129 +- ...__parse__tests__create_transform_stmt.snap | 184 +-- ...er__parse__tests__create_trigger_stmt.snap | 78 +- ...arse__tests__create_user_mapping_stmt.snap | 114 +- ...arser__parse__tests__create_view_stmt.snap | 308 ++-- ...parser__parse__tests__deallocate_stmt.snap | 20 +- ...er__parse__tests__declare_cursor_stmt.snap | 117 +- ...k_parser__parse__tests__define_stmt-2.snap | 460 +++--- ...k_parser__parse__tests__define_stmt-3.snap | 250 ++- ...awk_parser__parse__tests__define_stmt.snap | 232 +-- ...wk_parser__parse__tests__discard_stmt.snap | 84 +- .../squawk_parser__parse__tests__do_stmt.snap | 60 +- ...ser__parse__tests__drop_database_stmt.snap | 62 +- ..._parser__parse__tests__drop_extension.snap | 30 +- ...uawk_parser__parse__tests__drop_index.snap | 420 +++-- ...parser__parse__tests__drop_owned_stmt.snap | 56 +- ...ser__parse__tests__drop_role_set_stmt.snap | 50 +- ..._parse__tests__drop_subscription_stmt.snap | 34 +- ..._parse__tests__drop_user_mapping_stmt.snap | 52 +- ...wk_parser__parse__tests__execute_stmt.snap | 120 +- ...wk_parser__parse__tests__explain_stmt.snap | 307 ++-- ...uawk_parser__parse__tests__fetch_stmt.snap | 40 +- ...se__tests__import_foreign_schema_stmt.snap | 46 +- ...er__parse__tests__json_index_operator.snap | 164 +- ...awk_parser__parse__tests__listen_stmt.snap | 28 +- ...quawk_parser__parse__tests__load_stmt.snap | 28 +- ...quawk_parser__parse__tests__lock_stmt.snap | 124 +- ...quawk_parser__parse__tests__migration.snap | 246 ++- ...awk_parser__parse__tests__notify_stmt.snap | 62 +- ...se__tests__parse_alter_collation_stmt.snap | 34 +- ...ts__parse_alter_constraint_regression.snap | 180 +- ...parse__tests__parse_alter_domain_stmt.snap | 50 +- ...arse__tests__parse_create_schema_stmt.snap | 28 +- ...__tests__parse_create_table_partition.snap | 184 +-- ..._tests__parse_create_table_regression.snap | 304 ++-- ...er__parse__tests__parse_delete_stmt-2.snap | 128 +- ...rser__parse__tests__parse_delete_stmt.snap | 50 +- ...parser__parse__tests__parse_func_call.snap | 174 +- ..._parse__tests__parse_generated_column.snap | 128 ++ ...quawk_parser__parse__tests__parse_inh.snap | 186 +-- ...e__tests__parse_replica_identity_stmt.snap | 76 +- ...e__tests__parse_set_operations_stmt-2.snap | 165 +- ...rse__tests__parse_set_operations_stmt.snap | 165 +- ..._parse__tests__parse_sql_create_index.snap | 92 +- ...__parse_sql_create_index_concurrently.snap | 92 +- ...s__parse_sql_create_unique_index_safe.snap | 98 +- ...r__parse__tests__parse_sql_query_json.snap | 139 ++ ...rser__parse__tests__parsing_copy_stmt.snap | 58 +- ...r__parse__tests__parsing_create_table.snap | 1014 ++++++------ ...ests__parsing_create_table_space_stmt.snap | 34 +- ..._tests__parsing_drop_table_space_stmt.snap | 28 +- ...ser__parse__tests__parsing_grant_role.snap | 78 +- ...ser__parse__tests__parsing_grant_stmt.snap | 118 +- ...er__parse__tests__parsing_insert_stmt.snap | 147 +- ...er__parse__tests__parsing_update_stmt.snap | 164 +- ...rse__tests__parsing_variable_set_stmt.snap | 60 +- ...se__tests__parsing_variable_show_stmt.snap | 24 +- ...wk_parser__parse__tests__prepare_stmt.snap | 327 ++-- ...er__parse__tests__reassign_owned_stmt.snap | 60 +- ...se__tests__refresh_material_view_stmt.snap | 102 +- ...parse__tests__regression_update_table.snap | 142 +- ...wk_parser__parse__tests__reindex_stmt.snap | 166 +- ...quawk_parser__parse__tests__rule_stmt.snap | 221 ++- ...er__parse__tests__security_label_stmt.snap | 58 +- ...uawk_parser__parse__tests__select_one.snap | 96 +- ...__parse__tests__select_string_literal.snap | 96 +- ...parser__parse__tests__set_constraints.snap | 104 +- ...arser__parse__tests__span_with_indent.snap | 96 +- ..._tests__span_with_new_line_and_indent.snap | 96 +- ...k_parser__parse__tests__truncate_stmt.snap | 190 ++- ...k_parser__parse__tests__unlisten_stmt.snap | 28 +- ...awk_parser__parse__tests__vacuum_stmt.snap | 78 +- s/update-version | 4 +- 153 files changed, 10025 insertions(+), 10505 deletions(-) create mode 100644 parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap create mode 100644 parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index a1acaded..cb15fdcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## v0.8.2 - 2022-01-07 + +### Fixed + +- errors parsing PG12 and later query syntax by upgrading to PG13 parser (#174) +- parsing alter constraint statement (#173) + ## v0.8.1 - 2021-11-30 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 010f3752..2e3a5b3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c" dependencies = [ "addr2line", - "cfg-if", + "cfg-if 0.1.10", "libc", "miniz_oxide", "object", @@ -87,22 +87,24 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "bindgen" -version = "0.45.0" +version = "0.58.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e144fcd207ac9c7325d2c012050e7d8839634defe1a3e8d303124ed0a77c6bea" +checksum = "0f8523b410d7187a43085e7e064416ea32ded16bd0a4e6fc025e21616d01258f" dependencies = [ "bitflags", "cexpr", - "cfg-if", "clang-sys", "clap", "env_logger", "lazy_static", + "lazycell", "log", "peeking_take_while", - "proc-macro2 0.4.30", - "quote 0.6.13", + "proc-macro2", + "quote", "regex", + "rustc-hash", + "shlex", "which", ] @@ -143,9 +145,9 @@ checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368" [[package]] name = "cexpr" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" dependencies = [ "nom", ] @@ -156,6 +158,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "chrono" version = "0.4.11" @@ -169,9 +177,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "0.26.4" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" +checksum = "fa66045b9cb23c2e9c1520732030608b02ee07e5cfaa5a521ec15ded7fa24c90" dependencies = [ "glob", "libc", @@ -296,7 +304,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] [[package]] @@ -317,7 +325,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ "autocfg 1.0.0", - "cfg-if", + "cfg-if 0.1.10", "crossbeam-utils", "lazy_static", "maybe-uninit", @@ -331,7 +339,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "crossbeam-utils", "maybe-uninit", ] @@ -343,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ "autocfg 1.0.0", - "cfg-if", + "cfg-if 0.1.10", "lazy_static", ] @@ -377,14 +385,14 @@ version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] [[package]] name = "env_logger" -version = "0.6.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" dependencies = [ "atty", "humantime", @@ -399,7 +407,7 @@ version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" dependencies = [ - "version_check 0.9.2", + "version_check", ] [[package]] @@ -418,8 +426,8 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", "synstructure", ] @@ -430,7 +438,7 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "crc32fast", "libc", "miniz_oxide", @@ -501,7 +509,7 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "wasi", ] @@ -514,9 +522,9 @@ checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" [[package]] name = "glob" -version = "0.2.11" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" @@ -585,12 +593,9 @@ checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" [[package]] name = "humantime" -version = "1.3.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" @@ -734,6 +739,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.71" @@ -742,19 +753,18 @@ checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" [[package]] name = "libloading" -version = "0.5.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" dependencies = [ - "cc", + "cfg-if 1.0.0", "winapi 0.3.9", ] [[package]] name = "libpg_query-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993d317c18bca7147e2cda43f4de7848c8d570e4e67fb15b670fe19c50bd67a" +version = "0.1.3" +source = "git+https://github.com/chdsbd/libpg_query-sys?branch=chris/bump-submodule#03b96cf6b8a7df84a62e285835d9ca08a89e4af4" dependencies = [ "bindgen", "make-cmd", @@ -781,7 +791,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] [[package]] @@ -848,7 +858,7 @@ version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "fuchsia-zircon", "fuchsia-zircon-sys", "iovec", @@ -897,19 +907,19 @@ version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "winapi 0.3.9", ] [[package]] name = "nom" -version = "4.2.3" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ "memchr", - "version_check 0.1.5", + "version_check", ] [[package]] @@ -971,7 +981,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 0.1.10", "foreign-types", "lazy_static", "libc", @@ -1014,7 +1024,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "cloudabi", "libc", "redox_syscall", @@ -1071,10 +1081,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc175e9777c3116627248584e8f8b3e2987405cabe1c0adf7d1dd28f09dc7880" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1083,20 +1093,11 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cc9795ca17eb581285ec44936da7fc2335a3f34f2ddd13118b6f4d515435c50" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", "syn-mid", - "version_check 0.9.2", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", + "version_check", ] [[package]] @@ -1105,7 +1106,7 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" dependencies = [ - "unicode-xid 0.2.1", + "unicode-xid", ] [[package]] @@ -1121,28 +1122,13 @@ dependencies = [ "url 2.1.1", ] -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "proc-macro2 1.0.18", + "proc-macro2", ] [[package]] @@ -1389,6 +1375,12 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -1473,8 +1465,8 @@ version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", ] @@ -1495,8 +1487,8 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", ] @@ -1524,6 +1516,12 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + [[package]] name = "simple_asn1" version = "0.4.0" @@ -1569,7 +1567,7 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "squawk" -version = "0.8.1" +version = "0.8.2" dependencies = [ "atty", "base64 0.12.3", @@ -1651,8 +1649,8 @@ checksum = "510413f9de616762a4fbeab62509bf15c729603b72d7cd71280fbca431b1c118" dependencies = [ "heck", "proc-macro-error", - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", ] @@ -1662,9 +1660,9 @@ version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", - "unicode-xid 0.2.1", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -1673,8 +1671,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", ] @@ -1684,10 +1682,10 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", - "unicode-xid 0.2.1", + "unicode-xid", ] [[package]] @@ -1696,7 +1694,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", "rand 0.7.3", "redox_syscall", @@ -1911,7 +1909,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", ] [[package]] @@ -1920,7 +1918,7 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" dependencies = [ - "version_check 0.9.2", + "version_check", ] [[package]] @@ -1953,12 +1951,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.1" @@ -2014,12 +2006,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.2" @@ -2049,7 +2035,7 @@ version = "0.2.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "wasm-bindgen-macro", ] @@ -2062,8 +2048,8 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", "wasm-bindgen-shared", ] @@ -2074,7 +2060,7 @@ version = "0.2.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3" dependencies = [ - "quote 1.0.7", + "quote", "wasm-bindgen-macro-support", ] @@ -2084,8 +2070,8 @@ version = "0.2.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92" dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.7", + "proc-macro2", + "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -2109,11 +2095,10 @@ dependencies = [ [[package]] name = "which" -version = "2.0.1" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" dependencies = [ - "failure", "libc", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 2f162715..590936cc 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk" -version = "0.8.1" +version = "0.8.2" authors = ["Steve Dignam "] edition = "2018" license = "GPL-3.0" diff --git a/linter/src/lib.rs b/linter/src/lib.rs index c9517260..68be3da5 100644 --- a/linter/src/lib.rs +++ b/linter/src/lib.rs @@ -15,7 +15,7 @@ use crate::rules::{ require_concurrent_index_creation, }; use crate::violations::{RuleViolation, RuleViolationKind, ViolationMessage}; -use squawk_parser::ast::RootStmt; +use squawk_parser::ast::RawStmt; use squawk_parser::parse::parse_sql_query; use std::collections::HashSet; use std::convert::TryFrom; @@ -24,7 +24,7 @@ use std::convert::TryFrom; pub struct SquawkRule { pub id: String, pub name: RuleViolationKind, - func: fn(&[RootStmt]) -> Vec, + func: fn(&[RawStmt]) -> Vec, pub messages: Vec, } diff --git a/linter/src/rules/adding_field_with_default.rs b/linter/src/rules/adding_field_with_default.rs index abfbe8f7..b1edea6c 100644 --- a/linter/src/rules/adding_field_with_default.rs +++ b/linter/src/rules/adding_field_with_default.rs @@ -1,12 +1,12 @@ use crate::violations::{RuleViolation, RuleViolationKind}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, ColumnDefConstraint, ConstrType, RootStmt, Stmt, + AlterTableCmds, AlterTableDef, ColumnDefConstraint, ConstrType, RawStmt, Stmt, }; #[must_use] -pub fn adding_field_with_default(tree: &[RootStmt]) -> Vec { +pub fn adding_field_with_default(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { diff --git a/linter/src/rules/adding_foreign_key_constraint.rs b/linter/src/rules/adding_foreign_key_constraint.rs index e3c803e7..59f249a2 100644 --- a/linter/src/rules/adding_foreign_key_constraint.rs +++ b/linter/src/rules/adding_foreign_key_constraint.rs @@ -1,6 +1,6 @@ use crate::violations::{RuleViolation, RuleViolationKind}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ConstrType, RootStmt, Stmt, TableElt, + AlterTableCmds, AlterTableDef, AlterTableType, ConstrType, RawStmt, Stmt, TableElt, }; /// Adding a foreign key constraint requires a table scan and a @@ -10,9 +10,9 @@ use squawk_parser::ast::{ /// VALIDATE in another transaction will allow writes when adding the /// constraint. #[must_use] -pub fn adding_foreign_key_constraint(tree: &[RootStmt]) -> Vec { +pub fn adding_foreign_key_constraint(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::CreateStmt(stmt) => { for elt in &stmt.table_elts { diff --git a/linter/src/rules/adding_not_null_field.rs b/linter/src/rules/adding_not_null_field.rs index ecfda873..2947c517 100644 --- a/linter/src/rules/adding_not_null_field.rs +++ b/linter/src/rules/adding_not_null_field.rs @@ -1,7 +1,7 @@ use crate::violations::{RuleViolation, RuleViolationKind}; use crate::ViolationMessage; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RootStmt, Stmt, + AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RawStmt, Stmt, }; fn has_null_and_no_default_constraint(constraints: &[ColumnDefConstraint]) -> bool { @@ -19,9 +19,9 @@ fn has_null_and_no_default_constraint(constraints: &[ColumnDefConstraint]) -> bo } #[must_use] -pub fn adding_not_nullable_field(tree: &[RootStmt]) -> Vec { +pub fn adding_not_nullable_field(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { diff --git a/linter/src/rules/adding_primary_key_constraint.rs b/linter/src/rules/adding_primary_key_constraint.rs index 73ab8cc8..44526ac8 100644 --- a/linter/src/rules/adding_primary_key_constraint.rs +++ b/linter/src/rules/adding_primary_key_constraint.rs @@ -1,12 +1,12 @@ use crate::violations::{RuleViolation, RuleViolationKind}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RootStmt, Stmt, + AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RawStmt, Stmt, }; #[must_use] -pub fn adding_primary_key_constraint(tree: &[RootStmt]) -> Vec { +pub fn adding_primary_key_constraint(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { diff --git a/linter/src/rules/bad_drop_database.rs b/linter/src/rules/bad_drop_database.rs index 1a44ac04..914d6a9b 100644 --- a/linter/src/rules/bad_drop_database.rs +++ b/linter/src/rules/bad_drop_database.rs @@ -1,11 +1,11 @@ use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{RootStmt, Stmt}; +use squawk_parser::ast::{RawStmt, Stmt}; /// Brad's Rule aka ban dropping database statements. #[must_use] -pub fn ban_drop_database(tree: &[RootStmt]) -> Vec { +pub fn ban_drop_database(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::DropdbStmt(_) => { errs.push(RuleViolation::new( diff --git a/linter/src/rules/ban_char_field.rs b/linter/src/rules/ban_char_field.rs index faaab3f8..5d3874cf 100644 --- a/linter/src/rules/ban_char_field.rs +++ b/linter/src/rules/ban_char_field.rs @@ -1,15 +1,15 @@ use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{ColumnDefTypeName, QualifiedName, RootStmt, Stmt, TableElt}; +use squawk_parser::ast::{QualifiedName, RawStmt, Stmt, TableElt}; #[must_use] -pub fn ban_char_type(tree: &[RootStmt]) -> Vec { +pub fn ban_char_type(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::CreateStmt(stmt) => { for column_def in &stmt.table_elts { if let TableElt::ColumnDef(column_def) = column_def { - let ColumnDefTypeName::TypeName(type_name) = &column_def.type_name; + let type_name = &column_def.type_name; for QualifiedName::String(field_type_name) in &type_name.names { if field_type_name.str == "bpchar" { errs.push(RuleViolation::new( diff --git a/linter/src/rules/ban_drop_column.rs b/linter/src/rules/ban_drop_column.rs index 2a46dd67..2ef45946 100644 --- a/linter/src/rules/ban_drop_column.rs +++ b/linter/src/rules/ban_drop_column.rs @@ -1,10 +1,10 @@ use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{AlterTableCmds, AlterTableType, RootStmt, Stmt}; +use squawk_parser::ast::{AlterTableCmds, AlterTableType, RawStmt, Stmt}; #[must_use] -pub fn ban_drop_column(tree: &[RootStmt]) -> Vec { +pub fn ban_drop_column(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { for cmd in &stmt.cmds { diff --git a/linter/src/rules/changing_column_type.rs b/linter/src/rules/changing_column_type.rs index 458ba2ba..63189cc8 100644 --- a/linter/src/rules/changing_column_type.rs +++ b/linter/src/rules/changing_column_type.rs @@ -1,10 +1,10 @@ use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{AlterTableCmds, AlterTableType, RootStmt, Stmt}; +use squawk_parser::ast::{AlterTableCmds, AlterTableType, RawStmt, Stmt}; #[must_use] -pub fn changing_column_type(tree: &[RootStmt]) -> Vec { +pub fn changing_column_type(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { diff --git a/linter/src/rules/constraint_missing_not_valid.rs b/linter/src/rules/constraint_missing_not_valid.rs index f95a38e8..3bea462d 100644 --- a/linter/src/rules/constraint_missing_not_valid.rs +++ b/linter/src/rules/constraint_missing_not_valid.rs @@ -3,19 +3,18 @@ use std::collections::HashSet; use crate::violations::{RuleViolation, RuleViolationKind, ViolationMessage}; use crate::{rules::utils::tables_created_in_transaction, violations::Span}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, RelationKind, RootStmt, Stmt, - TransactionStmtKind, + AlterTableCmds, AlterTableDef, AlterTableType, RawStmt, Stmt, TransactionStmtKind, }; /// Return list of spans for offending transactions. From the start of BEGIN to /// the end of COMMIT. -fn not_valid_validate_in_transaction(tree: &[RootStmt]) -> Vec { +fn not_valid_validate_in_transaction(tree: &[RawStmt]) -> Vec { let mut not_valid_names = HashSet::new(); let mut in_transaction = false; let mut in_bad_index = false; let mut begin_span_start = 0; let mut bad_spans = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::TransactionStmt(stmt) => { if stmt.kind == TransactionStmtKind::Begin { @@ -65,7 +64,7 @@ fn not_valid_validate_in_transaction(tree: &[RootStmt]) -> Vec { } #[must_use] -pub fn constraint_missing_not_valid(tree: &[RootStmt]) -> Vec { +pub fn constraint_missing_not_valid(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; let tables_created = tables_created_in_transaction(tree); not_valid_validate_in_transaction(tree) @@ -79,10 +78,10 @@ pub fn constraint_missing_not_valid(tree: &[RootStmt]) -> Vec { ]), )); }); - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { - let RelationKind::RangeVar(range) = &stmt.relation; + let range = &stmt.relation; let tbl_name = &range.relname; for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { match &cmd.def { diff --git a/linter/src/rules/disallow_unique_constraint.rs b/linter/src/rules/disallow_unique_constraint.rs index 002d423c..5ac4f53b 100644 --- a/linter/src/rules/disallow_unique_constraint.rs +++ b/linter/src/rules/disallow_unique_constraint.rs @@ -1,17 +1,17 @@ use crate::rules::utils::tables_created_in_transaction; use crate::violations::{RuleViolation, RuleViolationKind}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ConstrType, RelationKind, RootStmt, Stmt, + AlterTableCmds, AlterTableDef, AlterTableType, ConstrType, RawStmt, Stmt, }; #[must_use] -pub fn disallow_unique_constraint(tree: &[RootStmt]) -> Vec { +pub fn disallow_unique_constraint(tree: &[RawStmt]) -> Vec { let tables_created = tables_created_in_transaction(tree); let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { - let RelationKind::RangeVar(range) = &stmt.relation; + let range = &stmt.relation; let tbl_name = &range.relname; for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { match (&cmd.def, &cmd.subtype) { diff --git a/linter/src/rules/prefer_robust_stmts.rs b/linter/src/rules/prefer_robust_stmts.rs index a9e5d70e..bf453fb3 100644 --- a/linter/src/rules/prefer_robust_stmts.rs +++ b/linter/src/rules/prefer_robust_stmts.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use crate::violations::{RuleViolation, RuleViolationKind}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, RootStmt, Stmt, TransactionStmtKind, + AlterTableCmds, AlterTableDef, AlterTableType, RawStmt, Stmt, TransactionStmtKind, }; #[derive(PartialEq)] enum Constraint { @@ -17,11 +17,11 @@ enum Constraint { /// more robust by using guards like `IF NOT EXISTS`. So if the migration fails /// halfway through, it can be rerun without human intervention. #[must_use] -pub fn prefer_robust_stmts(tree: &[RootStmt]) -> Vec { +pub fn prefer_robust_stmts(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; let mut inside_transaction = false; let mut constraint_names: HashMap = HashMap::new(); - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::TransactionStmt(stmt) => match stmt.kind { TransactionStmtKind::Begin => inside_transaction = true, diff --git a/linter/src/rules/prefer_text_field.rs b/linter/src/rules/prefer_text_field.rs index b0125172..2920b362 100644 --- a/linter/src/rules/prefer_text_field.rs +++ b/linter/src/rules/prefer_text_field.rs @@ -1,16 +1,16 @@ use crate::violations::{RuleViolation, RuleViolationKind}; use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDef, ColumnDefTypeName, QualifiedName, - RawStmt, RootStmt, Stmt, TableElt, + AlterTableCmds, AlterTableDef, AlterTableType, ColumnDef, QualifiedName, RawStmt, Stmt, + TableElt, }; /// It's easier to update the check constraint on a text field than a varchar() /// size since the check constraint can use NOT VALID with a separate VALIDATE /// call. #[must_use] -pub fn prefer_text_field(tree: &[RootStmt]) -> Vec { +pub fn prefer_text_field(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::CreateStmt(stmt) => { for column_def in &stmt.table_elts { @@ -35,7 +35,7 @@ pub fn prefer_text_field(tree: &[RootStmt]) -> Vec { } fn check_column_def(errs: &mut Vec, raw_stmt: &RawStmt, column_def: &ColumnDef) { - let ColumnDefTypeName::TypeName(type_name) = &column_def.type_name; + let type_name = &column_def.type_name; for QualifiedName::String(field_type_name) in &type_name.names { if field_type_name.str == "varchar" && !type_name.typmods.is_empty() { errs.push(RuleViolation::new( diff --git a/linter/src/rules/renaming_column.rs b/linter/src/rules/renaming_column.rs index 96b68421..0a6fc54f 100644 --- a/linter/src/rules/renaming_column.rs +++ b/linter/src/rules/renaming_column.rs @@ -1,10 +1,10 @@ use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{ObjectType, RootStmt, Stmt}; +use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; #[must_use] -pub fn renaming_column(tree: &[RootStmt]) -> Vec { +pub fn renaming_column(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::RenameStmt(stmt) => match stmt.rename_type { ObjectType::Column => { diff --git a/linter/src/rules/renaming_table.rs b/linter/src/rules/renaming_table.rs index d0a6a75d..c45ae93c 100644 --- a/linter/src/rules/renaming_table.rs +++ b/linter/src/rules/renaming_table.rs @@ -1,10 +1,10 @@ use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{ObjectType, RootStmt, Stmt}; +use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; #[must_use] -pub fn renaming_table(tree: &[RootStmt]) -> Vec { +pub fn renaming_table(tree: &[RawStmt]) -> Vec { let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::RenameStmt(stmt) => match stmt.rename_type { ObjectType::Table => { diff --git a/linter/src/rules/require_concurrent_index_creation.rs b/linter/src/rules/require_concurrent_index_creation.rs index bb0e59d9..cf009122 100644 --- a/linter/src/rules/require_concurrent_index_creation.rs +++ b/linter/src/rules/require_concurrent_index_creation.rs @@ -1,15 +1,15 @@ use crate::rules::utils::tables_created_in_transaction; use crate::violations::{RuleViolation, RuleViolationKind}; -use squawk_parser::ast::{ObjectType, RelationKind, RootStmt, Stmt}; +use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; #[must_use] -pub fn require_concurrent_index_creation(tree: &[RootStmt]) -> Vec { +pub fn require_concurrent_index_creation(tree: &[RawStmt]) -> Vec { let tables_created = tables_created_in_transaction(tree); let mut errs = vec![]; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::IndexStmt(stmt) => { - let RelationKind::RangeVar(range) = &stmt.relation; + let range = &stmt.relation; let tbl_name = &range.relname; if !stmt.concurrent && !tables_created.contains(tbl_name) { errs.push(RuleViolation::new( diff --git a/linter/src/rules/utils.rs b/linter/src/rules/utils.rs index 95216db3..dd4cff62 100644 --- a/linter/src/rules/utils.rs +++ b/linter/src/rules/utils.rs @@ -1,10 +1,10 @@ -use squawk_parser::ast::{RelationKind, RootStmt, Stmt, TransactionStmtKind}; +use squawk_parser::ast::{RawStmt, Stmt, TransactionStmtKind}; use std::collections::HashSet; -pub fn tables_created_in_transaction(tree: &[RootStmt]) -> HashSet { +pub fn tables_created_in_transaction(tree: &[RawStmt]) -> HashSet { let mut created_table_names = HashSet::new(); let mut inside_transaction = false; - for RootStmt::RawStmt(raw_stmt) in tree { + for raw_stmt in tree { match &raw_stmt.stmt { Stmt::TransactionStmt(stmt) => match stmt.kind { TransactionStmtKind::Begin => inside_transaction = true, @@ -12,7 +12,7 @@ pub fn tables_created_in_transaction(tree: &[RootStmt]) -> HashSet { _ => continue, }, Stmt::CreateStmt(stmt) if inside_transaction => { - let RelationKind::RangeVar(stmt) = &stmt.relation; + let stmt = &stmt.relation; let table_name = &stmt.relname; created_table_names.insert(table_name.to_owned()); } diff --git a/package.json b/package.json index 138ee3ec..03ce35be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squawk-cli", - "version": "0.8.1", + "version": "0.8.2", "description": "linter for PostgreSQL, focused on migrations", "repository": "git@github.com:sbdchd/squawk.git", "author": "Steve Dignam ", diff --git a/parser/Cargo.toml b/parser/Cargo.toml index fbb0f0c9..d0008d26 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["postgres", "sql", "parser"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libpg_query-sys = "0.1.2" +libpg_query-sys = { git = "https://github.com/chdsbd/libpg_query-sys", branch= "chris/bump-submodule" } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } serde_repr = "0.1" diff --git a/parser/src/ast.rs b/parser/src/ast.rs index a0926e60..ccba90c0 100644 --- a/parser/src/ast.rs +++ b/parser/src/ast.rs @@ -1,20 +1,28 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; -use serde_repr::{Deserialize_repr, Serialize_repr}; -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum TransactionStmtKind { + #[serde(rename = "TRANS_STMT_BEGIN")] Begin, - /// semantically identical to BEGIN + #[serde(rename = "TRANS_STMT_START")] Start, + #[serde(rename = "TRANS_STMT_COMMIT")] Commit, + #[serde(rename = "TRANS_STMT_ROLLBACK")] Rollback, + #[serde(rename = "TRANS_STMT_SAVEPOINT")] Savepoint, + #[serde(rename = "TRANS_STMT_RELEASE")] Release, + #[serde(rename = "TRANS_STMT_ROLLBACK_TO")] RollbackTo, + #[serde(rename = "TRANS_STMT_PREPARE")] Prepare, + #[serde(rename = "TRANS_STMT_COMMIT_PREPARED")] CommitPrepared, + #[serde(rename = "TRANS_STMT_ROLLBACK_PREPARED")] RollbackPrepared, } @@ -56,12 +64,16 @@ impl RawStmt { } } -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum SetOperation { + #[serde(rename = "SETOP_NONE")] None, + #[serde(rename = "SETOP_UNION")] Union, + #[serde(rename = "SETOP_INTERSECT")] Intersect, + #[serde(rename = "SETOP_EXCEPT")] Except, } @@ -155,13 +167,17 @@ pub struct SelectStmt { } /// Sort ordering options for ORDER BY and CREATE INDEX -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum SortByDir { + #[serde(rename = "SORTBY_DEFAULT")] Default, + #[serde(rename = "SORTBY_ASC")] Asc, + #[serde(rename = "SORTBY_DESC")] Desc, - /// not allowed in CREATE INDEX ... + #[serde(rename = "SORTBY_USING")] Using, } @@ -171,11 +187,14 @@ impl Default for SortByDir { } } -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum SortByNulls { + #[serde(rename = "SORTBY_NULLS_DEFAULT")] Default, + #[serde(rename = "SORTBY_NULLS_FIRST")] First, + #[serde(rename = "SORTBY_NULLS_LAST")] Last, } @@ -230,11 +249,6 @@ pub struct RangeVar { pub location: i32, } -#[derive(Debug, Deserialize, Serialize)] -pub enum RelationKind { - RangeVar(RangeVar), -} - #[derive(Debug, Deserialize, Serialize)] pub struct IndexStmt { /// name of access method (eg. btree) @@ -246,7 +260,7 @@ pub struct IndexStmt { #[serde(rename = "indexParams")] pub index_params: Vec, /// relation to build index on - pub relation: RelationKind, + pub relation: RangeVar, #[serde(default)] pub concurrent: bool, /// is index unique @@ -279,57 +293,109 @@ pub struct IndexStmt { /// When a command can act on several kinds of objects with only one /// parse structure required, use these constants to designate the /// object type. Note that commands typically don't support all the types. -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum ObjectType { + #[serde(rename = "OBJECT_ACCESS_METHOD")] AccessMethod, + #[serde(rename = "OBJECT_AGGREGATE")] Aggregate, + #[serde(rename = "OBJECT_AMOP")] Amop, + #[serde(rename = "OBJECT_AMPROC")] Amproc, - /// type's attribute, when distinct from column + #[serde(rename = "OBJECT_ATTRIBUTE")] Attribute, + #[serde(rename = "OBJECT_CAST")] Cast, + #[serde(rename = "OBJECT_COLUMN")] Column, + #[serde(rename = "OBJECT_COLLATION")] Collation, + #[serde(rename = "OBJECT_CONVERSION")] Conversion, + #[serde(rename = "OBJECT_DATABASE")] Database, + #[serde(rename = "OBJECT_DEFAULT")] Default, + #[serde(rename = "OBJECT_DEFACL")] Defacl, + #[serde(rename = "OBJECT_DOMAIN")] Domain, + #[serde(rename = "OBJECT_DOMCONSTRAINT")] Domconstraint, + #[serde(rename = "OBJECT_EVENT_TRIGGER")] EventTrigger, + #[serde(rename = "OBJECT_EXTENSION")] Extension, + #[serde(rename = "OBJECT_FDW")] Fdw, + #[serde(rename = "OBJECT_FOREIGN_SERVER")] ForeignServer, + #[serde(rename = "OBJECT_FOREIGN_TABLE")] ForeignTable, + #[serde(rename = "OBJECT_FUNCTION")] Function, + #[serde(rename = "OBJECT_INDEX")] Index, + #[serde(rename = "OBJECT_LANGUAGE")] Language, + #[serde(rename = "OBJECT_LARGEOBJECT")] Largeobject, + #[serde(rename = "OBJECT_MATVIEW")] Matview, + #[serde(rename = "OBJECT_OPCLASS")] Opclass, + #[serde(rename = "OBJECT_OPERATOR")] Operator, + #[serde(rename = "OBJECT_OPFAMILY")] Opfamily, + #[serde(rename = "OBJECT_POLICY")] Policy, + #[serde(rename = "OBJECT_PROCEDURE")] + Procedure, + #[serde(rename = "OBJECT_PUBLICATION")] Publication, + #[serde(rename = "OBJECT_PUBLICATION_REL")] PublicationRel, + #[serde(rename = "OBJECT_ROLE")] Role, + #[serde(rename = "OBJECT_ROUTINE")] + Routine, + #[serde(rename = "OBJECT_RULE")] Rule, + #[serde(rename = "OBJECT_SCHEMA")] Schema, + #[serde(rename = "OBJECT_SEQUENCE")] Sequence, + #[serde(rename = "OBJECT_SUBSCRIPTION")] Subscription, + #[serde(rename = "OBJECT_STATISTIC_EXT")] StatisticExt, - TabConstraint, + #[serde(rename = "OBJECT_TABCONSTRAINT")] + Tabconstraint, + #[serde(rename = "OBJECT_TABLE")] Table, + #[serde(rename = "OBJECT_TABLESPACE")] Tablespace, + #[serde(rename = "OBJECT_TRANSFORM")] Transform, + #[serde(rename = "OBJECT_TRIGGER")] Trigger, - TsConfiguration, - TsDictionary, - TsParser, - TsTemplate, + #[serde(rename = "OBJECT_TSCONFIGURATION")] + Tsconfiguration, + #[serde(rename = "OBJECT_TSDICTIONARY")] + Tsdictionary, + #[serde(rename = "OBJECT_TSPARSER")] + Tsparser, + #[serde(rename = "OBJECT_TSTEMPLATE")] + Tstemplate, + #[serde(rename = "OBJECT_TYPE")] Type, + #[serde(rename = "OBJECT_USER_MAPPING")] UserMapping, + #[serde(rename = "OBJECT_VIEW")] View, } @@ -347,18 +413,18 @@ pub enum AlterTableCmds { #[derive(Debug, Deserialize, Serialize)] pub struct AlterTableStmt { pub cmds: Vec, - pub relation: RelationKind, + pub relation: RangeVar, pub relkind: ObjectType, #[serde(default)] pub missing_ok: bool, } -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum DropBehavior { - /// drop fails if any dependent objects + #[serde(rename = "DROP_RESTRICT")] Restrict, - /// remove dependent objects too + #[serde(rename = "DROP_CASCADE")] DropCascade, } impl Default for DropBehavior { @@ -367,140 +433,142 @@ impl Default for DropBehavior { } } -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum AlterTableType { - /// add column + #[serde(rename = "AT_AddColumn")] AddColumn, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_AddColumnRecurse")] AddColumnRecurse, - /// implicitly via CREATE OR REPLACE VIEW + #[serde(rename = "AT_AddColumnToView")] AddColumnToView, - /// alter column default + #[serde(rename = "AT_ColumnDefault")] ColumnDefault, - /// alter column drop not null + #[serde(rename = "AT_CookedColumnDefault")] + CookedColumnDefault, + #[serde(rename = "AT_DropNotNull")] DropNotNull, - /// alter column set not null + #[serde(rename = "AT_SetNotNull")] SetNotNull, - /// alter column set statistics + #[serde(rename = "AT_DropExpression")] + DropExpression, + #[serde(rename = "AT_CheckNotNull")] + CheckNotNull, + #[serde(rename = "AT_SetStatistics")] SetStatistics, - /// alter column set ( options ) + #[serde(rename = "AT_SetOptions")] SetOptions, - /// alter column reset ( options ) + #[serde(rename = "AT_ResetOptions")] ResetOptions, - /// alter column set storage + #[serde(rename = "AT_SetStorage")] SetStorage, - /// drop column + #[serde(rename = "AT_DropColumn")] DropColumn, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_DropColumnRecurse")] DropColumnRecurse, - /// add index + #[serde(rename = "AT_AddIndex")] AddIndex, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_ReAddIndex")] ReAddIndex, - /// add constraint + #[serde(rename = "AT_AddConstraint")] AddConstraint, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_AddConstraintRecurse")] AddConstraintRecurse, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_ReAddConstraint")] ReAddConstraint, - /// alter constraint + #[serde(rename = "AT_ReAddDomainConstraint")] + ReAddDomainConstraint, + #[serde(rename = "AT_AlterConstraint")] AlterConstraint, - /// validate constraint + #[serde(rename = "AT_ValidateConstraint")] ValidateConstraint, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_ValidateConstraintRecurse")] ValidateConstraintRecurse, - /// pre-processed add constraint (local in parser/parse_utilcmd.c) - ProcessedConstraint, - /// add constraint using existing index + #[serde(rename = "AT_AddIndexConstraint")] AddIndexConstraint, - /// drop constraint + #[serde(rename = "AT_DropConstraint")] DropConstraint, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_DropConstraintRecurse")] DropConstraintRecurse, - /// internal to commands/tablecmds.c + #[serde(rename = "AT_ReAddComment")] ReAddComment, - /// alter column type + #[serde(rename = "AT_AlterColumnType")] AlterColumnType, - /// alter column OPTIONS (...) + #[serde(rename = "AT_AlterColumnGenericOptions")] AlterColumnGenericOptions, - /// change owner + #[serde(rename = "AT_ChangeOwner")] ChangeOwner, - /// CLUSTER ON + #[serde(rename = "AT_ClusterOn")] ClusterOn, - /// SET WITHOUT CLUSTER + #[serde(rename = "AT_DropCluster")] DropCluster, - /// SET LOGGED + #[serde(rename = "AT_SetLogged")] SetLogged, - /// SET UNLOGGED + #[serde(rename = "AT_SetUnLogged")] SetUnLogged, - /// SET WITH OIDS - AddOids, - /// internal to commands/tablecmds.c - AddOidsRecurse, - /// SET WITHOUT OIDS + #[serde(rename = "AT_DropOids")] DropOids, - /// SET TABLESPACE + #[serde(rename = "AT_SetTableSpace")] SetTableSpace, - /// SET (...) -- AM specific parameters + #[serde(rename = "AT_SetRelOptions")] SetRelOptions, - /// RESET (...) -- AM specific parameters + #[serde(rename = "AT_ResetRelOptions")] ResetRelOptions, - /// replace reloption list in its entirety + #[serde(rename = "AT_ReplaceRelOptions")] ReplaceRelOptions, - /// ENABLE TRIGGER name + #[serde(rename = "AT_EnableTrig")] EnableTrig, - /// ENABLE ALWAYS TRIGGER name + #[serde(rename = "AT_EnableAlwaysTrig")] EnableAlwaysTrig, - /// ENABLE REPLICA TRIGGER name + #[serde(rename = "AT_EnableReplicaTrig")] EnableReplicaTrig, - /// DISABLE TRIGGER name + #[serde(rename = "AT_DisableTrig")] DisableTrig, - /// ENABLE TRIGGER ALL + #[serde(rename = "AT_EnableTrigAll")] EnableTrigAll, - /// DISABLE TRIGGER ALL + #[serde(rename = "AT_DisableTrigAll")] DisableTrigAll, - /// ENABLE TRIGGER USER + #[serde(rename = "AT_EnableTrigUser")] EnableTrigUser, - /// DISABLE TRIGGER USER + #[serde(rename = "AT_DisableTrigUser")] DisableTrigUser, - /// ENABLE RULE name + #[serde(rename = "AT_EnableRule")] EnableRule, - /// ENABLE ALWAYS RULE name + #[serde(rename = "AT_EnableAlwaysRule")] EnableAlwaysRule, - /// ENABLE REPLICA RULE name + #[serde(rename = "AT_EnableReplicaRule")] EnableReplicaRule, - /// DISABLE RULE name + #[serde(rename = "AT_DisableRule")] DisableRule, - /// INHERIT parent + #[serde(rename = "AT_AddInherit")] AddInherit, - /// NO INHERIT parent + #[serde(rename = "AT_DropInherit")] DropInherit, - /// OF + #[serde(rename = "AT_AddOf")] AddOf, - /// NOT OF + #[serde(rename = "AT_DropOf")] DropOf, - /// REPLICA IDENTITY + #[serde(rename = "AT_ReplicaIdentity")] ReplicaIdentity, - /// ENABLE ROW SECURITY + #[serde(rename = "AT_EnableRowSecurity")] EnableRowSecurity, - /// DISABLE ROW SECURITY + #[serde(rename = "AT_DisableRowSecurity")] DisableRowSecurity, - /// FORCE ROW SECURITY + #[serde(rename = "AT_ForceRowSecurity")] ForceRowSecurity, - /// NO FORCE ROW SECURITY + #[serde(rename = "AT_NoForceRowSecurity")] NoForceRowSecurity, - /// OPTIONS (...) + #[serde(rename = "AT_GenericOptions")] GenericOptions, - /// ATTACH PARTITION + #[serde(rename = "AT_AttachPartition")] AttachPartition, - /// DETACH PARTITION + #[serde(rename = "AT_DetachPartition")] DetachPartition, - /// ADD IDENTITY + #[serde(rename = "AT_AddIdentity")] AddIdentity, - /// SET identity column options + #[serde(rename = "AT_SetIdentity")] SetIdentity, - /// DROP IDENTITY + #[serde(rename = "AT_DropIdentity")] DropIdentity, } @@ -557,11 +625,6 @@ pub struct TypeName { pub location: i32, } -#[derive(Debug, Deserialize, Serialize)] -pub enum ColumnDefTypeName { - TypeName(TypeName), -} - #[derive(Debug, Deserialize, Serialize)] pub struct ColumnDef { // int inhcount; /* number of times column is inherited */ @@ -580,7 +643,7 @@ pub struct ColumnDef { // List *fdwoptions; /* per-column FDW options */ pub colname: Option, #[serde(rename = "typeName")] - pub type_name: ColumnDefTypeName, + pub type_name: TypeName, #[serde(default)] pub constraints: Vec, /// column has local (non-inherited) def'n @@ -617,23 +680,38 @@ pub struct AlterTableCmd { pub missing_ok: bool, } -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +/// Source: +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum ConstrType { /// not standard SQL, but a lot of people expect it + #[serde(rename = "CONSTR_NULL")] Null, + #[serde(rename = "CONSTR_NOTNULL")] NotNull, + #[serde(rename = "CONSTR_DEFAULT")] Default, + #[serde(rename = "CONSTR_IDENTITY")] Identity, + #[serde(rename = "CONSTR_GENERATED")] + Generated, + #[serde(rename = "CONSTR_CHECK")] Check, + #[serde(rename = "CONSTR_PRIMARY")] Primary, + #[serde(rename = "CONSTR_UNIQUE")] Unique, + #[serde(rename = "CONSTR_EXCLUSION")] Exclusion, + #[serde(rename = "CONSTR_FOREIGN")] Foreign, - /// attributes for previous constraint node + #[serde(rename = "CONSTR_ATTR_DEFERRABLE")] AttrDeferrable, + /// attributes for previous constraint node + #[serde(rename = "CONSTR_ATTR_NOT_DEFERRABLE")] AttrNotDeferrable, + #[serde(rename = "CONSTR_ATTR_DEFERRED")] AttrDeferred, + #[serde(rename = "CONSTR_ATTR_IMMEDIATE")] AttrImmediate, } @@ -697,7 +775,7 @@ pub struct RenameStmt { pub newname: String, pub behavior: DropBehavior, // in case it's a table - pub relation: Option, + pub relation: Option, #[serde(rename = "relationType")] pub relation_type: ObjectType, #[serde(rename = "renameType")] @@ -714,23 +792,22 @@ pub enum TableElt { } /// What to do at commit time for temporary relations -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)] -#[repr(u8)] +#[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum OnCommitAction { - /// No ON COMMIT clause (do nothing) + #[serde(rename = "ONCOMMIT_NOOP")] Noop, - /// ON COMMIT PRESERVE ROWS (do nothing) + #[serde(rename = "ONCOMMIT_PRESERVE_ROWS")] PreserveRows, - /// ON COMMIT DELETE ROWS + #[serde(rename = "ONCOMMIT_DELETE_ROWS")] DeleteRows, - /// ON COMMIT DROP + #[serde(rename = "ONCOMMIT_DROP")] Drop, } #[derive(Debug, Deserialize, Serialize)] pub struct CreateStmt { /// relation to create - pub relation: RelationKind, + pub relation: RangeVar, /// column definitions (list of ColumnDef) #[serde(rename = "tableElts", default)] pub table_elts: Vec, @@ -772,8 +849,8 @@ pub struct DropStmt { } #[derive(Debug, Deserialize, Serialize)] -pub enum RootStmt { - RawStmt(RawStmt), +pub struct StmtRoot { + pub stmts: Vec, } /// case for each node type found in Postgres' parsenodes.h diff --git a/parser/src/parse.rs b/parser/src/parse.rs index 600a4e20..27a3e556 100644 --- a/parser/src/parse.rs +++ b/parser/src/parse.rs @@ -1,11 +1,11 @@ -use crate::ast::RootStmt; +use crate::ast::{RawStmt, StmtRoot}; use crate::error::PgQueryError; use libpg_query::{pg_query_free_parse_result, pg_query_parse}; use serde::Deserialize; use serde_json::Value; use std::ffi::{CStr, CString}; -fn parse_sql_query_base<'a, T>(query: &'a str) -> Result, PgQueryError> +fn parse_sql_query_base<'a, T>(query: &'a str) -> Result where T: Deserialize<'a>, { @@ -32,12 +32,13 @@ where output } -pub fn parse_sql_query_json(query: &str) -> Result, PgQueryError> { +pub fn parse_sql_query_json(query: &str) -> Result { parse_sql_query_base(query) } -pub fn parse_sql_query(query: &str) -> Result, PgQueryError> { - parse_sql_query_base(query) +pub fn parse_sql_query(query: &str) -> Result, PgQueryError> { + let parsed: StmtRoot = parse_sql_query_base(query)?; + Ok(parsed.stmts) } #[cfg(test)] @@ -46,6 +47,13 @@ mod tests { use insta::assert_debug_snapshot; + #[test] + fn test_parse_sql_query_json() { + let sql = r#"ALTER TABLE table_c ADD column c boolean GENERATED ALWAYS AS (p IS NOT NULL) STORED NOT NULL;"#; + let res = parse_sql_query_json(sql); + assert_debug_snapshot!(res); + } + #[test] fn test_span_with_indent() { // NOTE: the span information for these starts at 0 even though the SQL @@ -1244,6 +1252,16 @@ ALTER TABLE "table" ALTER CONSTRAINT "constraint" NOT DEFERRABLE; assert_debug_snapshot!(res); } + #[test] + fn parse_generated_column() { + let sql = r#" +ALTER TABLE table_c ADD column c boolean GENERATED ALWAYS AS (p IS NOT NULL) STORED NOT NULL; +"#; + let res = parse_sql_query(sql); + assert!(res.is_ok()); + assert_debug_snapshot!(res); + } + #[test] fn test_parse_create_table_regression() { let sql = r#" diff --git a/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap b/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap index 84e3d93f..83dd1dff 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap @@ -4,107 +4,99 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "field_name_idx", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "field_name", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 52, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "field_name_idx", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "field_name", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: false, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 52, }, - ), - stmt_location: 0, - stmt_len: Some( - 79, - ), - }, - ), - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "field_name_idx", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "field_name", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 151, + concurrent: false, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 79, + ), + }, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "field_name_idx", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "field_name", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: true, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 151, }, - ), - stmt_location: 80, - stmt_len: Some( - 98, - ), - }, - ), + concurrent: true, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 80, + stmt_len: Some( + 98, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap index 467ae2b1..d231fa02 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap @@ -4,57 +4,53 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ColumnDefault, - name: Some( - "column_name", + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: ColumnDefault, + name: Some( + "column_name", + ), + def: Some( + SQLValueFunction( + Object({ + "location": Number( + 73, + ), + "op": String( + "SVFOP_CURRENT_TIMESTAMP", + ), + "typmod": Number( + -1, + ), + }), ), - def: Some( - SQLValueFunction( - Object({ - "location": Number( - 73, - ), - "op": Number( - 3, - ), - "typmod": Number( - -1, - ), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 21, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 21, }, - ), - stmt_location: 0, - stmt_len: Some( - 90, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 90, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap index 48bad1f0..73140ae9 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap @@ -4,144 +4,128 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "new_name", - behavior: Restrict, - relation: None, - relation_type: AccessMethod, - rename_type: Database, - subname: Some( - "name", + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "new_name", + behavior: Restrict, + relation: None, + relation_type: AccessMethod, + rename_type: Database, + subname: Some( + "name", + ), + }, + ), + stmt_location: 0, + stmt_len: Some( + 39, + ), + }, + RawStmt { + stmt: AlterOwnerStmt( + Object({ + "newowner": Object({ + "location": Number( + 70, ), - }, - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterOwnerStmt( - Object({ - "newowner": Object({ - "RoleSpec": Object({ - "location": Number( - 70, - ), - "rolename": String( - "new_owner", - ), - "roletype": Number( - 0, - ), - }), - }), - "object": Object({ - "String": Object({ - "str": String( - "name", - ), - }), - }), - "objectType": Number( - 9, + "rolename": String( + "new_owner", ), - }), - ), - stmt_location: 40, - stmt_len: Some( - 39, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterDatabaseStmt( - Object({ - "dbname": String( - "name", + "roletype": String( + "ROLESPEC_CSTRING", ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "new_tablespace", - ), - }), + }), + "object": Object({ + "String": Object({ + "str": String( + "name", + ), + }), + }), + "objectType": String( + "OBJECT_DATABASE", + ), + }), + ), + stmt_location: 40, + stmt_len: Some( + 39, + ), + }, + RawStmt { + stmt: AlterDatabaseStmt( + Object({ + "dbname": String( + "name", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "new_tablespace", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "tablespace", - ), - "location": Number( - 116, - ), }), - }), - ]), - }), - ), - stmt_location: 80, - stmt_len: Some( - 50, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterDatabaseSetStmt( - Object({ - "dbname": String( - "name", - ), - "setstmt": Object({ - "VariableSetStmt": Object({ - "kind": Number( - 4, + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "tablespace", ), - "name": String( - "configuration_parameter", + "location": Number( + 116, ), }), }), + ]), + }), + ), + stmt_location: 80, + stmt_len: Some( + 50, + ), + }, + RawStmt { + stmt: AlterDatabaseSetStmt( + Object({ + "dbname": String( + "name", + ), + "setstmt": Object({ + "kind": String( + "VAR_RESET", + ), + "name": String( + "configuration_parameter", + ), }), - ), - stmt_location: 131, - stmt_len: Some( - 50, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterDatabaseSetStmt( - Object({ - "dbname": String( - "name", + }), + ), + stmt_location: 131, + stmt_len: Some( + 50, + ), + }, + RawStmt { + stmt: AlterDatabaseSetStmt( + Object({ + "dbname": String( + "name", + ), + "setstmt": Object({ + "kind": String( + "VAR_RESET_ALL", ), - "setstmt": Object({ - "VariableSetStmt": Object({ - "kind": Number( - 5, - ), - }), - }), }), - ), - stmt_location: 182, - stmt_len: Some( - 30, - ), - }, - ), + }), + ), + stmt_location: 182, + stmt_len: Some( + 30, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap index fefe1b4f..8db90c2e 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap @@ -4,78 +4,78 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterDefaultPrivilegesStmt( - Object({ - "action": Object({ - "GrantStmt": Object({ - "behavior": Number( - 0, - ), - "grantees": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 70, - ), - "roletype": Number( - 3, - ), - }), - }), - ]), - "is_grant": Bool( - true, - ), - "objtype": Number( - 1, - ), - "privileges": Array([ - Object({ - "AccessPriv": Object({ - "priv_name": String( - "select", - ), - }), - }), - ]), - "targtype": Number( - 2, - ), - }), - }), - "options": Array([ + RawStmt { + stmt: AlterDefaultPrivilegesStmt( + Object({ + "action": Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "grantees": Array([ Object({ - "DefElem": Object({ - "arg": Array([ - Object({ - "String": Object({ - "str": String( - "myschema", - ), - }), - }), - ]), - "defaction": Number( - 0, + "RoleSpec": Object({ + "location": Number( + 70, ), - "defname": String( - "schemas", + "roletype": String( + "ROLESPEC_PUBLIC", ), - "location": Number( - 25, + }), + }), + ]), + "is_grant": Bool( + true, + ), + "objtype": String( + "OBJECT_TABLE", + ), + "privileges": Array([ + Object({ + "AccessPriv": Object({ + "priv_name": String( + "select", ), }), }), ]), + "targtype": String( + "ACL_TARGET_DEFAULTS", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 76, - ), - }, - ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "myschema", + ), + }), + }), + ]), + }), + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "schemas", + ), + "location": Number( + 25, + ), + }), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 76, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap index b5bc75b7..fb514a81 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap @@ -4,35 +4,33 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterEnumStmt( - Object({ - "newVal": String( - "orange", - ), - "newValIsAfter": Bool( - true, - ), - "newValNeighbor": String( - "red", - ), - "typeName": Array([ - Object({ - "String": Object({ - "str": String( - "colors", - ), - }), + RawStmt { + stmt: AlterEnumStmt( + Object({ + "newVal": String( + "orange", + ), + "newValIsAfter": Bool( + true, + ), + "newValNeighbor": String( + "red", + ), + "typeName": Array([ + Object({ + "String": Object({ + "str": String( + "colors", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 49, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap index d71be137..7641d1cf 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap @@ -4,23 +4,21 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterEventTrigStmt( - Object({ - "tgenabled": String( - "D", - ), - "trigname": String( - "name", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ), + RawStmt { + stmt: AlterEventTrigStmt( + Object({ + "tgenabled": String( + "D", + ), + "trigname": String( + "name", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 33, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap index efd48de4..42bcfd31 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap @@ -4,79 +4,77 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterExtensionContentsStmt( - Object({ - "action": Number( - 1, - ), - "extname": String( - "hstore", - ), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 52, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "anyelement", - ), - }), + RawStmt { + stmt: AlterExtensionContentsStmt( + Object({ + "action": Number( + 1, + ), + "extname": String( + "hstore", + ), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 52, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "anyelement", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "TypeName": Object({ - "location": Number( - 64, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "hstore", - ), - }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 64, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "hstore", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "populate_record", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "populate_record", + ), }), - ]), - }), + }), + ]), }), - "objtype": Number( - 19, - ), }), - ), - stmt_location: 0, - stmt_len: Some( - 71, - ), - }, - ), + "objtype": String( + "OBJECT_FUNCTION", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 71, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap index 740ddfc3..20e6fbfa 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap @@ -4,30 +4,28 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterObjectSchemaStmt( - Object({ - "newschema": String( - "utils", - ), - "object": Object({ - "String": Object({ - "str": String( - "hstore", - ), - }), + RawStmt { + stmt: AlterObjectSchemaStmt( + Object({ + "newschema": String( + "utils", + ), + "object": Object({ + "String": Object({ + "str": String( + "hstore", + ), }), - "objectType": Number( - 15, - ), }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ), + "objectType": String( + "OBJECT_EXTENSION", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 39, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap index 9b4e0c90..95cbe54b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap @@ -4,62 +4,60 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterFdwStmt( - Object({ - "fdwname": String( - "dbi", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "1", - ), - }), + RawStmt { + stmt: AlterFdwStmt( + Object({ + "fdwname": String( + "dbi", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "1", + ), }), - "defaction": Number( - 2, - ), - "defname": String( - "foo", - ), - "location": Number( - 44, - ), }), + "defaction": String( + "DEFELEM_ADD", + ), + "defname": String( + "foo", + ), + "location": Number( + 44, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "bar", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "bar", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "drop", - ), - "location": Number( - 53, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "drop", + ), + "location": Number( + 53, + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 64, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 64, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap index 0ee46c45..3d4468c5 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap @@ -4,62 +4,60 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterForeignServerStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "foo", - ), - }), + RawStmt { + stmt: AlterForeignServerStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "foo", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "host", - ), - "location": Number( - 26, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "host", + ), + "location": Number( + 26, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "foodb", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "foodb", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "dbname", - ), - "location": Number( - 38, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "dbname", + ), + "location": Number( + 38, + ), }), - ]), - "servername": String( - "foo", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 53, - ), - }, - ), + }), + ]), + "servername": String( + "foo", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 53, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap index bcdb0f0b..b40f5726 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap @@ -4,323 +4,313 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "square_root", - behavior: Restrict, - relation: None, - relation_type: AccessMethod, - rename_type: Function, - subname: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 51, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterOwnerStmt( - Object({ - "newowner": Object({ - "RoleSpec": Object({ - "location": Number( - 91, - ), - "rolename": String( - "joe", - ), - "roletype": Number( - 0, - ), - }), - }), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 73, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "square_root", + behavior: Restrict, + relation: None, + relation_type: AccessMethod, + rename_type: Function, + subname: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 51, + ), + }, + RawStmt { + stmt: AlterOwnerStmt( + Object({ + "newowner": Object({ + "location": Number( + 91, + ), + "rolename": String( + "joe", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), + }), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 73, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "int4", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "sqrt", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "sqrt", + ), }), - ]), - }), + }), + ]), }), - "objectType": Number( - 19, - ), }), - ), - stmt_location: 52, - stmt_len: Some( - 42, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterObjectSchemaStmt( - Object({ - "newschema": String( - "maths", - ), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 116, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + "objectType": String( + "OBJECT_FUNCTION", + ), + }), + ), + stmt_location: 52, + stmt_len: Some( + 42, + ), + }, + RawStmt { + stmt: AlterObjectSchemaStmt( + Object({ + "newschema": String( + "maths", + ), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 116, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "int4", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "sqrt", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "sqrt", + ), }), - ]), - }), + }), + ]), }), - "objectType": Number( - 19, - ), }), - ), - stmt_location: 95, - stmt_len: Some( - 46, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterFunctionStmt( - Object({ - "actions": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "VariableSetStmt": Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 197, - ), - "val": Object({ - "String": Object({ - "str": String( - "admin", - ), - }), + "objectType": String( + "OBJECT_FUNCTION", + ), + }), + ), + stmt_location: 95, + stmt_len: Some( + 46, + ), + }, + RawStmt { + stmt: AlterFunctionStmt( + Object({ + "actions": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "VariableSetStmt": Object({ + "args": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 197, + ), + "val": Object({ + "String": Object({ + "str": String( + "admin", + ), }), }), }), - Object({ - "A_Const": Object({ - "location": Number( - 204, - ), - "val": Object({ - "String": Object({ - "str": String( - "pg_temp", - ), - }), + }), + Object({ + "A_Const": Object({ + "location": Number( + 204, + ), + "val": Object({ + "String": Object({ + "str": String( + "pg_temp", + ), }), }), }), - ]), - "kind": Number( - 0, - ), - "name": String( - "search_path", - ), - }), + }), + ]), + "kind": String( + "VAR_SET_VALUE", + ), + "name": String( + "search_path", + ), }), - "defaction": Number( - 0, + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "set", + ), + "location": Number( + 179, + ), + }), + }), + ]), + "func": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 173, ), - "defname": String( - "set", + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), + }), + }), + ]), + "typemod": Number( + -1, ), - "location": Number( - 179, + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "check_password", ), }), }), ]), - "func": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 173, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "check_password", - ), - }), + }), + "objtype": String( + "OBJECT_FUNCTION", + ), + }), + ), + stmt_location: 142, + stmt_len: Some( + 69, + ), + }, + RawStmt { + stmt: AlterFunctionStmt( + Object({ + "actions": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "VariableSetStmt": Object({ + "kind": String( + "VAR_RESET", + ), + "name": String( + "search_path", + ), }), - ]), + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "set", + ), + "location": Number( + 249, + ), }), }), - }), - ), - stmt_location: 142, - stmt_len: Some( - 69, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterFunctionStmt( - Object({ - "actions": Array([ + ]), + "func": Object({ + "objargs": Array([ Object({ - "DefElem": Object({ - "arg": Object({ - "VariableSetStmt": Object({ - "kind": Number( - 4, - ), - "name": String( - "search_path", - ), - }), - }), - "defaction": Number( - 0, - ), - "defname": String( - "set", - ), + "TypeName": Object({ "location": Number( - 249, + 243, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), + }), + }), + ]), + "typemod": Number( + -1, ), }), }), ]), - "func": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 243, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "check_password", - ), - }), - }), - ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "check_password", + ), + }), }), - }), + ]), }), - ), - stmt_location: 212, - stmt_len: Some( - 54, - ), - }, - ), + "objtype": String( + "OBJECT_FUNCTION", + ), + }), + ), + stmt_location: 212, + stmt_len: Some( + 54, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap index 7f29d972..7fb16b56 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap @@ -4,115 +4,113 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterObjectDependsStmt( - Object({ - "extname": Object({ - "String": Object({ - "str": String( - "extension_name", - ), - }), + RawStmt { + stmt: AlterObjectDependsStmt( + Object({ + "extname": Object({ + "String": Object({ + "str": String( + "extension_name", + ), }), - "object": Array([ - Object({ - "String": Object({ - "str": String( - "name", - ), + }), + "object": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "name", + ), + }), }), - }), - ]), - "objectType": Number( - 40, - ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 23, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), + ]), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 74, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterObjectDependsStmt( - Object({ - "extname": Object({ - "String": Object({ - "str": String( - "extension_name", - ), - }), + "objectType": String( + "OBJECT_TRIGGER", + ), + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 23, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), + }), + }), + ), + stmt_location: 0, + stmt_len: Some( + 74, + ), + }, + RawStmt { + stmt: AlterObjectDependsStmt( + Object({ + "extname": Object({ + "String": Object({ + "str": String( + "extension_name", + ), }), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 96, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + }), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 96, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "int4", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "sqrt", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "sqrt", + ), }), - ]), - }), + }), + ]), }), - "objectType": Number( - 19, - ), }), - ), - stmt_location: 75, - stmt_len: Some( - 70, - ), - }, - ), + "objectType": String( + "OBJECT_FUNCTION", + ), + }), + ), + stmt_location: 75, + stmt_len: Some( + 70, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap index 6d9e3193..fe4e3e98 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap @@ -4,98 +4,98 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "new_name", - behavior: Restrict, - relation: None, - relation_type: AccessMethod, - rename_type: Opclass, - subname: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 64, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterOwnerStmt( - Object({ - "newowner": Object({ - "RoleSpec": Object({ - "location": Number( - 124, - ), - "roletype": Number( - 1, - ), - }), - }), - "object": Array([ - Object({ - "String": Object({ - "str": String( - "index_method", - ), + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "new_name", + behavior: Restrict, + relation: None, + relation_type: AccessMethod, + rename_type: Opclass, + subname: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 64, + ), + }, + RawStmt { + stmt: AlterOwnerStmt( + Object({ + "newowner": Object({ + "location": Number( + 124, + ), + "roletype": String( + "ROLESPEC_CURRENT_USER", + ), + }), + "object": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "index_method", + ), + }), }), - }), - Object({ - "String": Object({ - "str": String( - "name", - ), + Object({ + "String": Object({ + "str": String( + "name", + ), + }), }), - }), - ]), - "objectType": Number( - 24, - ), + ]), + }), }), - ), - stmt_location: 65, - stmt_len: Some( - 71, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterObjectSchemaStmt( - Object({ - "newschema": String( - "new_schema", - ), - "object": Array([ - Object({ - "String": Object({ - "str": String( - "index_method", - ), + "objectType": String( + "OBJECT_OPCLASS", + ), + }), + ), + stmt_location: 65, + stmt_len: Some( + 71, + ), + }, + RawStmt { + stmt: AlterObjectSchemaStmt( + Object({ + "newschema": String( + "new_schema", + ), + "object": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "index_method", + ), + }), }), - }), - Object({ - "String": Object({ - "str": String( - "name", - ), + Object({ + "String": Object({ + "str": String( + "name", + ), + }), }), - }), - ]), - "objectType": Number( - 24, - ), + ]), + }), }), - ), - stmt_location: 137, - stmt_len: Some( - 71, - ), - }, - ), + "objectType": String( + "OBJECT_OPCLASS", + ), + }), + ), + stmt_location: 137, + stmt_len: Some( + 71, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap index 813b665d..3fb57fe4 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap @@ -4,787 +4,761 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterOpFamilyStmt( - Object({ - "amname": String( - "btree", - ), - "items": Array([ - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 86, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 92, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "<", - ), - }), - }), - ]), + RawStmt { + stmt: AlterOpFamilyStmt( + Object({ + "amname": String( + "btree", + ), + "items": Array([ + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 86, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 92, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 1, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "<", + ), + }), + }), + ]), }), + "number": Number( + 1, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 117, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 123, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "<=", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 117, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 2, - ), + Object({ + "TypeName": Object({ + "location": Number( + 123, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "<=", + ), + }), + }), + ]), }), + "number": Number( + 2, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 147, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 153, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "=", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 147, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 153, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 3, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "=", + ), + }), + }), + ]), }), + "number": Number( + 3, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 178, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 184, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - ">=", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 178, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 184, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + ">=", + ), + }), }), - }), - "number": Number( - 4, - ), + ]), }), + "number": Number( + 4, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 208, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 214, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - ">", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 208, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 214, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 5, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + ">", + ), + }), + }), + ]), }), + "number": Number( + 5, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 246, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 252, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "btint42cmp", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 246, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 1, - ), + Object({ + "TypeName": Object({ + "location": Number( + 252, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "btint42cmp", + ), + }), + }), + ]), }), + "number": Number( + 1, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 295, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 301, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "<", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 295, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 301, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "<", + ), + }), }), - }), - "number": Number( - 1, - ), + ]), }), + "number": Number( + 1, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 326, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 332, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "<=", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 326, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 332, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 2, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "<=", + ), + }), + }), + ]), }), + "number": Number( + 2, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 356, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 362, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "=", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 356, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 3, - ), + Object({ + "TypeName": Object({ + "location": Number( + 362, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "=", + ), + }), + }), + ]), }), + "number": Number( + 3, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 387, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 393, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - ">=", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 387, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 393, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + ">=", + ), + }), }), - }), - "number": Number( - 4, - ), + ]), }), + "number": Number( + 4, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 417, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 423, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - ">", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 417, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 423, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 5, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + ">", + ), + }), + }), + ]), }), + "number": Number( + 5, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 455, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 461, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "btint24cmp", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 455, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int2", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 1, - ), + Object({ + "TypeName": Object({ + "location": Number( + 461, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "btint24cmp", + ), + }), + }), + ]), }), + "number": Number( + 1, + ), }), - ]), - "opfamilyname": Array([ - Object({ - "String": Object({ - "str": String( - "integer_ops", - ), - }), + }), + ]), + "opfamilyname": Array([ + Object({ + "String": Object({ + "str": String( + "integer_ops", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 467, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 467, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap index 7f8dcad5..4a065696 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap @@ -4,288 +4,278 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterOwnerStmt( - Object({ - "newowner": Object({ - "RoleSpec": Object({ - "location": Number( - 41, - ), - "rolename": String( - "joe", - ), - "roletype": Number( - 0, - ), - }), - }), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 20, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 26, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "@@", - ), - }), - }), - ]), - }), - }), - "objectType": Number( - 25, + RawStmt { + stmt: AlterOwnerStmt( + Object({ + "newowner": Object({ + "location": Number( + 41, ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 44, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterObjectSchemaStmt( - Object({ - "newschema": String( - "bar", + "rolename": String( + "joe", + ), + "roletype": String( + "ROLESPEC_CSTRING", ), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 65, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), + }), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 20, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "TypeName": Object({ - "location": Number( - 71, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 26, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "@@", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "@@", + ), }), - ]), - }), + }), + ]), }), - "objectType": Number( - 25, - ), }), - ), - stmt_location: 45, - stmt_len: Some( - 46, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterOperatorStmt( - Object({ - "opername": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 112, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), + "objectType": String( + "OBJECT_OPERATOR", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 44, + ), + }, + RawStmt { + stmt: AlterObjectSchemaStmt( + Object({ + "newschema": String( + "bar", + ), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 65, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "TypeName": Object({ - "location": Number( - 119, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 71, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "&&", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "@@", + ), }), - ]), - }), + }), + ]), }), - "options": Array([ + }), + "objectType": String( + "OBJECT_OPERATOR", + ), + }), + ), + stmt_location: 45, + stmt_len: Some( + 46, + ), + }, + RawStmt { + stmt: AlterOperatorStmt( + Object({ + "opername": Object({ + "objargs": Array([ Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 142, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int_contsel", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": Number( - 0, - ), - "defname": String( - "restrict", - ), + "TypeName": Object({ "location": Number( - 131, + 112, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int4", + ), + }), + }), + ]), + "typemod": Number( + -1, ), }), }), Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 163, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int_contjoinsel", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": Number( - 0, + "TypeName": Object({ + "location": Number( + 119, ), - "defname": String( - "join", + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int4", + ), + }), + }), + ]), + "typemod": Number( + -1, ), - "location": Number( - 156, + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "&&", ), }), }), ]), }), - ), - stmt_location: 92, - stmt_len: Some( - 88, - ), - }, - ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 142, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int_contsel", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "restrict", + ), + "location": Number( + 131, + ), + }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 163, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int_contjoinsel", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "join", + ), + "location": Number( + 156, + ), + }), + }), + ]), + }), + ), + stmt_location: 92, + stmt_len: Some( + 88, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap index 6c8172ee..bf06fc57 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap @@ -4,97 +4,93 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterPolicyStmt( - Object({ - "policy_name": String( - "name", - ), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 35, - ), - "roletype": Number( - 3, - ), - }), - }), - ]), - "table": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), + RawStmt { + stmt: AlterPolicyStmt( + Object({ + "policy_name": String( + "name", + ), + "roles": Array([ + Object({ + "RoleSpec": Object({ "location": Number( - 21, - ), - "relname": String( - "table_name", + 35, ), - "relpersistence": String( - "p", + "roletype": String( + "ROLESPEC_PUBLIC", ), }), }), - "with_check": Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "account_age", - ), - }), + ]), + "table": Object({ + "inh": Bool( + true, + ), + "location": Number( + 21, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), + }), + "with_check": Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "account_age", + ), }), - ]), - "location": Number( - 54, + }), + ]), + "location": Number( + 54, + ), + }), + }), + "location": Number( + 66, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + ">", ), }), }), - "location": Number( - 66, - ), - "name": Array([ - Object({ - "String": Object({ - "str": String( - ">", + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 68, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 10, ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 68, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 10, - ), - }), - }), - }), }), }), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 71, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 71, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap index e6629680..d406047d 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap @@ -4,37 +4,33 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "new_name", - behavior: Restrict, - relation: Some( - RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 21, - }, - ), - ), - relation_type: AccessMethod, - rename_type: Policy, - subname: Some( - "name", - ), - }, - ), - stmt_location: 0, - stmt_len: Some( - 50, - ), - }, - ), + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "new_name", + behavior: Restrict, + relation: Some( + RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 21, + }, + ), + relation_type: AccessMethod, + rename_type: Policy, + subname: Some( + "name", + ), + }, + ), + stmt_location: 0, + stmt_len: Some( + 50, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap index 177358c4..2bf10dce 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap @@ -4,113 +4,107 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterPublicationStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "update, delete", - ), - }), + RawStmt { + stmt: AlterPublicationStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "update, delete", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "publish", - ), - "location": Number( - 33, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "publish", + ), + "location": Number( + 33, + ), }), - ]), - "pubname": String( - "noinsert", - ), - "tableAction": Number( - 0, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 60, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterPublicationStmt( - Object({ - "pubname": String( - "mypublication", - ), - "tableAction": Number( - 2, - ), - "tables": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 104, - ), - "relname": String( - "users", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + "pubname": String( + "noinsert", + ), + "tableAction": String( + "DEFELEM_UNSPEC", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 60, + ), + }, + RawStmt { + stmt: AlterPublicationStmt( + Object({ + "pubname": String( + "mypublication", + ), + "tableAction": String( + "DEFELEM_ADD", + ), + "tables": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 104, + ), + "relname": String( + "users", + ), + "relpersistence": String( + "p", + ), }), - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 111, - ), - "relname": String( - "departments", - ), - "relpersistence": String( - "p", - ), - }), + }), + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 111, + ), + "relname": String( + "departments", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 61, - stmt_len: Some( - 61, - ), - }, - ), - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "new_name", - behavior: Restrict, - relation: None, - relation_type: AccessMethod, - rename_type: Publication, - subname: None, - }, - ), - stmt_location: 123, - stmt_len: None, - }, - ), + }), + ]), + }), + ), + stmt_location: 61, + stmt_len: Some( + 61, + ), + }, + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "new_name", + behavior: Restrict, + relation: None, + relation_type: AccessMethod, + rename_type: Publication, + subname: None, + }, + ), + stmt_location: 123, + stmt_len: None, + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap index f71b42af..5ce29b9d 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap @@ -4,56 +4,50 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterRoleSetStmt( - Object({ - "role": Object({ - "RoleSpec": Object({ - "location": Number( - 12, - ), - "rolename": String( - "worker_bee", - ), - "roletype": Number( - 0, - ), - }), - }), - "setstmt": Object({ - "VariableSetStmt": Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 50, + RawStmt { + stmt: AlterRoleSetStmt( + Object({ + "role": Object({ + "location": Number( + 12, + ), + "rolename": String( + "worker_bee", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), + }), + "setstmt": Object({ + "args": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 50, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 100000, ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 100000, - ), - }), - }), }), }), - ]), - "kind": Number( - 0, - ), - "name": String( - "maintenance_work_mem", - ), + }), }), - }), + ]), + "kind": String( + "VAR_SET_VALUE", + ), + "name": String( + "maintenance_work_mem", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 56, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 56, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap index 1c7a45fe..b219bc3b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap @@ -4,75 +4,71 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterRoleStmt( - Object({ - "action": Number( - 1, - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + RawStmt { + stmt: AlterRoleStmt( + Object({ + "action": Number( + 1, + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "createrole", - ), - "location": Number( - 19, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "createrole", + ), + "location": Number( + 19, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "createdb", - ), - "location": Number( - 30, - ), }), - }), - ]), - "role": Object({ - "RoleSpec": Object({ - "location": Number( - 12, + "defaction": String( + "DEFELEM_UNSPEC", ), - "rolename": String( - "miriam", + "defname": String( + "createdb", ), - "roletype": Number( - 0, + "location": Number( + 30, ), }), }), + ]), + "role": Object({ + "location": Number( + 12, + ), + "rolename": String( + "miriam", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 38, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 38, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap index 1a6319d2..6cf89bfd 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap @@ -4,55 +4,51 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterSeqStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 105, - ), - }), + RawStmt { + stmt: AlterSeqStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 105, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "restart", - ), - "location": Number( - 23, - ), }), - }), - ]), - "sequence": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 16, + "defaction": String( + "DEFELEM_UNSPEC", ), - "relname": String( - "serial", + "defname": String( + "restart", ), - "relpersistence": String( - "p", + "location": Number( + 23, ), }), }), + ]), + "sequence": Object({ + "inh": Bool( + true, + ), + "location": Number( + 16, + ), + "relname": String( + "serial", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 39, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap index 03b5bef8..2d724440 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap @@ -4,72 +4,68 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterSubscriptionStmt( - Object({ - "kind": Number( - 2, - ), - "publication": Array([ - Object({ - "String": Object({ - "str": String( - "insert_only", - ), - }), + RawStmt { + stmt: AlterSubscriptionStmt( + Object({ + "kind": String( + "ALTER_SUBSCRIPTION_PUBLICATION", + ), + "publication": Array([ + Object({ + "String": Object({ + "str": String( + "insert_only", + ), }), - ]), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 53, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterSubscriptionStmt( - Object({ - "kind": Number( - 4, - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 0, - ), - }), + }), + ]), + "subname": String( + "mysub", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 53, + ), + }, + RawStmt { + stmt: AlterSubscriptionStmt( + Object({ + "kind": String( + "ALTER_SUBSCRIPTION_ENABLED", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 0, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "enabled", - ), - "location": Number( - 55, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "enabled", + ), + "location": Number( + 55, + ), }), - ]), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 54, - stmt_len: Some( - 33, - ), - }, - ), + }), + ]), + "subname": String( + "mysub", + ), + }), + ), + stmt_location: 54, + stmt_len: Some( + 33, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap index 8d9cd43f..deb7eace 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap @@ -4,65 +4,57 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterSystemStmt( - Object({ - "setstmt": Object({ - "VariableSetStmt": Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 30, + RawStmt { + stmt: AlterSystemStmt( + Object({ + "setstmt": Object({ + "args": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 30, + ), + "val": Object({ + "String": Object({ + "str": String( + "hot_standby", ), - "val": Object({ - "String": Object({ - "str": String( - "hot_standby", - ), - }), - }), }), }), - ]), - "kind": Number( - 0, - ), - "name": String( - "wal_level", - ), + }), }), - }), + ]), + "kind": String( + "VAR_SET_VALUE", + ), + "name": String( + "wal_level", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 41, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterSystemStmt( - Object({ - "setstmt": Object({ - "VariableSetStmt": Object({ - "kind": Number( - 4, - ), - "name": String( - "wal_level", - ), - }), - }), + }), + ), + stmt_location: 0, + stmt_len: Some( + 41, + ), + }, + RawStmt { + stmt: AlterSystemStmt( + Object({ + "setstmt": Object({ + "kind": String( + "VAR_RESET", + ), + "name": String( + "wal_level", + ), }), - ), - stmt_location: 42, - stmt_len: Some( - 29, - ), - }, - ), + }), + ), + stmt_location: 42, + stmt_len: Some( + 29, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap index cd9311ab..27e7cc96 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap @@ -4,42 +4,40 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterExtensionStmt( - Object({ - "extname": String( - "hstore", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "2.0", - ), - }), + RawStmt { + stmt: AlterExtensionStmt( + Object({ + "extname": String( + "hstore", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "2.0", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "new_version", - ), - "location": Number( - 30, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "new_version", + ), + "location": Number( + 30, + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 38, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 38, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap index 23a09c22..04e90c5b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap @@ -4,25 +4,23 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "fast_raid", - behavior: Restrict, - relation: None, - relation_type: AccessMethod, - rename_type: Tablespace, - subname: Some( - "index_space", - ), - }, - ), - stmt_location: 0, - stmt_len: Some( - 48, - ), - }, - ), + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "fast_raid", + behavior: Restrict, + relation: None, + relation_type: AccessMethod, + rename_type: Tablespace, + subname: Some( + "index_space", + ), + }, + ), + stmt_location: 0, + stmt_len: Some( + 48, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap index b8e94a34..f5284807 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap @@ -4,67 +4,77 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTSConfigurationStmt( - Object({ - "cfgname": Array([ - Object({ - "String": Object({ - "str": String( - "astro_en", - ), - }), + RawStmt { + stmt: AlterTSConfigurationStmt( + Object({ + "cfgname": Array([ + Object({ + "String": Object({ + "str": String( + "astro_en", + ), }), - ]), - "dicts": Array([ - Array([ - Object({ - "String": Object({ - "str": String( - "astrosyn", - ), + }), + ]), + "dicts": Array([ + Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "astrosyn", + ), + }), }), - }), - ]), - Array([ - Object({ - "String": Object({ - "str": String( - "english_ispell", - ), + ]), + }), + }), + Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "english_ispell", + ), + }), }), - }), - ]), - Array([ - Object({ - "String": Object({ - "str": String( - "english_stem", - ), + ]), + }), + }), + Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "english_stem", + ), + }), }), - }), - ]), - ]), - "kind": Number( - 0, - ), - "tokentype": Array([ - Object({ - "String": Object({ - "str": String( - "asciiword", - ), - }), + ]), + }), + }), + ]), + "kind": String( + "ALTER_TSCONFIG_ADD_MAPPING", + ), + "tokentype": Array([ + Object({ + "String": Object({ + "str": String( + "asciiword", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 115, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 115, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap index 89f657df..e2403385 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap @@ -4,60 +4,58 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTSDictionaryStmt( - Object({ - "dictname": Array([ - Object({ - "String": Object({ - "str": String( - "my_dict", - ), - }), + RawStmt { + stmt: AlterTSDictionaryStmt( + Object({ + "dictname": Array([ + Object({ + "String": Object({ + "str": String( + "my_dict", + ), }), - ]), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 52, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "newrussian", - ), - }), + }), + ]), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 52, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "newrussian", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "stopwords", - ), - "location": Number( - 40, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "stopwords", + ), + "location": Number( + 40, + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 64, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 64, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap index 49a803a8..ebbc4828 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap @@ -4,55 +4,51 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterUserMappingStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "public", - ), - }), + RawStmt { + stmt: AlterUserMappingStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "public", + ), }), - "defaction": Number( - 1, - ), - "defname": String( - "password", - ), - "location": Number( - 51, - ), }), - }), - ]), - "servername": String( - "foo", - ), - "user": Object({ - "RoleSpec": Object({ - "location": Number( - 23, + "defaction": String( + "DEFELEM_SET", ), - "rolename": String( - "bob", + "defname": String( + "password", ), - "roletype": Number( - 0, + "location": Number( + 51, ), }), }), + ]), + "servername": String( + "foo", + ), + "user": Object({ + "location": Number( + 23, + ), + "rolename": String( + "bob", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 69, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 69, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap b/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap index e76e0b9c..f5dd31f3 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap @@ -4,16 +4,14 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CheckPointStmt( - Object({}), - ), - stmt_location: 0, - stmt_len: Some( - 11, - ), - }, - ), + RawStmt { + stmt: CheckPointStmt( + Object({}), + ), + stmt_location: 0, + stmt_len: Some( + 11, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap index 5cd56a00..01d978ab 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ClosePortalStmt( - Object({ - "portalname": String( - "curs1", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 12, - ), - }, - ), + RawStmt { + stmt: ClosePortalStmt( + Object({ + "portalname": String( + "curs1", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 12, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap index 84ab135d..8063e20d 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap @@ -4,75 +4,65 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ClusterStmt( - Object({ - "indexname": String( - "employees_ind", + RawStmt { + stmt: ClusterStmt( + Object({ + "indexname": String( + "employees_ind", + ), + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 9, + ), + "relname": String( + "employees", + ), + "relpersistence": String( + "p", ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 9, - ), - "relname": String( - "employees", - ), - "relpersistence": String( - "p", - ), - }), - }), }), - ), - stmt_location: 0, - stmt_len: Some( - 38, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ClusterStmt( - Object({ - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 48, - ), - "relname": String( - "employees", - ), - "relpersistence": String( - "p", - ), - }), - }), + }), + ), + stmt_location: 0, + stmt_len: Some( + 38, + ), + }, + RawStmt { + stmt: ClusterStmt( + Object({ + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 48, + ), + "relname": String( + "employees", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 39, - stmt_len: Some( - 18, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ClusterStmt( - Object({}), - ), - stmt_location: 58, - stmt_len: Some( - 8, - ), - }, - ), + }), + ), + stmt_location: 39, + stmt_len: Some( + 18, + ), + }, + RawStmt { + stmt: ClusterStmt( + Object({}), + ), + stmt_location: 58, + stmt_len: Some( + 8, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap index c2677472..b36fc546 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap @@ -4,64 +4,62 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CommentStmt( - Object({ - "comment": String( - "Computes sample variance", - ), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 36, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + RawStmt { + stmt: CommentStmt( + Object({ + "comment": String( + "Computes sample variance", + ), + "object": Object({ + "ObjectWithArgs": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 36, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - Object({ - "String": Object({ - "str": String( - "float8", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "float8", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "my_aggregate", - ), - }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "my_aggregate", + ), }), - ]), - }), + }), + ]), }), - "objtype": Number( - 1, - ), }), - ), - stmt_location: 0, - stmt_len: Some( - 83, - ), - }, - ), + "objtype": String( + "OBJECT_AGGREGATE", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 83, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap index 2ed6f8ff..5e8c8447 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap @@ -4,110 +4,102 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CompositeTypeStmt( - Object({ - "coldeflist": Array([ - Object({ - "ColumnDef": Object({ - "colname": String( - "r", - ), - "is_local": Bool( - true, - ), + RawStmt { + stmt: CompositeTypeStmt( + Object({ + "coldeflist": Array([ + Object({ + "ColumnDef": Object({ + "colname": String( + "r", + ), + "is_local": Bool( + true, + ), + "location": Number( + 30, + ), + "typeName": Object({ "location": Number( - 30, + 38, ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 38, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), }), - }), - }), - }), - Object({ - "ColumnDef": Object({ - "colname": String( - "i", - ), - "is_local": Bool( - true, - ), - "location": Number( - 60, - ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 68, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + Object({ + "String": Object({ + "str": String( + "float8", + ), + }), }), - }), + ]), + "typemod": Number( + -1, + ), }), }), - ]), - "typevar": Object({ - "RangeVar": Object({ - "location": Number( - 13, + }), + Object({ + "ColumnDef": Object({ + "colname": String( + "i", ), - "relname": String( - "complex", + "is_local": Bool( + true, ), - "relpersistence": String( - "p", + "location": Number( + 60, ), + "typeName": Object({ + "location": Number( + 68, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), + }), + Object({ + "String": Object({ + "str": String( + "float8", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), }), + ]), + "typevar": Object({ + "location": Number( + 13, + ), + "relname": String( + "complex", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 86, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 86, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap index b5a1e7ad..0f2d80f5 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap @@ -4,32 +4,30 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateAmStmt( - Object({ - "amname": String( - "heptree", - ), - "amtype": String( - "i", - ), - "handler_name": Array([ - Object({ - "String": Object({ - "str": String( - "heptree_handler", - ), - }), + RawStmt { + stmt: CreateAmStmt( + Object({ + "amname": String( + "heptree", + ), + "amtype": String( + "i", + ), + "handler_name": Array([ + Object({ + "String": Object({ + "str": String( + "heptree_handler", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 63, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 63, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap index 56b8897a..2e1b12a2 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap @@ -4,106 +4,98 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateCastStmt( - Object({ - "context": Number( - 1, - ), - "func": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 49, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "int8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + RawStmt { + stmt: CreateCastStmt( + Object({ + "context": String( + "COERCION_ASSIGNMENT", + ), + "func": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 49, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), + Object({ + "String": Object({ + "str": String( + "int8", + ), + }), }), - }), - ]), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "sourcetype": Object({ - "TypeName": Object({ - "location": Number( - 14, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "int8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), }), - }), - "targettype": Object({ - "TypeName": Object({ - "location": Number( - 24, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + ]), + }), + "sourcetype": Object({ + "location": Number( + 14, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), }), - }), + Object({ + "String": Object({ + "str": String( + "int8", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + "targettype": Object({ + "location": Number( + 24, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 70, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 70, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap index 197ba449..a21f6f11 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap @@ -4,41 +4,39 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateConversionStmt( - Object({ - "conversion_name": Array([ - Object({ - "String": Object({ - "str": String( - "myconv", - ), - }), + RawStmt { + stmt: CreateConversionStmt( + Object({ + "conversion_name": Array([ + Object({ + "String": Object({ + "str": String( + "myconv", + ), }), - ]), - "for_encoding_name": String( - "UTF8", - ), - "func_name": Array([ - Object({ - "String": Object({ - "str": String( - "myfunc", - ), - }), + }), + ]), + "for_encoding_name": String( + "UTF8", + ), + "func_name": Array([ + Object({ + "String": Object({ + "str": String( + "myfunc", + ), }), - ]), - "to_encoding_name": String( - "LATIN1", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 60, - ), - }, - ), + }), + ]), + "to_encoding_name": String( + "LATIN1", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 60, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap index 70a0063e..af3cd297 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap @@ -4,134 +4,128 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreatedbStmt( - Object({ - "dbname": String( - "lusiadas", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 25, - ), - }, - ), - RawStmt( - RawStmt { - stmt: CreatedbStmt( - Object({ - "dbname": String( - "sales", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "salesapp", - ), - }), + RawStmt { + stmt: CreatedbStmt( + Object({ + "dbname": String( + "lusiadas", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 25, + ), + }, + RawStmt { + stmt: CreatedbStmt( + Object({ + "dbname": String( + "sales", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "salesapp", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "owner", - ), - "location": Number( - 49, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "owner", + ), + "location": Number( + 49, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "salesspace", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "salesspace", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "tablespace", - ), - "location": Number( - 64, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "tablespace", + ), + "location": Number( + 64, + ), }), - ]), - }), - ), - stmt_location: 26, - stmt_len: Some( - 59, - ), - }, - ), - RawStmt( - RawStmt { - stmt: CreatedbStmt( - Object({ - "dbname": String( - "music", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "LATIN1", - ), - }), + }), + ]), + }), + ), + stmt_location: 26, + stmt_len: Some( + 59, + ), + }, + RawStmt { + stmt: CreatedbStmt( + Object({ + "dbname": String( + "music", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "LATIN1", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "encoding", - ), - "location": Number( - 109, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "encoding", + ), + "location": Number( + 109, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "template0", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "template0", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "template", - ), - "location": Number( - 127, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "template", + ), + "location": Number( + 127, + ), }), - ]), - }), - ), - stmt_location: 86, - stmt_len: Some( - 59, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 86, + stmt_len: Some( + 59, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap index 619158dc..329cf648 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap @@ -4,170 +4,166 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateDomainStmt( - Object({ - "constraints": Array([ - Object({ - "Constraint": Object({ - "contype": Number( - 4, - ), - "initially_valid": Bool( - true, - ), - "location": Number( - 38, - ), - "raw_expr": Object({ - "BoolExpr": Object({ - "args": Array([ - Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "value", - ), - }), + RawStmt { + stmt: CreateDomainStmt( + Object({ + "constraints": Array([ + Object({ + "Constraint": Object({ + "contype": String( + "CONSTR_CHECK", + ), + "initially_valid": Bool( + true, + ), + "location": Number( + 38, + ), + "raw_expr": Object({ + "BoolExpr": Object({ + "args": Array([ + Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "value", + ), }), - ]), - "location": Number( - 48, + }), + ]), + "location": Number( + 48, + ), + }), + }), + "location": Number( + 54, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + "~", ), }), }), - "location": Number( - 54, - ), - "name": Array([ - Object({ + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 56, + ), + "val": Object({ "String": Object({ "str": String( - "~", + "^\\d{5}$", ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 56, - ), - "val": Object({ + }), + }), + }), + }), + Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ "String": Object({ "str": String( - "^\\d{5}$", + "value", ), }), }), - }), + ]), + "location": Number( + 69, + ), }), }), - }), - Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "value", - ), - }), - }), - ]), - "location": Number( - 69, + "location": Number( + 75, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + "~", ), }), }), - "location": Number( - 75, - ), - "name": Array([ - Object({ + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 77, + ), + "val": Object({ "String": Object({ "str": String( - "~", + "^\\d{5}-\\d{4}$", ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 77, - ), - "val": Object({ - "String": Object({ - "str": String( - "^\\d{5}-\\d{4}$", - ), - }), - }), - }), }), }), }), - ]), - "boolop": Number( - 1, - ), - "location": Number( - 66, - ), - }), + }), + ]), + "boolop": String( + "OR_EXPR", + ), + "location": Number( + 66, + ), }), }), }), - ]), - "domainname": Array([ + }), + ]), + "domainname": Array([ + Object({ + "String": Object({ + "str": String( + "us_postal_code", + ), + }), + }), + ]), + "typeName": Object({ + "location": Number( + 33, + ), + "names": Array([ Object({ "String": Object({ "str": String( - "us_postal_code", + "text", ), }), }), ]), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 33, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), + "typemod": Number( + -1, + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 94, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 94, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap index 786d5516..99bde134 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap @@ -4,49 +4,47 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateEnumStmt( - Object({ - "typeName": Array([ - Object({ - "String": Object({ - "str": String( - "happiness", - ), - }), + RawStmt { + stmt: CreateEnumStmt( + Object({ + "typeName": Array([ + Object({ + "String": Object({ + "str": String( + "happiness", + ), }), - ]), - "vals": Array([ - Object({ - "String": Object({ - "str": String( - "happy", - ), - }), + }), + ]), + "vals": Array([ + Object({ + "String": Object({ + "str": String( + "happy", + ), }), - Object({ - "String": Object({ - "str": String( - "very happy", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "very happy", + ), }), - Object({ - "String": Object({ - "str": String( - "ecstatic", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "ecstatic", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 66, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 66, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap index 6947c9a8..6911c100 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap @@ -4,32 +4,30 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateEventTrigStmt( - Object({ - "eventname": String( - "ddl_command_start", - ), - "funcname": Array([ - Object({ - "String": Object({ - "str": String( - "abort_any_command", - ), - }), + RawStmt { + stmt: CreateEventTrigStmt( + Object({ + "eventname": String( + "ddl_command_start", + ), + "funcname": Array([ + Object({ + "String": Object({ + "str": String( + "abort_any_command", + ), }), - ]), - "trigname": String( - "abort_ddl", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 93, - ), - }, - ), + }), + ]), + "trigname": String( + "abort_ddl", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 93, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap index 180e06b2..1a238fdb 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateExtensionStmt( - Object({ - "extname": String( - "hstore", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ), + RawStmt { + stmt: CreateExtensionStmt( + Object({ + "extname": String( + "hstore", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 23, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap index 4241b39a..de765e5c 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateFdwStmt( - Object({ - "fdwname": String( - "dummy", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ), + RawStmt { + stmt: CreateFdwStmt( + Object({ + "fdwname": String( + "dummy", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 33, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap index 86ae3801..d8627309 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap @@ -4,85 +4,83 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateForeignServerStmt( - Object({ - "fdwname": String( - "postgres_fdw", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "foo", - ), - }), + RawStmt { + stmt: CreateForeignServerStmt( + Object({ + "fdwname": String( + "postgres_fdw", + ), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "foo", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "host", - ), - "location": Number( - 66, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "host", + ), + "location": Number( + 66, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "foodb", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "foodb", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "dbname", - ), - "location": Number( - 78, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "dbname", + ), + "location": Number( + 78, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "5432", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "5432", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "port", - ), - "location": Number( - 94, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "port", + ), + "location": Number( + 94, + ), }), - ]), - "servername": String( - "myserver", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 106, - ), - }, - ), + }), + ]), + "servername": String( + "myserver", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 106, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap index 09a334a3..fa2f07e6 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap @@ -4,372 +4,354 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateForeignTableStmt( - Object({ - "base": Object({ - "CreateStmt": Object({ - "oncommit": Number( - 0, - ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), + RawStmt { + stmt: CreateForeignTableStmt( + Object({ + "base": Object({ + "oncommit": String( + "ONCOMMIT_NOOP", + ), + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 22, + ), + "relname": String( + "films", + ), + "relpersistence": String( + "p", + ), + }), + "tableElts": Array([ + Object({ + "ColumnDef": Object({ + "colname": String( + "code", + ), + "constraints": Array([ + Object({ + "Constraint": Object({ + "contype": String( + "CONSTR_NOTNULL", + ), + "location": Number( + 54, + ), + }), + }), + ]), + "is_local": Bool( + true, + ), + "location": Number( + 34, + ), + "typeName": Object({ "location": Number( - 22, - ), - "relname": String( - "films", + 46, ), - "relpersistence": String( - "p", - ), - }), - }), - "tableElts": Array([ - Object({ - "ColumnDef": Object({ - "colname": String( - "code", - ), - "constraints": Array([ - Object({ - "Constraint": Object({ - "contype": Number( - 1, - ), - "location": Number( - 54, - ), - }), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - ]), - "is_local": Bool( - true, - ), - "location": Number( - 34, - ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 46, + }), + Object({ + "String": Object({ + "str": String( + "bpchar", ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "bpchar", - ), - }), - }), - ]), - "typemod": Number( - -1, + }), + }), + ]), + "typemod": Number( + -1, + ), + "typmods": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 51, ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 51, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 5, - ), - }), - }), - }), + "val": Object({ + "Integer": Object({ + "ival": Number( + 5, + ), }), - ]), + }), }), }), - }), + ]), }), - Object({ - "ColumnDef": Object({ - "colname": String( - "title", - ), - "constraints": Array([ - Object({ - "Constraint": Object({ - "contype": Number( - 1, - ), - "location": Number( - 92, - ), - }), + }), + }), + Object({ + "ColumnDef": Object({ + "colname": String( + "title", + ), + "constraints": Array([ + Object({ + "Constraint": Object({ + "contype": String( + "CONSTR_NOTNULL", + ), + "location": Number( + 92, + ), + }), + }), + ]), + "is_local": Bool( + true, + ), + "location": Number( + 68, + ), + "typeName": Object({ + "location": Number( + 80, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - ]), - "is_local": Bool( - true, - ), - "location": Number( - 68, - ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 80, + }), + Object({ + "String": Object({ + "str": String( + "varchar", ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "varchar", - ), - }), - }), - ]), - "typemod": Number( - -1, + }), + }), + ]), + "typemod": Number( + -1, + ), + "typmods": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 88, ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 88, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 40, - ), - }), - }), - }), + "val": Object({ + "Integer": Object({ + "ival": Number( + 40, + ), }), - ]), + }), }), }), - }), + ]), }), - Object({ - "ColumnDef": Object({ - "colname": String( - "did", - ), - "constraints": Array([ - Object({ - "Constraint": Object({ - "contype": Number( - 1, - ), - "location": Number( - 126, - ), - }), + }), + }), + Object({ + "ColumnDef": Object({ + "colname": String( + "did", + ), + "constraints": Array([ + Object({ + "Constraint": Object({ + "contype": String( + "CONSTR_NOTNULL", + ), + "location": Number( + 126, + ), + }), + }), + ]), + "is_local": Bool( + true, + ), + "location": Number( + 106, + ), + "typeName": Object({ + "location": Number( + 118, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - ]), - "is_local": Bool( - true, - ), - "location": Number( - 106, - ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 118, + }), + Object({ + "String": Object({ + "str": String( + "int4", ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + }), + Object({ + "ColumnDef": Object({ + "colname": String( + "date_prod", + ), + "is_local": Bool( + true, + ), + "location": Number( + 140, + ), + "typeName": Object({ + "location": Number( + 152, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "date", ), }), }), - }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "ColumnDef": Object({ - "colname": String( - "date_prod", - ), - "is_local": Bool( - true, - ), - "location": Number( - 140, - ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 152, + }), + }), + Object({ + "ColumnDef": Object({ + "colname": String( + "kind", + ), + "is_local": Bool( + true, + ), + "location": Number( + 162, + ), + "typeName": Object({ + "location": Number( + 174, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "date", - ), - }), - }), - ]), - "typemod": Number( - -1, + }), + }), + Object({ + "String": Object({ + "str": String( + "varchar", ), }), }), - }), - }), - Object({ - "ColumnDef": Object({ - "colname": String( - "kind", - ), - "is_local": Bool( - true, - ), - "location": Number( - 162, - ), - "typeName": Object({ - "TypeName": Object({ + ]), + "typemod": Number( + -1, + ), + "typmods": Array([ + Object({ + "A_Const": Object({ "location": Number( - 174, + 182, ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + "val": Object({ + "Integer": Object({ + "ival": Number( + 10, + ), }), - Object({ - "String": Object({ - "str": String( - "varchar", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 182, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 10, - ), - }), - }), - }), - }), - ]), + }), }), }), - }), + ]), }), - Object({ - "ColumnDef": Object({ - "colname": String( - "len", - ), - "is_local": Bool( - true, - ), - "location": Number( - 191, - ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - 203, + }), + }), + Object({ + "ColumnDef": Object({ + "colname": String( + "len", + ), + "is_local": Bool( + true, + ), + "location": Number( + 191, + ), + "typeName": Object({ + "location": Number( + 203, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "interval", - ), - }), - }), - ]), - "typemod": Number( - -1, + }), + }), + Object({ + "String": Object({ + "str": String( + "interval", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + "typmods": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 212, ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 212, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 3072, - ), - }), - }), - }), + "val": Object({ + "Integer": Object({ + "ival": Number( + 3072, + ), }), - ]), + }), }), }), - }), + ]), }), - ]), + }), }), - }), - "servername": String( - "film_server", - ), + ]), }), - ), - stmt_location: 0, - stmt_len: Some( - 247, - ), - }, - ), + "servername": String( + "film_server", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 247, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap index 8d1860d4..aa6c065f 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap @@ -4,96 +4,96 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateFunctionStmt( - Object({ - "funcname": Array([ - Object({ - "String": Object({ - "str": String( - "populate", - ), + RawStmt { + stmt: CreateFunctionStmt( + Object({ + "funcname": Array([ + Object({ + "String": Object({ + "str": String( + "populate", + ), + }), + }), + ]), + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "\nDECLARE\n -- declarations\nBEGIN\n PERFORM my_function();\nEND;\n", + ), + }), + }), + ]), + }), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "as", + ), + "location": Number( + 44, + ), }), - ]), - "options": Array([ + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "plpgsql", + ), + }), + }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "language", + ), + "location": Number( + 119, + ), + }), + }), + ]), + "returnType": Object({ + "location": Number( + 36, + ), + "names": Array([ Object({ - "DefElem": Object({ - "arg": Array([ - Object({ - "String": Object({ - "str": String( - "\nDECLARE\n -- declarations\nBEGIN\n PERFORM my_function();\nEND;\n", - ), - }), - }), - ]), - "defaction": Number( - 0, - ), - "defname": String( - "as", - ), - "location": Number( - 44, + "String": Object({ + "str": String( + "pg_catalog", ), }), }), Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "plpgsql", - ), - }), - }), - "defaction": Number( - 0, - ), - "defname": String( - "language", - ), - "location": Number( - 119, + "String": Object({ + "str": String( + "int4", ), }), }), ]), - "returnType": Object({ - "TypeName": Object({ - "location": Number( - 36, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), + "typemod": Number( + -1, + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 135, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 135, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap index 199229d5..239231e0 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap @@ -4,54 +4,50 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: None, - index_params: [ - IndexElem( - IndexElem { - name: Some( - "bar", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "foo", - inh: true, - relpersistence: "p", - alias: None, - location: 16, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: None, + index_params: [ + IndexElem( + IndexElem { + name: Some( + "bar", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: false, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "foo", + inh: true, + relpersistence: "p", + alias: None, + location: 16, }, - ), - stmt_location: 0, - stmt_len: Some( - 24, - ), - }, - ), + concurrent: false, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 24, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap index e15dc99f..e8676106 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap @@ -4,753 +4,725 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateOpClassStmt( - Object({ - "amname": String( - "gist", + RawStmt { + stmt: CreateOpClassStmt( + Object({ + "amname": String( + "gist", + ), + "datatype": Object({ + "location": Number( + 58, ), - "datatype": Object({ - "TypeName": Object({ - "location": Number( - 58, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "isDefault": Bool( - true, - ), - "items": Array([ + "names": Array([ Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "&&", - ), - }), - }), - ]), - }), - }), - "number": Number( - 3, + "String": Object({ + "str": String( + "_int4", ), }), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 149, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "anyarray", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 159, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "anyarray", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "=", - ), - }), - }), - ]), + ]), + "typemod": Number( + -1, + ), + }), + "isDefault": Bool( + true, + ), + "items": Array([ + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "&&", + ), + }), }), - }), - "number": Number( - 6, - ), + ]), }), + "number": Number( + 3, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "@>", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 149, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "anyarray", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 7, - ), + Object({ + "TypeName": Object({ + "location": Number( + 159, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "anyarray", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "=", + ), + }), + }), + ]), }), + "number": Number( + 6, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "<@", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "@>", + ), + }), }), - }), - "number": Number( - 8, - ), + ]), }), + "number": Number( + 7, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 278, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 285, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "query_int", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "@@", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "<@", + ), + }), }), - }), - "number": Number( - 20, - ), + ]), }), + "number": Number( + 8, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 347, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 357, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 364, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 369, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "oid", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 374, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_consistent", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 1, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 278, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 1, - ), + Object({ + "TypeName": Object({ + "location": Number( + 285, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "query_int", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "@@", + ), + }), + }), + ]), }), + "number": Number( + 20, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 430, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 440, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_union", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 347, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 2, - ), + Object({ + "TypeName": Object({ + "location": Number( + 357, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 364, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), + }), + Object({ + "String": Object({ + "str": String( + "int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 369, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "oid", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 374, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_consistent", + ), + }), + }), + ]), }), + "number": Number( + 1, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 499, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_compress", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 430, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 3, - ), + Object({ + "TypeName": Object({ + "location": Number( + 440, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_union", + ), + }), + }), + ]), }), + "number": Number( + 2, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 560, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_decompress", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 499, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 4, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_compress", + ), + }), + }), + ]), }), + "number": Number( + 3, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 618, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 628, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 638, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_penalty", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 560, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 5, - ), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_decompress", + ), + }), + }), + ]), }), + "number": Number( + 4, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 698, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 708, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_picksplit", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 618, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 6, - ), + Object({ + "TypeName": Object({ + "location": Number( + 628, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 638, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_penalty", + ), + }), + }), + ]), }), + "number": Number( + 5, + ), }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 763, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 770, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 777, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "g_int_same", - ), - }), - }), - ]), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 698, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "number": Number( - 7, - ), + Object({ + "TypeName": Object({ + "location": Number( + 708, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_picksplit", + ), + }), + }), + ]), }), + "number": Number( + 6, + ), }), - ]), - "opclassname": Array([ - Object({ - "String": Object({ - "str": String( - "gist__int_ops", - ), + }), + Object({ + "CreateOpClassItem": Object({ + "itemtype": Number( + 2, + ), + "name": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 763, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 770, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "_int4", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 777, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "g_int_same", + ), + }), + }), + ]), }), + "number": Number( + 7, + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 786, - ), - }, - ), + }), + ]), + "opclassname": Array([ + Object({ + "String": Object({ + "str": String( + "gist__int_ops", + ), + }), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 786, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap index 5de2b51b..031606b5 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap @@ -4,41 +4,39 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreatePLangStmt( - Object({ - "plhandler": Array([ - Object({ - "String": Object({ - "str": String( - "plpgsql_call_handler", - ), - }), + RawStmt { + stmt: CreatePLangStmt( + Object({ + "plhandler": Array([ + Object({ + "String": Object({ + "str": String( + "plpgsql_call_handler", + ), }), - ]), - "plname": String( - "plpgsql", - ), - "pltrusted": Bool( - true, - ), - "plvalidator": Array([ - Object({ - "String": Object({ - "str": String( - "plpgsql_validator", - ), - }), + }), + ]), + "plname": String( + "plpgsql", + ), + "pltrusted": Bool( + true, + ), + "plvalidator": Array([ + Object({ + "String": Object({ + "str": String( + "plpgsql_validator", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 108, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 108, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap index d0cab00e..c1eee656 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap @@ -4,54 +4,50 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreatePolicyStmt( - Object({ - "cmd_name": String( - "all", - ), - "permissive": Bool( - true, - ), - "policy_name": String( - "name", - ), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - -1, - ), - "roletype": Number( - 3, - ), - }), - }), - ]), - "table": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), + RawStmt { + stmt: CreatePolicyStmt( + Object({ + "cmd_name": String( + "all", + ), + "permissive": Bool( + true, + ), + "policy_name": String( + "name", + ), + "roles": Array([ + Object({ + "RoleSpec": Object({ "location": Number( - 22, + -1, ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", + "roletype": String( + "ROLESPEC_PUBLIC", ), }), }), + ]), + "table": Object({ + "inh": Bool( + true, + ), + "location": Number( + 22, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 40, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 40, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap index 22b4a333..daf65b3f 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap @@ -3,5 +3,7 @@ source: parser/src/parse.rs expression: res --- Err( - PgParseError, + JsonParse( + "unknown variant `CallStmt`, expected one of `TransactionStmt`, `SelectStmt`, `IndexStmt`, `AlterTableStmt`, `RenameStmt`, `CreateStmt`, `InsertStmt`, `UpdateStmt`, `DeleteStmt`, `CreateSchemaStmt`, `AlterDomainStmt`, `GrantStmt`, `GrantRoleStmt`, `AlterDefaultPrivilegesStmt`, `CopyStmt`, `VariableSetStmt`, `VariableShowStmt`, `CreateTableSpaceStmt`, `DropTableSpaceStmt`, `CreateExtensionStmt`, `AlterExtensionStmt`, `DropStmt`, `AlterObjectSchemaStmt`, `AlterExtensionContentsStmt`, `CreateFdwStmt`, `AlterFdwStmt`, `CreateForeignServerStmt`, `AlterForeignServerStmt`, `CreateForeignTableStmt`, `CreateUserMappingStmt`, `AlterUserMappingStmt`, `DropUserMappingStmt`, `ImportForeignSchemaStmt`, `CreatePolicyStmt`, `AlterPolicyStmt`, `CreateAmStmt`, `CreateTrigStmt`, `CreateEventTrigStmt`, `AlterEventTrigStmt`, `CreateFunctionStmt`, `AlterFunctionStmt`, `CreatePLangStmt`, `CreateRoleStmt`, `AlterRoleStmt`, `AlterRoleSetStmt`, `DropRoleStmt`, `CreateSeqStmt`, `AlterSeqStmt`, `DefineStmt`, `CreateDomainStmt`, `CreateOpClassStmt`, `CreateOpFamilyStmt`, `AlterOpFamilyStmt`, `TruncateStmt`, `CommentStmt`, `SecLabelStmt`, `DeclareCursorStmt`, `ClosePortalStmt`, `FetchStmt`, `CreateStatsStmt`, `ExplainStmt`, `AlterOwnerStmt`, `DoStmt`, `AlterObjectDependsStmt`, `AlterOperatorStmt`, `RuleStmt`, `NotifyStmt`, `ListenStmt`, `UnlistenStmt`, `CompositeTypeStmt`, `CreateEnumStmt`, `CreateRangeStmt`, `AlterEnumStmt`, `ViewStmt`, `LoadStmt`, `CreatedbStmt`, `AlterDatabaseStmt`, `AlterDatabaseSetStmt`, `DropdbStmt`, `AlterSystemStmt`, `ClusterStmt`, `VacuumStmt`, `CreateTableAsStmt`, `RefreshMatViewStmt`, `CheckPointStmt`, `DiscardStmt`, `LockStmt`, `ConstraintsSetStmt`, `ReindexStmt`, `CreateConversionStmt`, `CreateCastStmt`, `CreateTransformStmt`, `PrepareStmt`, `ExecuteStmt`, `DeallocateStmt`, `DropOwnedStmt`, `ReassignOwnedStmt`, `AlterTSDictionaryStmt`, `AlterTSConfigurationStmt`, `CreatePublicationStmt`, `AlterPublicationStmt`, `CreateSubscriptionStmt`, `AlterSubscriptionStmt`, `DropSubscriptionStmt` at line 1 column 808", + ), ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap index af63c4ea..66024359 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap @@ -4,109 +4,105 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreatePublicationStmt( - Object({ - "pubname": String( - "mypublication", - ), - "tables": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 44, - ), - "relname": String( - "users", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: CreatePublicationStmt( + Object({ + "pubname": String( + "mypublication", + ), + "tables": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 44, + ), + "relname": String( + "users", + ), + "relpersistence": String( + "p", + ), }), - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 51, - ), - "relname": String( - "departments", - ), - "relpersistence": String( - "p", - ), - }), + }), + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 51, + ), + "relname": String( + "departments", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 62, - ), - }, - ), - RawStmt( - RawStmt { - stmt: CreatePublicationStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "insert", - ), - }), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 62, + ), + }, + RawStmt { + stmt: CreatePublicationStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "insert", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "publish", - ), - "location": Number( - 122, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "publish", + ), + "location": Number( + 122, + ), }), - ]), - "pubname": String( - "insert_only", - ), - "tables": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 105, - ), - "relname": String( - "mydata", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + "pubname": String( + "insert_only", + ), + "tables": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 105, + ), + "relname": String( + "mydata", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 63, - stmt_len: Some( - 78, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 63, + stmt_len: Some( + 78, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap index 535890ff..c34279a2 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap @@ -4,92 +4,90 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateRangeStmt( - Object({ - "params": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 49, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "float8", - ), - }), + RawStmt { + stmt: CreateRangeStmt( + Object({ + "params": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 49, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "float8", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "subtype", - ), - "location": Number( - 39, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "subtype", + ), + "location": Number( + 39, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 76, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "float8mi", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 76, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "float8mi", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "subtype_diff", - ), - "location": Number( - 61, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "subtype_diff", + ), + "location": Number( + 61, + ), }), - ]), - "typeName": Array([ - Object({ - "String": Object({ - "str": String( - "floatrange", - ), - }), + }), + ]), + "typeName": Array([ + Object({ + "String": Object({ + "str": String( + "floatrange", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 86, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 86, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap index 067d9d72..20f81bdb 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap @@ -4,92 +4,83 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateRoleStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + RawStmt { + stmt: CreateRoleStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "canlogin", - ), - "location": Number( - 30, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "canlogin", + ), + "location": Number( + 30, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "A_Const": Object({ - "location": Number( - 45, - ), - "val": Object({ - "String": Object({ - "str": String( - "jw8s0F4", - ), - }), - }), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "jw8s0F4", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "password", - ), - "location": Number( - 36, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "password", + ), + "location": Number( + 36, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "2005-01-01", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "2005-01-01", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "validUntil", - ), - "location": Number( - 60, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "validUntil", + ), + "location": Number( + 60, + ), }), - ]), - "role": String( - "miriam", - ), - "stmt_type": Number( - 0, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 84, - ), - }, - ), + }), + ]), + "role": String( + "miriam", + ), + "stmt_type": String( + "ROLESTMT_ROLE", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 84, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap index c1e52530..3a164052 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap @@ -4,55 +4,51 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateSeqStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 101, - ), - }), + RawStmt { + stmt: CreateSeqStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 101, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "start", - ), - "location": Number( - 24, - ), }), - }), - ]), - "sequence": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 17, + "defaction": String( + "DEFELEM_UNSPEC", ), - "relname": String( - "serial", + "defname": String( + "start", ), - "relpersistence": String( - "p", + "location": Number( + 24, ), }), }), + ]), + "sequence": Object({ + "inh": Bool( + true, + ), + "location": Number( + 17, + ), + "relname": String( + "serial", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 33, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap index c153c2b4..9cbe1b33 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap @@ -4,87 +4,85 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateStatsStmt( - Object({ - "defnames": Array([ - Object({ - "String": Object({ - "str": String( - "s1", - ), - }), + RawStmt { + stmt: CreateStatsStmt( + Object({ + "defnames": Array([ + Object({ + "String": Object({ + "str": String( + "s1", + ), }), - ]), - "exprs": Array([ - Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "a", - ), - }), + }), + ]), + "exprs": Array([ + Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "a", + ), }), - ]), - "location": Number( - 40, - ), - }), + }), + ]), + "location": Number( + 40, + ), }), - Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "b", - ), - }), + }), + Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "b", + ), }), - ]), - "location": Number( - 43, - ), - }), + }), + ]), + "location": Number( + 43, + ), }), - ]), - "relations": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 50, - ), - "relname": String( - "t1", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + "relations": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 50, + ), + "relname": String( + "t1", + ), + "relpersistence": String( + "p", + ), }), - ]), - "stat_types": Array([ - Object({ - "String": Object({ - "str": String( - "dependencies", - ), - }), + }), + ]), + "stat_types": Array([ + Object({ + "String": Object({ + "str": String( + "dependencies", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 52, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 52, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap index 1ffb5288..b5d69409 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap @@ -4,39 +4,37 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateSubscriptionStmt( - Object({ - "conninfo": String( - "host=192.168.1.50 port=5432 user=foo dbname=foodb", - ), - "publication": Array([ - Object({ - "String": Object({ - "str": String( - "mypublication", - ), - }), + RawStmt { + stmt: CreateSubscriptionStmt( + Object({ + "conninfo": String( + "host=192.168.1.50 port=5432 user=foo dbname=foodb", + ), + "publication": Array([ + Object({ + "String": Object({ + "str": String( + "mypublication", + ), }), - Object({ - "String": Object({ - "str": String( - "insert_only", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "insert_only", + ), }), - ]), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 145, - ), - }, - ), + }), + ]), + "subname": String( + "mysub", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 145, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap index 6e3d5e43..ad455461 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap @@ -4,89 +4,86 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateTableAsStmt( - Object({ - "into": Object({ - "IntoClause": Object({ - "onCommit": Number( - 0, - ), - "rel": Object({ + RawStmt { + stmt: CreateTableAsStmt( + Object({ + "into": Object({ + "onCommit": String( + "ONCOMMIT_NOOP", + ), + "rel": Object({ + "inh": Bool( + true, + ), + "location": Number( + 14, + ), + "relname": String( + "films2", + ), + "relpersistence": String( + "p", + ), + }), + }), + "query": Object({ + "SelectStmt": Object({ + "fromClause": Array([ + Object({ "RangeVar": Object({ "inh": Bool( true, ), "location": Number( - 14, + 32, ), "relname": String( - "films2", + "films", ), "relpersistence": String( "p", ), }), }), - }), - }), - "query": Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 32, - ), - "relname": String( - "films", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - "op": Number( - 0, - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - -1, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - -1, - ), - }), + ]), + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "targetList": Array([ + Object({ + "ResTarget": Object({ + "location": Number( + -1, + ), + "val": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "A_Star": Object({}), + }), + ]), + "location": Number( + -1, + ), }), }), }), - ]), - }), + }), + ]), }), - "relkind": Number( - 37, - ), }), - ), - stmt_location: 0, - stmt_len: Some( - 37, - ), - }, - ), + "relkind": String( + "OBJECT_TABLE", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 37, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap index 846aae15..0528fd7b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap @@ -4,107 +4,99 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateTransformStmt( - Object({ - "fromsql": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 96, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + RawStmt { + stmt: CreateTransformStmt( + Object({ + "fromsql": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 96, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "hstore_to_plpython", - ), - }), - }), - ]), + ]), + "typemod": Number( + -1, + ), + }), }), - }), - "lang": String( - "plpythonu", - ), - "tosql": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 151, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "str": String( - "plpython_to_hstore", - ), - }), - }), - ]), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "hstore_to_plpython", + ), + }), }), - }), - "type_name": Object({ - "TypeName": Object({ - "location": Number( - 22, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "hstore", - ), + ]), + }), + "lang": String( + "plpythonu", + ), + "tosql": Object({ + "objargs": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 151, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "internal", + ), + }), }), - }), - ]), - "typemod": Number( - -1, - ), + ]), + "typemod": Number( + -1, + ), + }), }), - }), + ]), + "objname": Array([ + Object({ + "String": Object({ + "str": String( + "plpython_to_hstore", + ), + }), + }), + ]), + }), + "type_name": Object({ + "location": Number( + 22, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "hstore", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 162, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 162, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap index 92cdeff8..3fb1d8a0 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap @@ -4,54 +4,50 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateTrigStmt( - Object({ - "events": Number( - 16, - ), - "funcname": Array([ - Object({ - "String": Object({ - "str": String( - "check_account_update", - ), - }), - }), - ]), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 50, - ), - "relname": String( - "accounts", - ), - "relpersistence": String( - "p", + RawStmt { + stmt: CreateTrigStmt( + Object({ + "events": Number( + 16, + ), + "funcname": Array([ + Object({ + "String": Object({ + "str": String( + "check_account_update", ), }), }), - "row": Bool( + ]), + "relation": Object({ + "inh": Bool( true, ), - "timing": Number( - 2, + "location": Number( + 50, + ), + "relname": String( + "accounts", ), - "trigname": String( - "check_update", + "relpersistence": String( + "p", ), }), - ), - stmt_location: 0, - stmt_len: Some( - 120, - ), - }, - ), + "row": Bool( + true, + ), + "timing": Number( + 2, + ), + "trigname": String( + "check_update", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 120, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap index ad42a839..c20c7f7f 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap @@ -4,75 +4,71 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateUserMappingStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "bob", - ), - }), + RawStmt { + stmt: CreateUserMappingStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "bob", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "user", - ), - "location": Number( - 48, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "user", + ), + "location": Number( + 48, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "secret", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "secret", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "password", - ), - "location": Number( - 60, - ), }), - }), - ]), - "servername": String( - "foo", - ), - "user": Object({ - "RoleSpec": Object({ - "location": Number( - 24, + "defaction": String( + "DEFELEM_UNSPEC", ), - "rolename": String( - "bob", + "defname": String( + "password", ), - "roletype": Number( - 0, + "location": Number( + 60, ), }), }), + ]), + "servername": String( + "foo", + ), + "user": Object({ + "location": Number( + 24, + ), + "rolename": String( + "bob", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 78, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 78, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap index d1297d6f..fd106e95 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap @@ -4,192 +4,190 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ViewStmt( - Object({ - "query": Object({ - "SelectStmt": Object({ - "op": Number( - 0, - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 29, - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 29, - ), - "val": Object({ - "String": Object({ - "str": String( - "Hello World", - ), - }), + RawStmt { + stmt: ViewStmt( + Object({ + "query": Object({ + "SelectStmt": Object({ + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "targetList": Array([ + Object({ + "ResTarget": Object({ + "location": Number( + 29, + ), + "val": Object({ + "A_Const": Object({ + "location": Number( + 29, + ), + "val": Object({ + "String": Object({ + "str": String( + "Hello World", + ), }), }), }), }), }), - ]), - }), - }), - "view": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 13, - ), - "relname": String( - "vista", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), }), - "withCheckOption": Number( - 0, + }), + "view": Object({ + "inh": Bool( + true, + ), + "location": Number( + 13, + ), + "relname": String( + "vista", + ), + "relpersistence": String( + "p", ), }), - ), - stmt_location: 0, - stmt_len: Some( - 42, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ViewStmt( - Object({ - "query": Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 90, - ), - "relname": String( - "films", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - "op": Number( - 0, - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 79, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 79, - ), - }), - }), - }), + "withCheckOption": String( + "NO_CHECK_OPTION", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 42, + ), + }, + RawStmt { + stmt: ViewStmt( + Object({ + "query": Object({ + "SelectStmt": Object({ + "fromClause": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 90, + ), + "relname": String( + "films", + ), + "relpersistence": String( + "p", + ), }), - ]), - "whereClause": Object({ - "A_Expr": Object({ - "kind": Number( - 0, + }), + ]), + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "targetList": Array([ + Object({ + "ResTarget": Object({ + "location": Number( + 79, ), - "lexpr": Object({ + "val": Object({ "ColumnRef": Object({ "fields": Array([ Object({ - "String": Object({ - "str": String( - "kind", - ), - }), + "A_Star": Object({}), }), ]), "location": Number( - 106, + 79, ), }), }), - "location": Number( - 111, - ), - "name": Array([ - Object({ - "String": Object({ - "str": String( - "=", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 113, - ), - "val": Object({ + }), + }), + ]), + "whereClause": Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ "String": Object({ "str": String( - "Comedy", + "kind", ), }), }), + ]), + "location": Number( + 106, + ), + }), + }), + "location": Number( + 111, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + "=", + ), + }), + }), + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 113, + ), + "val": Object({ + "String": Object({ + "str": String( + "Comedy", + ), + }), }), }), }), }), }), }), - "view": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 56, - ), - "relname": String( - "comedies", - ), - "relpersistence": String( - "p", - ), - }), - }), - "withCheckOption": Number( - 0, + }), + "view": Object({ + "inh": Bool( + true, + ), + "location": Number( + 56, + ), + "relname": String( + "comedies", + ), + "relpersistence": String( + "p", ), }), - ), - stmt_location: 43, - stmt_len: Some( - 78, - ), - }, - ), + "withCheckOption": String( + "NO_CHECK_OPTION", + ), + }), + ), + stmt_location: 43, + stmt_len: Some( + 78, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap index f693e073..c6fdec6f 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap @@ -4,16 +4,14 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DeallocateStmt( - Object({}), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ), + RawStmt { + stmt: DeallocateStmt( + Object({}), + ), + stmt_location: 0, + stmt_len: Some( + 23, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap index 5cdec2ea..847c974f 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap @@ -4,69 +4,70 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DeclareCursorStmt( - Object({ - "options": Number( - 32, - ), - "portalname": String( - "curs2", - ), - "query": Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 44, - ), - "relname": String( - "tenk1", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: DeclareCursorStmt( + Object({ + "options": Number( + 32, + ), + "portalname": String( + "curs2", + ), + "query": Object({ + "SelectStmt": Object({ + "fromClause": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 44, + ), + "relname": String( + "tenk1", + ), + "relpersistence": String( + "p", + ), }), - ]), - "op": Number( - 0, - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 37, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 37, - ), - }), + }), + ]), + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "targetList": Array([ + Object({ + "ResTarget": Object({ + "location": Number( + 37, + ), + "val": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "A_Star": Object({}), + }), + ]), + "location": Number( + 37, + ), }), }), }), - ]), - }), + }), + ]), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 49, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap b/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap index 318affb0..193cc405 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap @@ -4,261 +4,267 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DefineStmt( - Object({ - "definition": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 37, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "box", - ), - }), + RawStmt { + stmt: DefineStmt( + Object({ + "definition": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 37, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "box", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "leftarg", - ), - "location": Number( - 27, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "leftarg", + ), + "location": Number( + 27, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 57, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "box", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 57, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "box", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "rightarg", - ), - "location": Number( - 46, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "rightarg", + ), + "location": Number( + 46, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 78, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "area_equal_procedure", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 78, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "area_equal_procedure", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "procedure", - ), - "location": Number( - 66, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "procedure", + ), + "location": Number( + 66, + ), }), - Object({ - "DefElem": Object({ - "arg": Array([ - Object({ - "String": Object({ - "str": String( - "===", - ), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "===", + ), + }), }), - }), - ]), - "defaction": Number( - 0, - ), - "defname": String( - "commutator", - ), - "location": Number( - 104, - ), + ]), + }), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "commutator", + ), + "location": Number( + 104, + ), }), - Object({ - "DefElem": Object({ - "arg": Array([ - Object({ - "String": Object({ - "str": String( - "!==", - ), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "!==", + ), + }), }), - }), - ]), - "defaction": Number( - 0, - ), - "defname": String( - "negator", - ), - "location": Number( - 126, - ), + ]), + }), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "negator", + ), + "location": Number( + 126, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 156, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "area_restriction_procedure", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 156, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "area_restriction_procedure", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "restrict", - ), - "location": Number( - 145, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "restrict", + ), + "location": Number( + 145, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 195, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "area_join_procedure", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 195, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "area_join_procedure", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "join", - ), - "location": Number( - 188, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "join", + ), + "location": Number( + 188, + ), }), - Object({ - "DefElem": Object({ - "defaction": Number( - 0, - ), - "defname": String( - "hashes", - ), - "location": Number( - 220, - ), - }), + }), + Object({ + "DefElem": Object({ + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "hashes", + ), + "location": Number( + 220, + ), }), - Object({ - "DefElem": Object({ - "defaction": Number( - 0, - ), - "defname": String( - "merges", - ), - "location": Number( - 228, - ), - }), + }), + Object({ + "DefElem": Object({ + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "merges", + ), + "location": Number( + 228, + ), }), - ]), - "defnames": Array([ - Object({ - "String": Object({ - "str": String( - "===", - ), - }), + }), + ]), + "defnames": Array([ + Object({ + "String": Object({ + "str": String( + "===", + ), }), - ]), - "kind": Number( - 25, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 236, - ), - }, - ), + }), + ]), + "kind": String( + "OBJECT_OPERATOR", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 236, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap b/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap index f0e1e33e..30e6f3b3 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap @@ -4,147 +4,145 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DefineStmt( - Object({ - "definition": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 16, - ), - }), + RawStmt { + stmt: DefineStmt( + Object({ + "definition": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "Integer": Object({ + "ival": Number( + 16, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "internallength", - ), - "location": Number( - 23, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "internallength", + ), + "location": Number( + 23, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 56, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "my_box_in_function", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 56, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "my_box_in_function", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "input", - ), - "location": Number( - 48, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "input", + ), + "location": Number( + 48, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 89, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "my_box_out_function", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 89, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "my_box_out_function", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "output", - ), - "location": Number( - 80, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "output", + ), + "location": Number( + 80, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 124, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "float4", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 124, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "float4", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "element", - ), - "location": Number( - 114, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "element", + ), + "location": Number( + 114, + ), }), - ]), - "defnames": Array([ - Object({ - "String": Object({ - "str": String( - "box", - ), - }), + }), + ]), + "defnames": Array([ + Object({ + "String": Object({ + "str": String( + "box", + ), }), - ]), - "kind": Number( - 45, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 132, - ), - }, - ), + }), + ]), + "kind": String( + "OBJECT_TYPE", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 132, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap index f3dbddb2..6015ef96 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap @@ -4,16 +4,16 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DefineStmt( - Object({ - "args": Array([ - Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "TypeName": Object({ + RawStmt { + stmt: DefineStmt( + Object({ + "args": Array([ + Object({ + "List": Object({ + "items": Array([ + Object({ + "FunctionParameter": Object({ + "argType": Object({ "location": Number( 23, ), @@ -30,126 +30,126 @@ Ok( -1, ), }), + "mode": String( + "FUNC_PARAM_IN", + ), }), - "mode": Number( - 105, - ), }), - }), - ]), - Object({ - "Integer": Object({ - "ival": Number( - -1, - ), - }), + ]), }), - ]), - "definition": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 46, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "complex_add", - ), - }), + }), + Object({ + "Integer": Object({ + "ival": Number( + -1, + ), + }), + }), + ]), + "definition": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 46, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "complex_add", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "sfunc", - ), - "location": Number( - 38, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "sfunc", + ), + "location": Number( + 38, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 71, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "complex", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "TypeName": Object({ + "location": Number( + 71, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "complex", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "stype", - ), - "location": Number( - 63, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "stype", + ), + "location": Number( + 63, + ), }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "(0,0)", - ), - }), + }), + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "(0,0)", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "initcond", - ), - "location": Number( - 84, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "initcond", + ), + "location": Number( + 84, + ), }), - ]), - "defnames": Array([ - Object({ - "String": Object({ - "str": String( - "sum", - ), - }), + }), + ]), + "defnames": Array([ + Object({ + "String": Object({ + "str": String( + "sum", + ), }), - ]), - "kind": Number( - 1, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 104, - ), - }, - ), + }), + ]), + "kind": String( + "OBJECT_AGGREGATE", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 104, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap index 9e2463cd..a2237f2b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap @@ -4,50 +4,44 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DiscardStmt( - Object({ - "target": Number( - 1, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 14, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DiscardStmt( - Object({ - "target": Number( - 2, - ), - }), - ), - stmt_location: 15, - stmt_len: Some( - 18, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DiscardStmt( - Object({ - "target": Number( - 3, - ), - }), - ), - stmt_location: 34, - stmt_len: Some( - 13, - ), - }, - ), + RawStmt { + stmt: DiscardStmt( + Object({ + "target": String( + "DISCARD_PLANS", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 14, + ), + }, + RawStmt { + stmt: DiscardStmt( + Object({ + "target": String( + "DISCARD_SEQUENCES", + ), + }), + ), + stmt_location: 15, + stmt_len: Some( + 18, + ), + }, + RawStmt { + stmt: DiscardStmt( + Object({ + "target": String( + "DISCARD_TEMP", + ), + }), + ), + stmt_location: 34, + stmt_len: Some( + 13, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap index 4ed23e60..f8448982 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap @@ -4,39 +4,37 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DoStmt( - Object({ - "args": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "str": String( - "DECLARE r record;\nBEGIN\n FOR r IN SELECT table_schema, table_name FROM information_schema.tables\n WHERE table_type = \'VIEW\' AND table_schema = \'public\'\n LOOP\n EXECUTE \'GRANT ALL ON \' || quote_ident(r.table_schema) || \'.\' || quote_ident(r.table_name) || \' TO webuser\';\n END LOOP;\nEND", - ), - }), + RawStmt { + stmt: DoStmt( + Object({ + "args": Array([ + Object({ + "DefElem": Object({ + "arg": Object({ + "String": Object({ + "str": String( + "DECLARE r record;\nBEGIN\n FOR r IN SELECT table_schema, table_name FROM information_schema.tables\n WHERE table_type = \'VIEW\' AND table_schema = \'public\'\n LOOP\n EXECUTE \'GRANT ALL ON \' || quote_ident(r.table_schema) || \'.\' || quote_ident(r.table_name) || \' TO webuser\';\n END LOOP;\nEND", + ), }), - "defaction": Number( - 0, - ), - "defname": String( - "as", - ), - "location": Number( - 4, - ), }), + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "as", + ), + "location": Number( + 4, + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 318, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 318, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap index 4710972a..101432ef 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap @@ -4,38 +4,34 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropdbStmt( - Object({ - "dbname": String( - "name", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 19, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropdbStmt( - Object({ - "dbname": String( - "name", - ), - "missing_ok": Bool( - true, - ), - }), - ), - stmt_location: 20, - stmt_len: Some( - 29, - ), - }, - ), + RawStmt { + stmt: DropdbStmt( + Object({ + "dbname": String( + "name", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 19, + ), + }, + RawStmt { + stmt: DropdbStmt( + Object({ + "dbname": String( + "name", + ), + "missing_ok": Bool( + true, + ), + }), + ), + stmt_location: 20, + stmt_len: Some( + 29, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap index 4b1ca7ac..cc614c47 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap @@ -4,21 +4,19 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: false, - remove_type: Extension, - }, - ), - stmt_location: 0, - stmt_len: Some( - 21, - ), - }, - ), + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: false, + remove_type: Extension, + }, + ), + stmt_location: 0, + stmt_len: Some( + 21, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap index f17c5c70..90576a96 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap @@ -4,229 +4,201 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 24, - stmt_len: Some( - 33, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: true, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 58, - stmt_len: Some( - 36, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: true, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 95, - stmt_len: Some( - 36, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: true, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 132, - stmt_len: Some( - 45, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 178, - stmt_len: Some( - 36, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: DropCascade, - concurrent: false, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 215, - stmt_len: Some( - 43, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: false, - remove_type: Index, - }, - ), - stmt_location: 259, - stmt_len: Some( - 44, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 304, - stmt_len: Some( - 46, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: DropCascade, - concurrent: false, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 351, - stmt_len: Some( - 53, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 405, - stmt_len: Some( - 54, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: true, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 460, - stmt_len: Some( - 59, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: DropCascade, - concurrent: true, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 520, - stmt_len: Some( - 66, - ), - }, - ), - RawStmt( - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: true, - missing_ok: true, - remove_type: Index, - }, - ), - stmt_location: 587, - stmt_len: Some( - 67, - ), - }, - ), + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 0, + stmt_len: Some( + 23, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 24, + stmt_len: Some( + 33, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: true, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 58, + stmt_len: Some( + 36, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: true, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 95, + stmt_len: Some( + 36, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: true, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 132, + stmt_len: Some( + 45, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 178, + stmt_len: Some( + 36, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: DropCascade, + concurrent: false, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 215, + stmt_len: Some( + 43, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: false, + remove_type: Index, + }, + ), + stmt_location: 259, + stmt_len: Some( + 44, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 304, + stmt_len: Some( + 46, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: DropCascade, + concurrent: false, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 351, + stmt_len: Some( + 53, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: false, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 405, + stmt_len: Some( + 54, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: true, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 460, + stmt_len: Some( + 59, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: DropCascade, + concurrent: true, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 520, + stmt_len: Some( + 66, + ), + }, + RawStmt { + stmt: DropStmt( + DropStmt { + behavior: Restrict, + concurrent: true, + missing_ok: true, + remove_type: Index, + }, + ), + stmt_location: 587, + stmt_len: Some( + 67, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap index 0a0bc36c..858a1ec0 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap @@ -4,35 +4,33 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropOwnedStmt( - Object({ - "behavior": Number( - 1, - ), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 15, - ), - "rolename": String( - "foo", - ), - "roletype": Number( - 0, - ), - }), + RawStmt { + stmt: DropOwnedStmt( + Object({ + "behavior": String( + "DROP_CASCADE", + ), + "roles": Array([ + Object({ + "RoleSpec": Object({ + "location": Number( + 15, + ), + "rolename": String( + "foo", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 26, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 26, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap index dd1a6809..f46949ec 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap @@ -4,32 +4,30 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropRoleStmt( - Object({ - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 11, - ), - "rolename": String( - "jonathan", - ), - "roletype": Number( - 0, - ), - }), + RawStmt { + stmt: DropRoleStmt( + Object({ + "roles": Array([ + Object({ + "RoleSpec": Object({ + "location": Number( + 11, + ), + "rolename": String( + "jonathan", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 19, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 19, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap index 8f86d9b3..63680ca1 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap @@ -4,23 +4,21 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropSubscriptionStmt( - Object({ - "behavior": Number( - 0, - ), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 24, - ), - }, - ), + RawStmt { + stmt: DropSubscriptionStmt( + Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "subname": String( + "mysub", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 24, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap index 1f73a3a6..60aab2c7 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap @@ -4,36 +4,32 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropUserMappingStmt( - Object({ - "missing_ok": Bool( - true, + RawStmt { + stmt: DropUserMappingStmt( + Object({ + "missing_ok": Bool( + true, + ), + "servername": String( + "foo", + ), + "user": Object({ + "location": Number( + 32, ), - "servername": String( - "foo", + "rolename": String( + "bob", + ), + "roletype": String( + "ROLESPEC_CSTRING", ), - "user": Object({ - "RoleSpec": Object({ - "location": Number( - 32, - ), - "rolename": String( - "bob", - ), - "roletype": Number( - 0, - ), - }), - }), }), - ), - stmt_location: 0, - stmt_len: Some( - 46, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 46, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap index 4760c47e..c36d38d3 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap @@ -4,78 +4,76 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ExecuteStmt( - Object({ - "name": String( - "fooplan", - ), - "params": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 17, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + RawStmt { + stmt: ExecuteStmt( + Object({ + "name": String( + "fooplan", + ), + "params": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 17, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), }), }), - Object({ - "A_Const": Object({ - "location": Number( - 20, - ), - "val": Object({ - "String": Object({ - "str": String( - "Hunter Valley", - ), - }), + }), + Object({ + "A_Const": Object({ + "location": Number( + 20, + ), + "val": Object({ + "String": Object({ + "str": String( + "Hunter Valley", + ), }), }), }), - Object({ - "A_Const": Object({ - "location": Number( - 37, - ), - "val": Object({ - "String": Object({ - "str": String( - "t", - ), - }), + }), + Object({ + "A_Const": Object({ + "location": Number( + 37, + ), + "val": Object({ + "String": Object({ + "str": String( + "t", + ), }), }), }), - Object({ - "A_Const": Object({ - "location": Number( - 42, - ), - "val": Object({ - "Float": Object({ - "str": String( - "200.00", - ), - }), + }), + Object({ + "A_Const": Object({ + "location": Number( + 42, + ), + "val": Object({ + "Float": Object({ + "str": String( + "200.00", + ), }), }), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 49, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap index d5a6efad..be46a729 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap @@ -4,188 +4,189 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ExplainStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "defaction": Number( - 0, - ), - "defname": String( - "analyze", - ), - "location": Number( - 9, - ), - }), + RawStmt { + stmt: ExplainStmt( + Object({ + "options": Array([ + Object({ + "DefElem": Object({ + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "analyze", + ), + "location": Number( + 9, + ), }), - ]), - "query": Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 31, - ), - "relname": String( - "t1", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + "query": Object({ + "SelectStmt": Object({ + "fromClause": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 31, + ), + "relname": String( + "t1", + ), + "relpersistence": String( + "p", + ), }), - ]), - "op": Number( - 0, - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 24, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 24, - ), - }), + }), + ]), + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "targetList": Array([ + Object({ + "ResTarget": Object({ + "location": Number( + 24, + ), + "val": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "A_Star": Object({}), + }), + ]), + "location": Number( + 24, + ), }), }), }), - ]), - "whereClause": Object({ - "BoolExpr": Object({ - "args": Array([ - Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "a", - ), - }), + }), + ]), + "whereClause": Object({ + "BoolExpr": Object({ + "args": Array([ + Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "a", + ), }), - ]), - "location": Number( - 41, + }), + ]), + "location": Number( + 41, + ), + }), + }), + "location": Number( + 43, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + "=", ), }), }), - "location": Number( - 43, - ), - "name": Array([ - Object({ - "String": Object({ - "str": String( - "=", + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 45, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 1, ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 45, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 1, + }), + }), + }), + }), + Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "b", ), }), }), - }), + ]), + "location": Number( + 53, + ), }), }), - }), - Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "b", - ), - }), - }), - ]), - "location": Number( - 53, + "location": Number( + 55, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + "=", ), }), }), - "location": Number( - 55, - ), - "name": Array([ - Object({ - "String": Object({ - "str": String( - "=", + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 57, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 0, ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 57, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 0, - ), - }), - }), - }), }), }), }), - ]), - "boolop": Number( - 0, - ), - "location": Number( - 48, - ), - }), + }), + ]), + "boolop": String( + "AND_EXPR", + ), + "location": Number( + 48, + ), }), }), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 59, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 59, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap index cc43fdf3..4343c556 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap @@ -4,26 +4,24 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: FetchStmt( - Object({ - "direction": Number( - 0, - ), - "howMany": Number( - 5, - ), - "portalname": String( - "foo", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 25, - ), - }, - ), + RawStmt { + stmt: FetchStmt( + Object({ + "direction": String( + "FETCH_FORWARD", + ), + "howMany": Number( + 5, + ), + "portalname": String( + "foo", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 25, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap index cc46acac..8e3198aa 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap @@ -4,29 +4,27 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ImportForeignSchemaStmt( - Object({ - "list_type": Number( - 0, - ), - "local_schema": String( - "films", - ), - "remote_schema": String( - "foreign_films", - ), - "server_name": String( - "film_server", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 75, - ), - }, - ), + RawStmt { + stmt: ImportForeignSchemaStmt( + Object({ + "list_type": String( + "FDW_IMPORT_SCHEMA_ALL", + ), + "local_schema": String( + "films", + ), + "remote_schema": String( + "foreign_films", + ), + "server_name": String( + "film_server", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 75, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap b/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap index 568bceb9..26c41a05 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap @@ -4,104 +4,100 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "idx_a_foo_bar", - ), - index_params: [ - IndexElem( - IndexElem { - name: None, - expr: Some( - Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "foo", - ), - }), + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "idx_a_foo_bar", + ), + index_params: [ + IndexElem( + IndexElem { + name: None, + expr: Some( + Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "foo", + ), }), - ]), - "location": Number( - 66, + }), + ]), + "location": Number( + 66, + ), + }), + }), + "location": Number( + 69, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + "->>", ), }), }), - "location": Number( - 69, - ), - "name": Array([ - Object({ + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 72, + ), + "val": Object({ "String": Object({ "str": String( - "->>", + "bar", ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 72, - ), - "val": Object({ - "String": Object({ - "str": String( - "bar", - ), - }), - }), - }), }), }), }), - ), - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "a", - inh: true, - relpersistence: "p", - alias: None, - location: 60, + }), + ), + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: true, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: true, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "a", + inh: true, + relpersistence: "p", + alias: None, + location: 60, }, - ), - stmt_location: 0, - stmt_len: Some( - 79, - ), - }, - ), + concurrent: true, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: true, + table_space: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 79, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap index b985708b..a23cc032 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ListenStmt( - Object({ - "conditionname": String( - "virtual", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 15, - ), - }, - ), + RawStmt { + stmt: ListenStmt( + Object({ + "conditionname": String( + "virtual", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 15, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap index 0ebeadaa..f12115a7 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: LoadStmt( - Object({ - "filename": String( - "filename", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 16, - ), - }, - ), + RawStmt { + stmt: LoadStmt( + Object({ + "filename": String( + "filename", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 16, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap index afaf09ad..24fb6075 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap @@ -4,71 +4,67 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: LockStmt( - Object({ - "mode": Number( - 5, - ), - "relations": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 12, - ), - "relname": String( - "films", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: LockStmt( + Object({ + "mode": Number( + 5, + ), + "relations": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 12, + ), + "relname": String( + "films", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 31, - ), - }, - ), - RawStmt( - RawStmt { - stmt: LockStmt( - Object({ - "mode": Number( - 6, - ), - "relations": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 44, - ), - "relname": String( - "films", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 31, + ), + }, + RawStmt { + stmt: LockStmt( + Object({ + "mode": Number( + 6, + ), + "relations": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 44, + ), + "relname": String( + "films", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 32, - stmt_len: Some( - 45, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 32, + stmt_len: Some( + 45, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__migration.snap b/parser/src/snapshots/squawk_parser__parse__tests__migration.snap index ac018390..a202e0dd 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__migration.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__migration.snap @@ -4,141 +4,129 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: TransactionStmt( - TransactionStmt { - kind: Begin, - }, - ), - stmt_location: 0, - stmt_len: Some( - 6, - ), - }, - ), - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "table_name_field_name_idx", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "field_name", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 52, + RawStmt { + stmt: TransactionStmt( + TransactionStmt { + kind: Begin, + }, + ), + stmt_location: 0, + stmt_len: Some( + 6, + ), + }, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "table_name_field_name_idx", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "field_name", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: false, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 52, }, - ), - stmt_location: 7, - stmt_len: Some( - 72, - ), - }, - ), - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "table_name_field_name_idx", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "field_name", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [ - Object({ - "String": Object({ - "str": String( - "varchar_pattern_ops", - ), - }), + concurrent: false, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 7, + stmt_len: Some( + 72, + ), + }, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "table_name_field_name_idx", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "field_name", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [ + Object({ + "String": Object({ + "str": String( + "varchar_pattern_ops", + ), }), - ], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 125, + }), + ], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: false, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, - }, - ), - stmt_location: 80, - stmt_len: Some( - 92, - ), - }, - ), - RawStmt( - RawStmt { - stmt: TransactionStmt( - TransactionStmt { - kind: Commit, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 125, }, - ), - stmt_location: 173, - stmt_len: Some( - 7, - ), - }, - ), + concurrent: false, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 80, + stmt_len: Some( + 92, + ), + }, + RawStmt { + stmt: TransactionStmt( + TransactionStmt { + kind: Commit, + }, + ), + stmt_location: 173, + stmt_len: Some( + 7, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap index 8b6b8be7..e213a483 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap @@ -4,38 +4,34 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: NotifyStmt( - Object({ - "conditionname": String( - "virtual", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 15, - ), - }, - ), - RawStmt( - RawStmt { - stmt: NotifyStmt( - Object({ - "conditionname": String( - "virtual", - ), - "payload": String( - "This is the payload", - ), - }), - ), - stmt_location: 16, - stmt_len: Some( - 38, - ), - }, - ), + RawStmt { + stmt: NotifyStmt( + Object({ + "conditionname": String( + "virtual", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 15, + ), + }, + RawStmt { + stmt: NotifyStmt( + Object({ + "conditionname": String( + "virtual", + ), + "payload": String( + "This is the payload", + ), + }), + ), + stmt_location: 16, + stmt_len: Some( + 38, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap index f152f72b..09255912 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap @@ -4,23 +4,21 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RenameStmt( - RenameStmt { - newname: "new_name", - behavior: Restrict, - relation: None, - relation_type: AccessMethod, - rename_type: Collation, - subname: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ), + RawStmt { + stmt: RenameStmt( + RenameStmt { + newname: "new_name", + behavior: Restrict, + relation: None, + relation_type: AccessMethod, + rename_type: Collation, + subname: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 39, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap index 5addaf10..08a6fdc4 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap @@ -4,107 +4,99 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: AlterConstraint, - name: None, - def: Some( - Constraint( - Constraint { - conname: Some( - "constraint", - ), - contype: Foreign, - location: None, - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, - }, - ), + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: AlterConstraint, + name: None, + def: Some( + Constraint( + Constraint { + conname: Some( + "constraint", + ), + contype: Foreign, + location: None, + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table", - inh: true, - relpersistence: "p", - alias: None, - location: 13, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table", + inh: true, + relpersistence: "p", + alias: None, + location: 13, }, - ), - stmt_location: 0, - stmt_len: Some( - 81, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: AlterConstraint, - name: None, - def: Some( - Constraint( - Constraint { - conname: Some( - "constraint", - ), - contype: Foreign, - location: None, - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 81, + ), + }, + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: AlterConstraint, + name: None, + def: Some( + Constraint( + Constraint { + conname: Some( + "constraint", + ), + contype: Foreign, + location: None, + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table", - inh: true, - relpersistence: "p", - alias: None, - location: 96, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table", + inh: true, + relpersistence: "p", + alias: None, + location: 96, }, - ), - stmt_location: 82, - stmt_len: Some( - 66, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 82, + stmt_len: Some( + 66, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap index f3446cfc..4fc09f0d 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap @@ -4,32 +4,30 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterDomainStmt( - Object({ - "behavior": Number( - 0, - ), - "subtype": String( - "O", - ), - "typeName": Array([ - Object({ - "String": Object({ - "str": String( - "zipcode", - ), - }), + RawStmt { + stmt: AlterDomainStmt( + Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "subtype": String( + "O", + ), + "typeName": Array([ + Object({ + "String": Object({ + "str": String( + "zipcode", + ), }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 33, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap index 0cb9787e..c1840229 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateSchemaStmt( - Object({ - "schemaname": String( - "schema_name", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 25, - ), - }, - ), + RawStmt { + stmt: CreateSchemaStmt( + Object({ + "schemaname": String( + "schema_name", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 25, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap index 61058699..68a3d958 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap @@ -4,118 +4,92 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateStmt( - CreateStmt { - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "measurement_y2006m02", - inh: true, - relpersistence: "p", - alias: None, - location: 14, - }, - ), - table_elts: [], - inh_relations: [ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 48, - ), - "relname": String( - "measurement", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: CreateStmt( + CreateStmt { + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "measurement_y2006m02", + inh: true, + relpersistence: "p", + alias: None, + location: 14, + }, + table_elts: [], + inh_relations: [ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 48, + ), + "relname": String( + "measurement", + ), + "relpersistence": String( + "p", + ), }), - ], - partbound: Some( - Object({ - "PartitionBoundSpec": Object({ - "location": Number( - 75, - ), - "lowerdatums": Array([ - Object({ - "PartitionRangeDatum": Object({ - "kind": Number( - 0, + }), + ], + partbound: Some( + Object({ + "location": Number( + 75, + ), + "lowerdatums": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 81, + ), + "val": Object({ + "String": Object({ + "str": String( + "2006-02-01", ), - "location": Number( - 81, - ), - "value": Object({ - "A_Const": Object({ - "location": Number( - 81, - ), - "val": Object({ - "String": Object({ - "str": String( - "2006-02-01", - ), - }), - }), - }), - }), }), }), - ]), - "strategy": String( - "r", - ), - "upperdatums": Array([ - Object({ - "PartitionRangeDatum": Object({ - "kind": Number( - 0, - ), - "location": Number( - 99, + }), + }), + ]), + "strategy": String( + "r", + ), + "upperdatums": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 99, + ), + "val": Object({ + "String": Object({ + "str": String( + "2006-03-01", ), - "value": Object({ - "A_Const": Object({ - "location": Number( - 99, - ), - "val": Object({ - "String": Object({ - "str": String( - "2006-03-01", - ), - }), - }), - }), - }), }), }), - ]), + }), }), - }), - ), - partspec: None, - of_typename: None, - constraints: [], - options: [], - oncommit: Noop, - tablespacename: None, - if_not_exists: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 112, - ), - }, - ), + ]), + }), + ), + partspec: None, + of_typename: None, + constraints: [], + options: [], + oncommit: Noop, + tablespacename: None, + if_not_exists: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 112, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap index 8dbd7191..15cdf5f9 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap @@ -4,169 +4,159 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateStmt( - CreateStmt { - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "example", - inh: true, - relpersistence: "p", - alias: None, - location: 14, + RawStmt { + stmt: CreateStmt( + CreateStmt { + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "example", + inh: true, + relpersistence: "p", + alias: None, + location: 14, + }, + table_elts: [ + ColumnDef( + ColumnDef { + colname: Some( + "a", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "int4", + }, + ), + ], + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 30, + }, + constraints: [], + is_local: true, + location: 28, }, ), - table_elts: [ - ColumnDef( - ColumnDef { - colname: Some( - "a", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "int4", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 30, - }, - ), - constraints: [], - is_local: true, - location: 28, + ColumnDef( + ColumnDef { + colname: Some( + "b", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "int4", + }, + ), + ], + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 45, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "b", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "int4", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 45, - }, - ), - constraints: [], - is_local: true, - location: 43, + constraints: [], + is_local: true, + location: 43, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "c", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "int4", + }, + ), + ], + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 60, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "c", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "int4", - }, + constraints: [], + is_local: true, + location: 58, + }, + ), + Constraint( + Constraint { + conname: None, + contype: Primary, + location: Some( + 73, + ), + raw_expr: None, + keys: Some( + Array([ + Object({ + "String": Object({ + "str": String( + "a", ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 60, - }, - ), - constraints: [], - is_local: true, - location: 58, - }, - ), - Constraint( - Constraint { - conname: None, - contype: Primary, - location: Some( - 73, - ), - raw_expr: None, - keys: Some( - Array([ - Object({ - "String": Object({ - "str": String( - "a", - ), - }), }), - Object({ - "String": Object({ - "str": String( - "c", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "c", + ), }), - ]), - ), - indexname: None, - skip_validation: false, - initially_valid: false, - }, - ), - ], - inh_relations: [], - partbound: None, - partspec: None, - of_typename: None, - constraints: [], - options: [], - oncommit: Noop, - tablespacename: None, - if_not_exists: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 93, - ), - }, - ), + }), + ]), + ), + indexname: None, + skip_validation: false, + initially_valid: false, + }, + ), + ], + inh_relations: [], + partbound: None, + partspec: None, + of_typename: None, + constraints: [], + options: [], + oncommit: Noop, + tablespacename: None, + if_not_exists: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 93, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap index c9de23f3..15ce3623 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap @@ -4,82 +4,78 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DeleteStmt( - Object({ - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 12, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), - "whereClause": Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "account_age", - ), - }), + RawStmt { + stmt: DeleteStmt( + Object({ + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 12, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), + }), + "whereClause": Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "account_age", + ), }), - ]), - "location": Number( - 31, + }), + ]), + "location": Number( + 31, + ), + }), + }), + "location": Number( + 43, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + ">", ), }), }), - "location": Number( - 43, - ), - "name": Array([ - Object({ - "String": Object({ - "str": String( - ">", + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 45, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 10, ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 45, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 10, - ), - }), - }), - }), }), }), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 47, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 47, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap index 5b7344b7..44d8bb0f 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap @@ -4,33 +4,29 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DeleteStmt( - Object({ - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 12, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), + RawStmt { + stmt: DeleteStmt( + Object({ + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 12, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 24, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 24, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap index d609d76b..20eaf76b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap @@ -4,109 +4,103 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ColumnDefault, - name: Some( - "value", - ), - def: Some( - FuncCall( - Object({ - "args": Array([ - Object({ - "TypeCast": Object({ - "arg": Object({ - "A_Const": Object({ - "location": Number( - 59, - ), - "val": Object({ - "String": Object({ - "str": String( - "f", - ), - }), + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: ColumnDefault, + name: Some( + "value", + ), + def: Some( + FuncCall( + Object({ + "args": Array([ + Object({ + "TypeCast": Object({ + "arg": Object({ + "A_Const": Object({ + "location": Number( + 59, + ), + "val": Object({ + "String": Object({ + "str": String( + "f", + ), }), }), }), + }), + "location": Number( + -1, + ), + "typeName": Object({ "location": Number( -1, ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - -1, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "bool", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), }), - }), - }), - }), - ]), - "funcname": Array([ - Object({ - "String": Object({ - "str": String( - "to_json", + Object({ + "String": Object({ + "str": String( + "bool", + ), + }), + }), + ]), + "typemod": Number( + -1, ), }), }), - ]), - "location": Number( - 51, - ), - }), - ), + }), + ]), + "funcname": Array([ + Object({ + "String": Object({ + "str": String( + "to_json", + ), + }), + }), + ]), + "location": Number( + 51, + ), + }), ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "foobar", - inh: true, - relpersistence: "p", - alias: None, - location: 13, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "foobar", + inh: true, + relpersistence: "p", + alias: None, + location: 13, }, - ), - stmt_location: 0, - stmt_len: Some( - 65, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 65, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap new file mode 100644 index 00000000..7e28571a --- /dev/null +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap @@ -0,0 +1,128 @@ +--- +source: parser/src/parse.rs +expression: res +--- +Ok( + [ + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: AddColumn, + name: None, + def: Some( + ColumnDef( + ColumnDef { + colname: Some( + "c", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "bool", + }, + ), + ], + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 34, + }, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: Generated, + location: Some( + 42, + ), + raw_expr: Some( + Object({ + "NullTest": Object({ + "arg": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "p", + ), + }), + }), + ]), + "location": Number( + 63, + ), + }), + }), + "location": Number( + 65, + ), + "nulltesttype": String( + "IS_NOT_NULL", + ), + }), + }), + ), + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, + ), + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 85, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, + ), + ], + is_local: true, + location: 32, + }, + ), + ), + behavior: Restrict, + missing_ok: false, + }, + ), + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_c", + inh: true, + relpersistence: "p", + alias: None, + location: 13, + }, + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 93, + ), + }, + ], +) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap index d28de728..39871473 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap @@ -4,111 +4,103 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: DropConstraint, - name: Some( - "tasks_fk", - ), - def: None, - behavior: Restrict, - missing_ok: false, - }, - ), - AlterTableCmd( - AlterTableCmd { - subtype: AddConstraint, - name: None, - def: Some( - Constraint( - Constraint { - conname: Some( - "tasks_fk", - ), - contype: Foreign, - location: Some( - 69, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: true, - initially_valid: false, - }, - ), + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: DropConstraint, + name: Some( + "tasks_fk", + ), + def: None, + behavior: Restrict, + missing_ok: false, + }, + ), + AlterTableCmd( + AlterTableCmd { + subtype: AddConstraint, + name: None, + def: Some( + Constraint( + Constraint { + conname: Some( + "tasks_fk", + ), + contype: Foreign, + location: Some( + 69, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: true, + initially_valid: false, + }, ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: Some( - "public", ), - relname: "tasks", - inh: false, - relpersistence: "p", - alias: None, - location: 18, + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: Some( + "public", + ), + relname: "tasks", + inh: false, + relpersistence: "p", + alias: None, + location: 18, }, - ), - stmt_location: 0, - stmt_len: Some( - 193, - ), - }, - ), - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ValidateConstraint, - name: Some( - "tasks_fk", - ), - def: None, - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: Some( - "public", + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 193, + ), + }, + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: ValidateConstraint, + name: Some( + "tasks_fk", ), - relname: "tasks", - inh: true, - relpersistence: "p", - alias: None, - location: 208, + def: None, + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: Some( + "public", + ), + relname: "tasks", + inh: true, + relpersistence: "p", + alias: None, + location: 208, }, - ), - stmt_location: 194, - stmt_len: Some( - 55, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 194, + stmt_len: Some( + 55, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap index 1df384fd..e27145a3 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap @@ -4,49 +4,45 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ReplicaIdentity, - name: None, - def: Some( - ReplicaIdentityStmt( - Object({ - "identity_type": String( - "f", - ), - }), - ), + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: ReplicaIdentity, + name: None, + def: Some( + ReplicaIdentityStmt( + Object({ + "identity_type": String( + "f", + ), + }), ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "aa", - inh: true, - relpersistence: "p", - alias: None, - location: 12, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "aa", + inh: true, + relpersistence: "p", + alias: None, + location: 12, }, - ), - stmt_location: 0, - stmt_len: Some( - 36, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 36, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap index ce6e0d11..a7d183f2 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap @@ -2,165 +2,8 @@ source: parser/src/parse.rs expression: res --- -Ok( - [ - RawStmt( - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: None, - from_clause: None, - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: Union, - all: true, - larg: Some( - SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 7, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 7, - ), - }), - }), - }), - }), - ], - ), - from_clause: Some( - Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 14, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - ), - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - ), - rarg: Some( - SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 44, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 44, - ), - }), - }), - }), - }), - ], - ), - from_clause: Some( - Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 51, - ), - "relname": String( - "table_foo", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - ), - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - ), - }, - ), - stmt_location: 0, - stmt_len: Some( - 62, - ), - }, - ), - ], +Err( + JsonParse( + "unknown variant `targetList`, expected `SelectStmt` at line 1 column 137", + ), ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap index 5a02350e..9e585cc0 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap @@ -2,165 +2,8 @@ source: parser/src/parse.rs expression: res --- -Ok( - [ - RawStmt( - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: None, - from_clause: None, - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: Union, - all: false, - larg: Some( - SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 7, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 7, - ), - }), - }), - }), - }), - ], - ), - from_clause: Some( - Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 14, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - ), - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - ), - rarg: Some( - SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 40, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 40, - ), - }), - }), - }), - }), - ], - ), - from_clause: Some( - Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 47, - ), - "relname": String( - "table_foo", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - ), - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - ), - }, - ), - stmt_location: 0, - stmt_len: Some( - 58, - ), - }, - ), - ], +Err( + JsonParse( + "unknown variant `targetList`, expected `SelectStmt` at line 1 column 126", + ), ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap index 7a501e27..475ca534 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap @@ -4,56 +4,52 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "table_name_idx", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "table_field", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 33, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "table_name_idx", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "table_field", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: false, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 33, }, - ), - stmt_location: 0, - stmt_len: Some( - 61, - ), - }, - ), + concurrent: false, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 61, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap index 73335434..1ff1348e 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap @@ -4,56 +4,52 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "table_name_idx", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "table_field", - ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 46, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "table_name_idx", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "table_field", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, }, ), - concurrent: true, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 46, }, - ), - stmt_location: 0, - stmt_len: Some( - 74, - ), - }, - ), + concurrent: true, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 74, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap index 1c9bd801..cea05cd8 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap @@ -4,60 +4,56 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: AddConstraint, - name: None, - def: Some( - Constraint( - Constraint { - conname: Some( - "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq", - ), - contype: Unique, - location: Some( - 47, - ), - raw_expr: None, - keys: None, - indexname: Some( - "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq_idx", - ), - skip_validation: false, - initially_valid: false, - }, - ), + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: AddConstraint, + name: None, + def: Some( + Constraint( + Constraint { + conname: Some( + "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq", + ), + contype: Unique, + location: Some( + 47, + ), + raw_expr: None, + keys: None, + indexname: Some( + "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq_idx", + ), + skip_validation: false, + initially_valid: false, + }, ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "legacy_questiongrouppg", - inh: true, - relpersistence: "p", - alias: None, - location: 13, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "legacy_questiongrouppg", + inh: true, + relpersistence: "p", + alias: None, + location: 13, }, - ), - stmt_location: 0, - stmt_len: Some( - 181, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 181, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap new file mode 100644 index 00000000..7273b74f --- /dev/null +++ b/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap @@ -0,0 +1,139 @@ +--- +source: parser/src/parse.rs +expression: res +--- +Ok( + Object({ + "stmts": Array([ + Object({ + "stmt": Object({ + "AlterTableStmt": Object({ + "cmds": Array([ + Object({ + "AlterTableCmd": Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "def": Object({ + "ColumnDef": Object({ + "colname": String( + "c", + ), + "constraints": Array([ + Object({ + "Constraint": Object({ + "contype": String( + "CONSTR_GENERATED", + ), + "generated_when": String( + "a", + ), + "location": Number( + 41, + ), + "raw_expr": Object({ + "NullTest": Object({ + "arg": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "p", + ), + }), + }), + ]), + "location": Number( + 62, + ), + }), + }), + "location": Number( + 64, + ), + "nulltesttype": String( + "IS_NOT_NULL", + ), + }), + }), + }), + }), + Object({ + "Constraint": Object({ + "contype": String( + "CONSTR_NOTNULL", + ), + "location": Number( + 84, + ), + }), + }), + ]), + "is_local": Bool( + true, + ), + "location": Number( + 31, + ), + "typeName": Object({ + "location": Number( + 33, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), + }), + Object({ + "String": Object({ + "str": String( + "bool", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), + }), + }), + }), + "subtype": String( + "AT_AddColumn", + ), + }), + }), + ]), + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 12, + ), + "relname": String( + "table_c", + ), + "relpersistence": String( + "p", + ), + }), + "relkind": String( + "OBJECT_TABLE", + ), + }), + }), + "stmt_len": Number( + 92, + ), + }), + ]), + "version": Number( + 130003, + ), + }), +) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap index c1721745..271f9f53 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap @@ -4,39 +4,35 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CopyStmt( - Object({ - "filename": String( - "/usr1/proj/bray/sql/country_data", - ), - "is_from": Bool( + RawStmt { + stmt: CopyStmt( + Object({ + "filename": String( + "/usr1/proj/bray/sql/country_data", + ), + "is_from": Bool( + true, + ), + "relation": Object({ + "inh": Bool( true, ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 5, - ), - "relname": String( - "country", - ), - "relpersistence": String( - "p", - ), - }), - }), + "location": Number( + 5, + ), + "relname": String( + "country", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 52, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 52, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap index 0151fc33..22fc3e7a 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap @@ -4,591 +4,561 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: TransactionStmt( - TransactionStmt { - kind: Begin, + RawStmt { + stmt: TransactionStmt( + TransactionStmt { + kind: Begin, + }, + ), + stmt_location: 0, + stmt_len: Some( + 6, + ), + }, + RawStmt { + stmt: CreateStmt( + CreateStmt { + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "core_foo", + inh: true, + relpersistence: "p", + alias: None, + location: 21, }, - ), - stmt_location: 0, - stmt_len: Some( - 6, - ), - }, - ), - RawStmt( - RawStmt { - stmt: CreateStmt( - CreateStmt { - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "core_foo", - inh: true, - relpersistence: "p", - alias: None, - location: 21, - }, - ), - table_elts: [ - ColumnDef( - ColumnDef { - colname: Some( - "id", + table_elts: [ + ColumnDef( + ColumnDef { + colname: Some( + "id", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "serial", + }, + ), + ], + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 41, + }, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 48, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "serial", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 41, + Constraint( + Constraint { + conname: None, + contype: Primary, + location: Some( + 57, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 48, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 36, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "created", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", }, ), - Constraint( - Constraint { - conname: None, - contype: Primary, - location: Some( - 57, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + String( + PGString { + str: "timestamptz", }, ), ], - is_local: true, - location: 36, + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 83, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "created", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "timestamptz", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 83, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 108, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 108, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 73, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "modified", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "timestamptz", }, ), ], - is_local: true, - location: 73, + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 132, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "modified", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "timestamptz", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 132, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 157, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 157, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 121, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "mongo_id", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "varchar", }, ), ], - is_local: true, - location: 121, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "mongo_id", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, + type_oid: None, + setof: false, + pct_type: false, + typmods: [ + Object({ + "A_Const": Object({ + "location": Number( + 189, ), - String( - PGString { - str: "varchar", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [ - Object({ - "A_Const": Object({ - "location": Number( - 189, + "val": Object({ + "Integer": Object({ + "ival": Number( + 255, ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 255, - ), - }), - }), }), }), - ], - typemod: -1, - array_bounds: [], - location: 181, + }), + }), + ], + typemod: -1, + array_bounds: [], + location: 181, + }, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 194, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 194, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, - }, - ), - Constraint( - Constraint { - conname: None, - contype: Unique, - location: Some( - 203, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + Constraint( + Constraint { + conname: None, + contype: Unique, + location: Some( + 203, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, + ), + ], + is_local: true, + location: 170, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "description", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "text", }, ), ], - is_local: true, - location: 170, + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 228, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "description", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "text", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 228, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 233, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 233, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 214, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "metadata", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "jsonb", }, ), ], - is_local: true, - location: 214, + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 257, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "metadata", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "jsonb", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 257, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 263, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 263, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 246, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "kind", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "varchar", }, ), ], - is_local: true, - location: 246, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "kind", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "varchar", - }, + type_oid: None, + setof: false, + pct_type: false, + typmods: [ + Object({ + "A_Const": Object({ + "location": Number( + 291, ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [ - Object({ - "A_Const": Object({ - "location": Number( - 291, + "val": Object({ + "Integer": Object({ + "ival": Number( + 255, ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 255, - ), - }), - }), }), }), - ], - typemod: -1, - array_bounds: [], - location: 283, - }, - ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 296, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, - }, - ), + }), + }), ], - is_local: true, - location: 276, + typemod: -1, + array_bounds: [], + location: 283, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "age", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "int4", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 315, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 296, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: NotNull, - location: Some( - 323, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 276, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "age", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "int4", }, ), ], - is_local: true, - location: 309, + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 315, }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "tenant_id", - ), - type_name: TypeName( - TypeName { - names: [ - String( - PGString { - str: "pg_catalog", - }, - ), - String( - PGString { - str: "int4", - }, - ), - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 348, + constraints: [ + Constraint( + Constraint { + conname: None, + contype: NotNull, + location: Some( + 323, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, }, ), - constraints: [ - Constraint( - Constraint { - conname: None, - contype: Null, - location: Some( - 356, - ), - raw_expr: None, - keys: None, - indexname: None, - skip_validation: false, - initially_valid: false, + ], + is_local: true, + location: 309, + }, + ), + ColumnDef( + ColumnDef { + colname: Some( + "tenant_id", + ), + type_name: TypeName { + names: [ + String( + PGString { + str: "pg_catalog", + }, + ), + String( + PGString { + str: "int4", }, ), ], - is_local: true, - location: 336, + type_oid: None, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 348, }, - ), - ], - inh_relations: [], - partbound: None, - partspec: None, - of_typename: None, - constraints: [], - options: [], - oncommit: Noop, - tablespacename: None, - if_not_exists: false, - }, - ), - stmt_location: 7, - stmt_len: Some( - 355, - ), - }, - ), - RawStmt( - RawStmt { - stmt: IndexStmt( - IndexStmt { - access_method: "btree", - idxname: Some( - "age_index", - ), - index_params: [ - IndexElem( - IndexElem { - name: Some( - "age", + constraints: [ + Constraint( + Constraint { + conname: None, + contype: Null, + location: Some( + 356, + ), + raw_expr: None, + keys: None, + indexname: None, + skip_validation: false, + initially_valid: false, + }, ), - expr: None, - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "core_foo", - inh: true, - relpersistence: "p", - alias: None, - location: 392, + ], + is_local: true, + location: 336, }, ), - concurrent: false, - unique: false, - primary: false, - isconstraint: false, - deferrable: false, - initdeferred: false, - transformed: false, - if_not_exists: false, - table_space: None, - }, - ), - stmt_location: 363, - stmt_len: Some( - 47, - ), - }, - ), - RawStmt( - RawStmt { - stmt: TransactionStmt( - TransactionStmt { - kind: Commit, + ], + inh_relations: [], + partbound: None, + partspec: None, + of_typename: None, + constraints: [], + options: [], + oncommit: Noop, + tablespacename: None, + if_not_exists: false, + }, + ), + stmt_location: 7, + stmt_len: Some( + 355, + ), + }, + RawStmt { + stmt: IndexStmt( + IndexStmt { + access_method: "btree", + idxname: Some( + "age_index", + ), + index_params: [ + IndexElem( + IndexElem { + name: Some( + "age", + ), + expr: None, + indexcolname: None, + collation: None, + opclass: [], + ordering: Default, + nulls_ordering: Default, + }, + ), + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "core_foo", + inh: true, + relpersistence: "p", + alias: None, + location: 392, }, - ), - stmt_location: 411, - stmt_len: Some( - 7, - ), - }, - ), + concurrent: false, + unique: false, + primary: false, + isconstraint: false, + deferrable: false, + initdeferred: false, + transformed: false, + if_not_exists: false, + table_space: None, + }, + ), + stmt_location: 363, + stmt_len: Some( + 47, + ), + }, + RawStmt { + stmt: TransactionStmt( + TransactionStmt { + kind: Commit, + }, + ), + stmt_location: 411, + stmt_len: Some( + 7, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap index fbc5c4b4..8f1313f2 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap @@ -4,23 +4,21 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: CreateTableSpaceStmt( - Object({ - "location": String( - "/data/dbs", - ), - "tablespacename": String( - "dbspace", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 46, - ), - }, - ), + RawStmt { + stmt: CreateTableSpaceStmt( + Object({ + "location": String( + "/data/dbs", + ), + "tablespacename": String( + "dbspace", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 46, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap index 1e3c0ded..9a7e6e6d 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: DropTableSpaceStmt( - Object({ - "tablespacename": String( - "dbspace", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ), + RawStmt { + stmt: DropTableSpaceStmt( + Object({ + "tablespacename": String( + "dbspace", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 23, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap index 082fd612..a65327ff 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap @@ -4,47 +4,45 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: GrantRoleStmt( - Object({ - "behavior": Number( - 0, - ), - "granted_roles": Array([ - Object({ - "AccessPriv": Object({ - "priv_name": String( - "admins", - ), - }), + RawStmt { + stmt: GrantRoleStmt( + Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "granted_roles": Array([ + Object({ + "AccessPriv": Object({ + "priv_name": String( + "admins", + ), }), - ]), - "grantee_roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 16, - ), - "rolename": String( - "joe", - ), - "roletype": Number( - 0, - ), - }), + }), + ]), + "grantee_roles": Array([ + Object({ + "RoleSpec": Object({ + "location": Number( + 16, + ), + "rolename": String( + "joe", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), }), - ]), - "is_grant": Bool( - true, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 19, - ), - }, - ), + }), + ]), + "is_grant": Bool( + true, + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 19, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap index 4a59a0ab..5c9a4255 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap @@ -4,68 +4,66 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: GrantStmt( - Object({ - "behavior": Number( - 0, - ), - "grantees": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 25, - ), - "roletype": Number( - 3, - ), - }), + RawStmt { + stmt: GrantStmt( + Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "grantees": Array([ + Object({ + "RoleSpec": Object({ + "location": Number( + 25, + ), + "roletype": String( + "ROLESPEC_PUBLIC", + ), }), - ]), - "is_grant": Bool( - true, - ), - "objects": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 16, - ), - "relname": String( - "films", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + "is_grant": Bool( + true, + ), + "objects": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 16, + ), + "relname": String( + "films", + ), + "relpersistence": String( + "p", + ), }), - ]), - "objtype": Number( - 1, - ), - "privileges": Array([ - Object({ - "AccessPriv": Object({ - "priv_name": String( - "insert", - ), - }), + }), + ]), + "objtype": String( + "OBJECT_TABLE", + ), + "privileges": Array([ + Object({ + "AccessPriv": Object({ + "priv_name": String( + "insert", + ), }), - ]), - "targtype": Number( - 0, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 31, - ), - }, - ), + }), + ]), + "targtype": String( + "ACL_TARGET_OBJECT", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 31, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap index edfe4791..8116c7e9 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap @@ -4,89 +4,92 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: InsertStmt( - Object({ - "override": Number( - 0, + RawStmt { + stmt: InsertStmt( + Object({ + "override": String( + "OVERRIDING_NOT_SET", + ), + "relation": Object({ + "inh": Bool( + true, ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 12, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), - "selectStmt": Object({ - "SelectStmt": Object({ - "op": Number( - 0, - ), - "valuesLists": Array([ - Array([ - Object({ - "A_Const": Object({ - "location": Number( - 31, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), + "location": Number( + 12, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), + }), + "selectStmt": Object({ + "SelectStmt": Object({ + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "valuesLists": Array([ + Object({ + "List": Object({ + "items": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 31, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), + }), }), }), }), - }), - Object({ - "A_Const": Object({ - "location": Number( - 34, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 2, - ), + Object({ + "A_Const": Object({ + "location": Number( + 34, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 2, + ), + }), }), }), }), - }), - Object({ - "A_Const": Object({ - "location": Number( - 37, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 3, - ), + Object({ + "A_Const": Object({ + "location": Number( + 37, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 3, + ), + }), }), }), }), - }), - ]), - ]), - }), + ]), + }), + }), + ]), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 39, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap index 764509e7..488877ff 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap @@ -4,108 +4,104 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: UpdateStmt( - Object({ - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), + RawStmt { + stmt: UpdateStmt( + Object({ + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 7, + ), + "relname": String( + "table_name", + ), + "relpersistence": String( + "p", + ), + }), + "targetList": Array([ + Object({ + "ResTarget": Object({ "location": Number( - 7, - ), - "relname": String( - "table_name", + 22, ), - "relpersistence": String( - "p", + "name": String( + "foo", ), - }), - }), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 22, - ), - "name": String( - "foo", - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 28, - ), - "val": Object({ - "String": Object({ - "str": String( - "bar", - ), - }), + "val": Object({ + "A_Const": Object({ + "location": Number( + 28, + ), + "val": Object({ + "String": Object({ + "str": String( + "bar", + ), }), }), }), }), }), - ]), - "whereClause": Object({ - "A_Expr": Object({ - "kind": Number( - 0, - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "str": String( - "buzz", - ), - }), + }), + ]), + "whereClause": Object({ + "A_Expr": Object({ + "kind": String( + "AEXPR_OP", + ), + "lexpr": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "String": Object({ + "str": String( + "buzz", + ), }), - ]), - "location": Number( - 40, + }), + ]), + "location": Number( + 40, + ), + }), + }), + "location": Number( + 45, + ), + "name": Array([ + Object({ + "String": Object({ + "str": String( + ">", ), }), }), - "location": Number( - 45, - ), - "name": Array([ - Object({ - "String": Object({ - "str": String( - ">", + ]), + "rexpr": Object({ + "A_Const": Object({ + "location": Number( + 47, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 10, ), }), }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 47, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 10, - ), - }), - }), - }), }), }), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 49, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap index 96487794..2897bc34 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap @@ -4,39 +4,37 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: VariableSetStmt( - Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 25, - ), - "val": Object({ - "String": Object({ - "str": String( - "1", - ), - }), + RawStmt { + stmt: VariableSetStmt( + Object({ + "args": Array([ + Object({ + "A_Const": Object({ + "location": Number( + 25, + ), + "val": Object({ + "String": Object({ + "str": String( + "1", + ), }), }), }), - ]), - "kind": Number( - 0, - ), - "name": String( - "my.vars.id", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 28, - ), - }, - ), + }), + ]), + "kind": String( + "VAR_SET_VALUE", + ), + "name": String( + "my.vars.id", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 28, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap index 44525b94..4f70b669 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap @@ -4,18 +4,16 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: VariableShowStmt( - Object({ - "name": String( - "name", - ), - }), - ), - stmt_location: 0, - stmt_len: None, - }, - ), + RawStmt { + stmt: VariableShowStmt( + Object({ + "name": String( + "name", + ), + }), + ), + stmt_location: 0, + stmt_len: None, + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap index 45c8a177..ee1e2357 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap @@ -4,186 +4,189 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: PrepareStmt( - Object({ - "argtypes": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 18, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + RawStmt { + stmt: PrepareStmt( + Object({ + "argtypes": Array([ + Object({ + "TypeName": Object({ + "location": Number( + 18, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - Object({ - "String": Object({ - "str": String( - "int4", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "int4", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "TypeName": Object({ - "location": Number( - 23, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "text", - ), - }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 23, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "text", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "TypeName": Object({ - "location": Number( - 29, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "bool", - ), - }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 29, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "bool", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - Object({ - "TypeName": Object({ - "location": Number( - 35, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), + }), + Object({ + "TypeName": Object({ + "location": Number( + 35, + ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), }), - Object({ - "String": Object({ - "str": String( - "numeric", - ), - }), + }), + Object({ + "String": Object({ + "str": String( + "numeric", + ), }), - ]), - "typemod": Number( - -1, - ), - }), + }), + ]), + "typemod": Number( + -1, + ), }), - ]), - "name": String( - "fooplan", - ), - "query": Object({ - "InsertStmt": Object({ - "override": Number( - 0, + }), + ]), + "name": String( + "fooplan", + ), + "query": Object({ + "InsertStmt": Object({ + "override": String( + "OVERRIDING_NOT_SET", + ), + "relation": Object({ + "inh": Bool( + true, ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 63, - ), - "relname": String( - "foo", - ), - "relpersistence": String( - "p", - ), - }), - }), - "selectStmt": Object({ - "SelectStmt": Object({ - "op": Number( - 0, - ), - "valuesLists": Array([ - Array([ - Object({ - "ParamRef": Object({ - "location": Number( - 74, - ), - "number": Number( - 1, - ), + "location": Number( + 63, + ), + "relname": String( + "foo", + ), + "relpersistence": String( + "p", + ), + }), + "selectStmt": Object({ + "SelectStmt": Object({ + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "valuesLists": Array([ + Object({ + "List": Object({ + "items": Array([ + Object({ + "ParamRef": Object({ + "location": Number( + 74, + ), + "number": Number( + 1, + ), + }), }), - }), - Object({ - "ParamRef": Object({ - "location": Number( - 78, - ), - "number": Number( - 2, - ), + Object({ + "ParamRef": Object({ + "location": Number( + 78, + ), + "number": Number( + 2, + ), + }), }), - }), - Object({ - "ParamRef": Object({ - "location": Number( - 82, - ), - "number": Number( - 3, - ), + Object({ + "ParamRef": Object({ + "location": Number( + 82, + ), + "number": Number( + 3, + ), + }), }), - }), - Object({ - "ParamRef": Object({ - "location": Number( - 86, - ), - "number": Number( - 4, - ), + Object({ + "ParamRef": Object({ + "location": Number( + 86, + ), + "number": Number( + 4, + ), + }), }), - }), - ]), - ]), - }), + ]), + }), + }), + ]), }), }), }), }), - ), - stmt_location: 0, - stmt_len: Some( - 89, - ), - }, - ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 89, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap index 7354f4de..49fd7ee5 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap @@ -4,45 +4,41 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ReassignOwnedStmt( - Object({ - "newrole": Object({ + RawStmt { + stmt: ReassignOwnedStmt( + Object({ + "newrole": Object({ + "location": Number( + 31, + ), + "rolename": String( + "new_role", + ), + "roletype": String( + "ROLESPEC_CSTRING", + ), + }), + "roles": Array([ + Object({ "RoleSpec": Object({ "location": Number( - 31, + 19, ), "rolename": String( - "new_role", + "old_role", ), - "roletype": Number( - 0, + "roletype": String( + "ROLESPEC_CSTRING", ), }), }), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 19, - ), - "rolename": String( - "old_role", - ), - "roletype": Number( - 0, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 39, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap index e9ebcdbb..b547d0bb 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap @@ -4,64 +4,56 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RefreshMatViewStmt( - Object({ - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 27, - ), - "relname": String( - "order_summary", - ), - "relpersistence": String( - "p", - ), - }), - }), + RawStmt { + stmt: RefreshMatViewStmt( + Object({ + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 27, + ), + "relname": String( + "order_summary", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 0, - stmt_len: Some( - 40, - ), - }, - ), - RawStmt( - RawStmt { - stmt: RefreshMatViewStmt( - Object({ - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 68, - ), - "relname": String( - "annual_statistics_basis", - ), - "relpersistence": String( - "p", - ), - }), - }), - "skipData": Bool( + }), + ), + stmt_location: 0, + stmt_len: Some( + 40, + ), + }, + RawStmt { + stmt: RefreshMatViewStmt( + Object({ + "relation": Object({ + "inh": Bool( true, ), + "location": Number( + 68, + ), + "relname": String( + "annual_statistics_basis", + ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 41, - stmt_len: Some( - 63, - ), - }, - ), + "skipData": Bool( + true, + ), + }), + ), + stmt_location: 41, + stmt_len: Some( + 63, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap b/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap index 3fc3718c..8e8fa0b9 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap @@ -4,91 +4,85 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ColumnDefault, - name: Some( - "column_name", - ), - def: Some( - TypeCast( - Object({ - "arg": Object({ - "A_Const": Object({ - "location": Number( - 73, - ), - "val": Object({ - "String": Object({ - "str": String( - "f", - ), - }), + RawStmt { + stmt: AlterTableStmt( + AlterTableStmt { + cmds: [ + AlterTableCmd( + AlterTableCmd { + subtype: ColumnDefault, + name: Some( + "column_name", + ), + def: Some( + TypeCast( + Object({ + "arg": Object({ + "A_Const": Object({ + "location": Number( + 73, + ), + "val": Object({ + "String": Object({ + "str": String( + "f", + ), }), }), }), + }), + "location": Number( + -1, + ), + "typeName": Object({ "location": Number( -1, ), - "typeName": Object({ - "TypeName": Object({ - "location": Number( - -1, - ), - "names": Array([ - Object({ - "String": Object({ - "str": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "str": String( - "bool", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), + "names": Array([ + Object({ + "String": Object({ + "str": String( + "pg_catalog", + ), + }), }), - }), + Object({ + "String": Object({ + "str": String( + "bool", + ), + }), + }), + ]), + "typemod": Number( + -1, + ), }), - ), + }), ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar( - RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 21, + ), + behavior: Restrict, + missing_ok: false, }, ), - relkind: Table, - missing_ok: false, + ], + relation: RangeVar { + catalogname: None, + schemaname: None, + relname: "table_name", + inh: true, + relpersistence: "p", + alias: None, + location: 21, }, - ), - stmt_location: 0, - stmt_len: Some( - 78, - ), - }, - ), + relkind: Table, + missing_ok: false, + }, + ), + stmt_location: 0, + stmt_len: Some( + 78, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap index 35df7b26..41321ce3 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap @@ -4,103 +4,91 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ReindexStmt( - Object({ - "kind": Number( - 0, + RawStmt { + stmt: ReindexStmt( + Object({ + "kind": String( + "REINDEX_OBJECT_INDEX", + ), + "relation": Object({ + "inh": Bool( + true, ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 15, - ), - "relname": String( - "my_index", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ReindexStmt( - Object({ - "kind": Number( - 1, + "location": Number( + 15, ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 39, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - ), - stmt_location: 24, - stmt_len: Some( - 25, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ReindexStmt( - Object({ - "kind": Number( - 4, + "relname": String( + "my_index", ), - "name": String( - "table_name", + "relpersistence": String( + "p", ), }), - ), - stmt_location: 50, - stmt_len: Some( - 28, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ReindexStmt( - Object({ - "kind": Number( - 3, + }), + ), + stmt_location: 0, + stmt_len: Some( + 23, + ), + }, + RawStmt { + stmt: ReindexStmt( + Object({ + "kind": String( + "REINDEX_OBJECT_TABLE", + ), + "relation": Object({ + "inh": Bool( + true, ), - "name": String( + "location": Number( + 39, + ), + "relname": String( "table_name", ), + "relpersistence": String( + "p", + ), }), - ), - stmt_location: 79, - stmt_len: Some( - 26, - ), - }, - ), + }), + ), + stmt_location: 24, + stmt_len: Some( + 25, + ), + }, + RawStmt { + stmt: ReindexStmt( + Object({ + "kind": String( + "REINDEX_OBJECT_DATABASE", + ), + "name": String( + "table_name", + ), + }), + ), + stmt_location: 50, + stmt_len: Some( + 28, + ), + }, + RawStmt { + stmt: ReindexStmt( + Object({ + "kind": String( + "REINDEX_OBJECT_SYSTEM", + ), + "name": String( + "table_name", + ), + }), + ), + stmt_location: 79, + stmt_len: Some( + 26, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap index 450c078f..f442ba2c 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap @@ -4,133 +4,128 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: RuleStmt( - Object({ - "actions": Array([ - Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 83, - ), - "relname": String( - "t2", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: RuleStmt( + Object({ + "actions": Array([ + Object({ + "SelectStmt": Object({ + "fromClause": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 83, + ), + "relname": String( + "t2", + ), + "relpersistence": String( + "p", + ), }), - ]), - "op": Number( - 0, - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 76, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 76, - ), - }), + }), + ]), + "limitOption": String( + "LIMIT_OPTION_DEFAULT", + ), + "op": String( + "SETOP_NONE", + ), + "targetList": Array([ + Object({ + "ResTarget": Object({ + "location": Number( + 76, + ), + "val": Object({ + "ColumnRef": Object({ + "fields": Array([ + Object({ + "A_Star": Object({}), + }), + ]), + "location": Number( + 76, + ), }), }), }), - ]), - }), + }), + ]), }), - ]), - "event": Number( - 1, - ), - "instead": Bool( + }), + ]), + "event": String( + "CMD_SELECT", + ), + "instead": Bool( + true, + ), + "relation": Object({ + "inh": Bool( true, ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 43, - ), - "relname": String( - "t1", - ), - "relpersistence": String( - "p", - ), - }), - }), - "rulename": String( - "_RETURN", + "location": Number( + 43, ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 85, - ), - }, - ), - RawStmt( - RawStmt { - stmt: RuleStmt( - Object({ - "actions": Array([ - Object({ - "NotifyStmt": Object({ - "conditionname": String( - "mytable", - ), - }), - }), - ]), - "event": Number( - 2, + "relname": String( + "t1", ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 126, - ), - "relname": String( + "relpersistence": String( + "p", + ), + }), + "rulename": String( + "_RETURN", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 85, + ), + }, + RawStmt { + stmt: RuleStmt( + Object({ + "actions": Array([ + Object({ + "NotifyStmt": Object({ + "conditionname": String( "mytable", ), - "relpersistence": String( - "p", - ), }), }), - "rulename": String( - "notify_me", + ]), + "event": String( + "CMD_UPDATE", + ), + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 126, + ), + "relname": String( + "mytable", + ), + "relpersistence": String( + "p", ), }), - ), - stmt_location: 86, - stmt_len: Some( - 70, - ), - }, - ), + "rulename": String( + "notify_me", + ), + }), + ), + stmt_location: 86, + stmt_len: Some( + 70, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap index 8d1865b4..dcfa9065 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap @@ -4,35 +4,37 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: SecLabelStmt( - Object({ - "label": String( - "system_u:object_r:sepgsql_table_t:s0", - ), - "object": Array([ - Object({ - "String": Object({ - "str": String( - "mytable", - ), + RawStmt { + stmt: SecLabelStmt( + Object({ + "label": String( + "system_u:object_r:sepgsql_table_t:s0", + ), + "object": Object({ + "List": Object({ + "items": Array([ + Object({ + "String": Object({ + "str": String( + "mytable", + ), + }), }), - }), - ]), - "objtype": Number( - 37, - ), - "provider": String( - "selinux", - ), + ]), + }), }), - ), - stmt_location: 0, - stmt_len: Some( - 86, - ), - }, - ), + "objtype": String( + "OBJECT_TABLE", + ), + "provider": String( + "selinux", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 86, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap b/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap index 5e1de706..ef3144ad 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap @@ -4,59 +4,57 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 7, - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 7, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + RawStmt { + stmt: SelectStmt( + SelectStmt { + distinct_clause: None, + into_clause: None, + target_list: Some( + [ + Object({ + "ResTarget": Object({ + "location": Number( + 7, + ), + "val": Object({ + "A_Const": Object({ + "location": Number( + 7, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), }), }), }), }), - ], - ), - from_clause: None, - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 8, - ), - }, - ), + }), + ], + ), + from_clause: None, + where_clause: None, + group_clause: None, + having_clause: None, + window_clause: None, + values_lists: None, + sort_clause: None, + limit_offset: None, + limit_count: None, + locking_clause: None, + with_clause: None, + op: None, + all: false, + larg: None, + rarg: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 8, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap b/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap index 99073c1f..8a230941 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap @@ -4,59 +4,57 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 7, - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 7, - ), - "val": Object({ - "String": Object({ - "str": String( - "some string", - ), - }), + RawStmt { + stmt: SelectStmt( + SelectStmt { + distinct_clause: None, + into_clause: None, + target_list: Some( + [ + Object({ + "ResTarget": Object({ + "location": Number( + 7, + ), + "val": Object({ + "A_Const": Object({ + "location": Number( + 7, + ), + "val": Object({ + "String": Object({ + "str": String( + "some string", + ), }), }), }), }), }), - ], - ), - from_clause: None, - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 20, - ), - }, - ), + }), + ], + ), + from_clause: None, + where_clause: None, + group_clause: None, + having_clause: None, + window_clause: None, + values_lists: None, + sort_clause: None, + limit_offset: None, + limit_count: None, + locking_clause: None, + with_clause: None, + op: None, + all: false, + larg: None, + rarg: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 20, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap b/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap index 8003ec96..d2e42b24 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap @@ -4,61 +4,55 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: ConstraintsSetStmt( - Object({ - "deferred": Bool( - true, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 29, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ConstraintsSetStmt( - Object({}), - ), - stmt_location: 30, - stmt_len: Some( - 30, - ), - }, - ), - RawStmt( - RawStmt { - stmt: ConstraintsSetStmt( - Object({ - "constraints": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 78, - ), - "relname": String( - "foo", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: ConstraintsSetStmt( + Object({ + "deferred": Bool( + true, + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 29, + ), + }, + RawStmt { + stmt: ConstraintsSetStmt( + Object({}), + ), + stmt_location: 30, + stmt_len: Some( + 30, + ), + }, + RawStmt { + stmt: ConstraintsSetStmt( + Object({ + "constraints": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 78, + ), + "relname": String( + "foo", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 61, - stmt_len: Some( - 30, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 61, + stmt_len: Some( + 30, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap b/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap index c33b3108..39150876 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap @@ -4,59 +4,57 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 10, - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 10, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + RawStmt { + stmt: SelectStmt( + SelectStmt { + distinct_clause: None, + into_clause: None, + target_list: Some( + [ + Object({ + "ResTarget": Object({ + "location": Number( + 10, + ), + "val": Object({ + "A_Const": Object({ + "location": Number( + 10, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), }), }), }), }), - ], - ), - from_clause: None, - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 11, - ), - }, - ), + }), + ], + ), + from_clause: None, + where_clause: None, + group_clause: None, + having_clause: None, + window_clause: None, + values_lists: None, + sort_clause: None, + limit_offset: None, + limit_count: None, + locking_clause: None, + with_clause: None, + op: None, + all: false, + larg: None, + rarg: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 11, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap b/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap index 27915143..df0ae23b 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap @@ -4,59 +4,57 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 12, - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 12, - ), - "val": Object({ - "Integer": Object({ - "ival": Number( - 1, - ), - }), + RawStmt { + stmt: SelectStmt( + SelectStmt { + distinct_clause: None, + into_clause: None, + target_list: Some( + [ + Object({ + "ResTarget": Object({ + "location": Number( + 12, + ), + "val": Object({ + "A_Const": Object({ + "location": Number( + 12, + ), + "val": Object({ + "Integer": Object({ + "ival": Number( + 1, + ), }), }), }), }), }), - ], - ), - from_clause: None, - where_clause: None, - group_clause: None, - having_clause: None, - window_clause: None, - values_lists: None, - sort_clause: None, - limit_offset: None, - limit_count: None, - locking_clause: None, - with_clause: None, - op: None, - all: false, - larg: None, - rarg: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 13, - ), - }, - ), + }), + ], + ), + from_clause: None, + where_clause: None, + group_clause: None, + having_clause: None, + window_clause: None, + values_lists: None, + sort_clause: None, + limit_offset: None, + limit_count: None, + locking_clause: None, + with_clause: None, + op: None, + all: false, + larg: None, + rarg: None, + }, + ), + stmt_location: 0, + stmt_len: Some( + 13, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap index d7cc30b7..3a732ec0 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap @@ -4,106 +4,102 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: TruncateStmt( - Object({ - "behavior": Number( - 0, - ), - "relations": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 10, - ), - "relname": String( - "bigtable", - ), - "relpersistence": String( - "p", - ), - }), + RawStmt { + stmt: TruncateStmt( + Object({ + "behavior": String( + "DROP_RESTRICT", + ), + "relations": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 10, + ), + "relname": String( + "bigtable", + ), + "relpersistence": String( + "p", + ), }), - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 20, - ), - "relname": String( - "fattable", - ), - "relpersistence": String( - "p", - ), - }), + }), + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 20, + ), + "relname": String( + "fattable", + ), + "relpersistence": String( + "p", + ), }), - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 30, - ), - "relname": String( - "bar", - ), - "relpersistence": String( - "p", - ), - }), + }), + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 30, + ), + "relname": String( + "bar", + ), + "relpersistence": String( + "p", + ), }), - ]), - "restart_seqs": Bool( - true, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 50, - ), - }, - ), - RawStmt( - RawStmt { - stmt: TruncateStmt( - Object({ - "behavior": Number( - 1, - ), - "relations": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 61, - ), - "relname": String( - "foo", - ), - "relpersistence": String( - "p", - ), - }), + }), + ]), + "restart_seqs": Bool( + true, + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 50, + ), + }, + RawStmt { + stmt: TruncateStmt( + Object({ + "behavior": String( + "DROP_CASCADE", + ), + "relations": Array([ + Object({ + "RangeVar": Object({ + "inh": Bool( + true, + ), + "location": Number( + 61, + ), + "relname": String( + "foo", + ), + "relpersistence": String( + "p", + ), }), - ]), - }), - ), - stmt_location: 51, - stmt_len: Some( - 21, - ), - }, - ), + }), + ]), + }), + ), + stmt_location: 51, + stmt_len: Some( + 21, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap index da07264e..5466da79 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap @@ -4,20 +4,18 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: UnlistenStmt( - Object({ - "conditionname": String( - "virtual", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 17, - ), - }, - ), + RawStmt { + stmt: UnlistenStmt( + Object({ + "conditionname": String( + "virtual", + ), + }), + ), + stmt_location: 0, + stmt_len: Some( + 17, + ), + }, ], ) diff --git a/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap b/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap index 3b017dba..5ef53d51 100644 --- a/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap +++ b/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap @@ -4,36 +4,66 @@ expression: res --- Ok( [ - RawStmt( - RawStmt { - stmt: VacuumStmt( - Object({ - "options": Number( - 7, - ), - "relation": Object({ - "RangeVar": Object({ - "inh": Bool( - true, + RawStmt { + stmt: VacuumStmt( + Object({ + "is_vacuumcmd": Bool( + true, + ), + "options": Array([ + Object({ + "DefElem": Object({ + "defaction": String( + "DEFELEM_UNSPEC", + ), + "defname": String( + "verbose", ), "location": Number( - 27, + 9, ), - "relname": String( - "foo", + }), + }), + Object({ + "DefElem": Object({ + "defaction": String( + "DEFELEM_UNSPEC", ), - "relpersistence": String( - "p", + "defname": String( + "analyze", ), + "location": Number( + 18, + ), + }), + }), + ]), + "rels": Array([ + Object({ + "VacuumRelation": Object({ + "relation": Object({ + "inh": Bool( + true, + ), + "location": Number( + 27, + ), + "relname": String( + "foo", + ), + "relpersistence": String( + "p", + ), + }), }), }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 30, - ), - }, - ), + ]), + }), + ), + stmt_location: 0, + stmt_len: Some( + 30, + ), + }, ], ) diff --git a/s/update-version b/s/update-version index 7e84040c..ad717572 100755 --- a/s/update-version +++ b/s/update-version @@ -6,8 +6,8 @@ function main { NEW_VERSION="$1" echo "updating version to '$NEW_VERSION'..." - fastmod '^version = ".*"' 'version = "'$NEW_VERSION'"' -g 'Cargo.toml' - fastmod '"version": ".*"' '"version": "'$NEW_VERSION'"' -g 'package.json' + fastmod '^version = ".*"' 'version = "'$NEW_VERSION'"' cli/Cargo.toml + fastmod '"version": ".*"' '"version": "'$NEW_VERSION'"' package.json }