From aa715624d739d1960982d198c8b71361829e04a8 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Mon, 5 May 2025 23:25:39 -0400 Subject: [PATCH] v2: remove v1 parser & linter --- Cargo.lock | 76 +- crates/linter/Cargo.toml | 22 - crates/linter/README.md | 4 - crates/linter/src/errors.rs | 20 - crates/linter/src/lib.rs | 484 --- crates/linter/src/rules/README.md | 25 - .../src/rules/adding_field_with_default.rs | 266 -- .../rules/adding_foreign_key_constraint.rs | 150 - .../linter/src/rules/adding_not_null_field.rs | 79 - .../rules/adding_primary_key_constraint.rs | 103 - .../linter/src/rules/adding_required_field.rs | 116 - .../ban_alter_domain_with_add_constraint.rs | 71 - crates/linter/src/rules/ban_char_field.rs | 80 - ...oncurrent_index_creation_in_transaction.rs | 122 - .../ban_create_domain_with_constraint.rs | 64 - crates/linter/src/rules/ban_drop_column.rs | 55 - crates/linter/src/rules/ban_drop_database.rs | 52 - crates/linter/src/rules/ban_drop_not_null.rs | 51 - crates/linter/src/rules/ban_drop_table.rs | 51 - .../linter/src/rules/changing_column_type.rs | 70 - .../src/rules/constraint_missing_not_valid.rs | 282 -- .../src/rules/disallow_unique_constraint.rs | 172 - crates/linter/src/rules/mod.rs | 58 - .../rules/non_volatile_built_in_functions.txt | 2963 ----------------- crates/linter/src/rules/prefer_big_int.rs | 140 - .../src/rules/prefer_bigint_over_int.rs | 121 - .../src/rules/prefer_bigint_over_smallint.rs | 127 - crates/linter/src/rules/prefer_identity.rs | 117 - .../linter/src/rules/prefer_robust_stmts.rs | 486 --- crates/linter/src/rules/prefer_text_field.rs | 157 - crates/linter/src/rules/prefer_timestamptz.rs | 111 - crates/linter/src/rules/renaming_column.rs | 53 - crates/linter/src/rules/renaming_table.rs | 53 - .../require_concurrent_index_creation.rs | 112 - .../require_concurrent_index_deletion.rs | 88 - ...h_default__test_rules__add_numbers_ok.snap | 23 - ...est_rules__default_arbitrary_func_err.snap | 23 - ..._default__test_rules__default_bool_ok.snap | 5 - ..._default__test_rules__default_enum_ok.snap | 5 - ...fault__test_rules__default_integer_ok.snap | 5 - ...default__test_rules__default_jsonb_ok.snap | 5 - ...ault__test_rules__default_now_func_ok.snap | 5 - ...t_rules__default_random_with_args_err.snap | 23 - ...h_default__test_rules__default_str_ok.snap | 5 - ...default__test_rules__default_uuid_err.snap | 23 - ...test_rules__default_volatile_func_err.snap | 23 - ...default__test_rules__docs_example_bad.snap | 23 - ..._default__test_rules__docs_example_ok.snap | 5 - ...default__test_rules__generated_stored.snap | 23 - ...es__adding_field_that_is_not_nullable.snap | 5 - ...ld_that_is_not_nullable_in_version_11.snap | 5 - ..._that_is_not_nullable_without_default.snap | 5 - ..._null_field__test_rules__set_not_null.snap | 23 - ...aint__test_rules__plain_primary_key-2.snap | 5 - ...traint__test_rules__plain_primary_key.snap | 23 - ...raint__test_rules__serial_primary_key.snap | 23 - ...d_field__test_rules__generated_stored.snap | 5 - ...test_rules__generated_stored_not_null.snap | 5 - ...ld__test_rules__not_null_with_default.snap | 5 - ..._test_rules__not_null_without_default.snap | 23 - ..._required_field__test_rules__nullable.snap | 5 - ...lter_domain_with_add_constraint_works.snap | 21 - ...ules__creating_table_with_char_errors.snap | 54 - ...ing_table_with_var_char_and_text_okay.snap | 5 - ...g_index_concurrently_in_transaction-2.snap | 5 - ...ing_index_concurrently_in_transaction.snap | 23 - ...nsaction_with_assume_in_transaction-2.snap | 5 - ...ransaction_with_assume_in_transaction.snap | 23 - ...ith_assume_in_transaction_but_outside.snap | 5 - ...n_create_domain_with_constraint_works.snap | 21 - ..._drop_column__test_rules__drop_column.snap | 20 - ...tabase__test_rules__ban_drop_database.snap | 46 - ...t_null__test_rules__ban_drop_not_null.snap | 20 - ...rop_table__test_rules__ban_drop_table.snap | 46 - ...pe__test_rules__changing_field_type-2.snap | 40 - ...type__test_rules__changing_field_type.snap | 23 - ...test_rules__adding_check_constraint-2.snap | 5 - ...__test_rules__adding_check_constraint.snap | 23 - ...lid__test_rules__adding_foreign_key-2.snap | 5 - ...valid__test_rules__adding_foreign_key.snap | 23 - ..._rules__ensure_ignored_when_new_table.snap | 5 - ..._new_table_with_assume_in_transaction.snap | 5 - ...es__not_valid_validate_in_transaction.snap | 12 - ...d_validate_with_assume_in_transaction.snap | 12 - ...e_in_transaction_with_explicit_commit.snap | 12 - ...est_rules__regression_with_indexing_2.snap | 5 - ...est_rules__adding_unique_constraint-2.snap | 5 - ...est_rules__adding_unique_constraint-3.snap | 5 - ..._test_rules__adding_unique_constraint.snap | 23 - ...__unique_constraint_inline_add_column.snap | 23 - ...e_constraint_inline_add_column_unique.snap | 23 - ...big_int__test_rules__create_table_bad.snap | 126 - ..._test_rules__create_table_many_errors.snap | 36 - ...ver_int__test_rules__create_table_bad.snap | 66 - ...mallint__test_rules__create_table_bad.snap | 66 - ...tity__test_rules__prefer_identity_bad.snap | 96 - ...es__create_index_concurrently_unnamed.snap | 22 - ...est_rules__disable_row_level_security.snap | 7 - ...test_rules__enable_row_level_security.snap | 7 - ...w_level_security_without_exists_check.snap | 7 - ...d__test_rules__adding_column_non_text.snap | 21 - ..._timestamptz__test_rules__alter_table.snap | 36 - ...g_column__test_rules__renaming_column.snap | 20 - ...ing_table__test_rules__renaming_table.snap | 20 - ...ules__adding_index_non_concurrently-2.snap | 5 - ..._rules__adding_index_non_concurrently.snap | 23 - ..._rules__ensure_ignored_when_new_table.snap | 5 - ..._new_table_with_assume_in_transaction.snap | 5 - ...n_nesting__test_rules__begin_repeated.snap | 23 - ...les__begin_with_assume_in_transaction.snap | 23 - ..._nesting__test_rules__commit_repeated.snap | 23 - ...es__commit_with_assume_in_transaction.snap | 23 - ...__rollback_with_assume_in_transaction.snap | 23 - crates/linter/src/rules/test_utils.rs | 10 - .../linter/src/rules/transaction_nesting.rs | 178 - crates/linter/src/rules/utils.rs | 57 - ...er__test_rules__rule_names_debug_snap.snap | 35 - ...__test_rules__rule_names_display_snap.snap | 33 - ...ter__versions__test_pg_version__parse.snap | 12 - crates/linter/src/versions.rs | 141 - crates/linter/src/violations.rs | 138 - crates/parser/Cargo.toml | 21 - crates/parser/README.md | 9 - crates/parser/src/ast.rs | 1007 ------ crates/parser/src/error.rs | 52 - crates/parser/src/lib.rs | 10 - crates/parser/src/parse.rs | 1379 -------- ..._tests__adding_index_non_concurrently.snap | 102 - ...s__alter_column_default_with_function.snap | 56 - ...arse__tests__alter_database_collation.snap | 21 - ...er__parse__tests__alter_database_stmt.snap | 131 - ..._tests__alter_default_privileges_stmt.snap | 81 - ...parser__parse__tests__alter_enum_stmt.snap | 36 - ...arse__tests__alter_event_trigger_stmt.snap | 24 - ...ests__alter_extension_contents_stmt-2.snap | 130 - ..._tests__alter_extension_contents_stmt.snap | 31 - ...se__tests__alter_foreign_data_wrapper.snap | 63 - ...rse__tests__alter_foreign_server_stmt.snap | 63 - ...er__parse__tests__alter_function_stmt.snap | 430 --- ...rse__tests__alter_object_depends_stmt.snap | 145 - ...er__parse__tests__alter_op_class_stmt.snap | 101 - ...r__parse__tests__alter_op_family_stmt.snap | 864 ----- ...er__parse__tests__alter_operator_stmt.snap | 281 -- ...er__parse__tests__alter_policy_stmt-2.snap | 94 - ...rser__parse__tests__alter_policy_stmt.snap | 36 - ...rser__parse__tests__alter_publication.snap | 127 - ...er__parse__tests__alter_role_set_stmt.snap | 51 - ...parser__parse__tests__alter_role_stmt.snap | 74 - ...er__parse__tests__alter_sequence_stmt.snap | 54 - ...parse__tests__alter_subscription_stmt.snap | 71 - ...rser__parse__tests__alter_system_stmt.snap | 58 - ...__parse__tests__alter_table_extension.snap | 43 - ..._parse__tests__alter_table_space_stmt.snap | 26 - ...e__tests__alter_ts_configuration_stmt.snap | 80 - ...arse__tests__alter_ts_dictionary_stmt.snap | 61 - ...parse__tests__alter_user_mapping_stmt.snap | 54 - ...uawk_parser__parse__tests__checkpoint.snap | 17 - ...rser__parse__tests__close_portal_stmt.snap | 21 - ...wk_parser__parse__tests__cluster_stmt.snap | 68 - ...parser__parse__tests__comment_on_stmt.snap | 98 - ...er__parse__tests__composite_type_stmt.snap | 105 - ...rse__tests__create_access_method_stmt.snap | 33 - ...arser__parse__tests__create_cast_stmt.snap | 134 - ..._parse__tests__create_conversion_stmt.snap | 42 - ...r__parse__tests__create_database_stmt.snap | 131 - ...ser__parse__tests__create_domain_stmt.snap | 164 - ...arser__parse__tests__create_enum_stmt.snap | 50 - ...rse__tests__create_event_trigger_stmt.snap | 33 - ...arser__parse__tests__create_extension.snap | 21 - ...e__tests__create_foreign_data_wrapper.snap | 21 - ...se__tests__create_foreign_server_stmt.snap | 86 - ...rse__tests__create_foriegn_table_stmt.snap | 349 -- ...r__parse__tests__create_function_stmt.snap | 99 - ...ests__create_index_without_index_name.snap | 53 - ...r__parse__tests__create_op_class_stmt.snap | 1157 ------- ...rser__parse__tests__create_plang_stmt.snap | 42 - ...ser__parse__tests__create_policy_stmt.snap | 53 - ...__parse__tests__create_procedure_stmt.snap | 199 -- ...parse__tests__create_publication_stmt.snap | 132 - ...rser__parse__tests__create_range_stmt.snap | 93 - ...arser__parse__tests__create_role_stmt.snap | 86 - ...r__parse__tests__create_sequence_stmt.snap | 54 - ...rser__parse__tests__create_stats_stmt.snap | 70 - ...arse__tests__create_subscription_stmt.snap | 40 - ...r__parse__tests__create_table_as_stmt.snap | 89 - ...__parse__tests__create_transform_stmt.snap | 154 - ...er__parse__tests__create_trigger_stmt.snap | 53 - ...arse__tests__create_user_mapping_stmt.snap | 74 - ...arser__parse__tests__create_view_stmt.snap | 189 -- ...parser__parse__tests__deallocate_stmt.snap | 17 - ...er__parse__tests__declare_cursor_stmt.snap | 73 - ...k_parser__parse__tests__define_stmt-2.snap | 270 -- ...k_parser__parse__tests__define_stmt-3.snap | 148 - ...awk_parser__parse__tests__define_stmt.snap | 151 - ...wk_parser__parse__tests__discard_stmt.snap | 47 - .../squawk_parser__parse__tests__do_stmt.snap | 40 - ...ser__parse__tests__drop_database_stmt.snap | 37 - ..._parser__parse__tests__drop_extension.snap | 22 - ...uawk_parser__parse__tests__drop_index.snap | 204 -- ...parser__parse__tests__drop_owned_stmt.snap | 36 - ...ser__parse__tests__drop_role_set_stmt.snap | 33 - ..._parse__tests__drop_subscription_stmt.snap | 24 - ..._parse__tests__drop_user_mapping_stmt.snap | 35 - ...awk_parser__parse__tests__error_paths.snap | 9 - ...wk_parser__parse__tests__execute_stmt.snap | 71 - ...wk_parser__parse__tests__explain_stmt.snap | 184 - ...uawk_parser__parse__tests__fetch_stmt.snap | 27 - ...se__tests__import_foreign_schema_stmt.snap | 30 - ...er__parse__tests__json_index_operator.snap | 101 - ...awk_parser__parse__tests__listen_stmt.snap | 21 - ...quawk_parser__parse__tests__load_stmt.snap | 21 - ...quawk_parser__parse__tests__lock_stmt.snap | 70 - ...quawk_parser__parse__tests__migration.snap | 132 - ...awk_parser__parse__tests__notify_stmt.snap | 37 - ...se__tests__parse_alter_collation_stmt.snap | 24 - ...ts__parse_alter_constraint_regression.snap | 102 - ...parse__tests__parse_alter_domain_stmt.snap | 32 - ...se__tests__parse_alter_table_set_list.snap | 67 - ...__tests__parse_attach_table_partition.snap | 96 - ...arse__tests__parse_create_schema_stmt.snap | 21 - ...__tests__parse_create_table_partition.snap | 91 - ..._tests__parse_create_table_regression.snap | 162 - ...er__parse__tests__parse_delete_stmt-2.snap | 79 - ...rser__parse__tests__parse_delete_stmt.snap | 32 - ...er__parse__tests__parse_delete_stmt_2.snap | 79 - ...__tests__parse_detach_table_partition.snap | 60 - ...parser__parse__tests__parse_func_call.snap | 72 - ..._parse__tests__parse_generated_column.snap | 128 - ...quawk_parser__parse__tests__parse_inh.snap | 106 - ...e__tests__parse_replica_identity_stmt.snap | 48 - ...e__tests__parse_set_operations_stmt-2.snap | 158 - ...rse__tests__parse_set_operations_stmt.snap | 158 - ...e__tests__parse_set_operations_stmt_2.snap | 158 - ..._parse__tests__parse_sql_create_index.snap | 55 - ...__parse_sql_create_index_concurrently.snap | 55 - ...s__parse_sql_create_unique_index_safe.snap | 59 - ...r__parse__tests__parse_sql_query_json.snap | 139 - ...se__tests__parse_sql_query_json_works.snap | 139 - ...rser__parse__tests__parsing_copy_stmt.snap | 38 - ...r__parse__tests__parsing_create_table.snap | 560 ---- ...ests__parsing_create_table_space_stmt.snap | 24 - ...ests__parsing_create_table_using_like.snap | 52 - ..._tests__parsing_drop_table_space_stmt.snap | 21 - ...ser__parse__tests__parsing_grant_role.snap | 48 - ...ser__parse__tests__parsing_grant_stmt.snap | 69 - ...er__parse__tests__parsing_insert_stmt.snap | 89 - ...er__parse__tests__parsing_update_stmt.snap | 103 - ...rse__tests__parsing_variable_set_stmt.snap | 38 - ...se__tests__parsing_variable_show_stmt.snap | 19 - ...wk_parser__parse__tests__prepare_stmt.snap | 192 -- ...er__parse__tests__reassign_owned_stmt.snap | 44 - ...se__tests__refresh_material_view_stmt.snap | 59 - ...parse__tests__regression_update_table.snap | 51 - ...wk_parser__parse__tests__reindex_stmt.snap | 94 - ...quawk_parser__parse__tests__rule_stmt.snap | 131 - ...er__parse__tests__security_label_stmt.snap | 40 - ...uawk_parser__parse__tests__select_one.snap | 58 - ...__parse__tests__select_string_literal.snap | 58 - ...parser__parse__tests__set_constraints.snap | 58 - ...arser__parse__tests__span_with_indent.snap | 58 - ..._tests__span_with_new_line_and_indent.snap | 58 - ...k_parser__parse__tests__truncate_stmt.snap | 105 - ...k_parser__parse__tests__unlisten_stmt.snap | 21 - ...awk_parser__parse__tests__vacuum_stmt.snap | 69 - 264 files changed, 1 insertion(+), 25151 deletions(-) delete mode 100644 crates/linter/Cargo.toml delete mode 100644 crates/linter/README.md delete mode 100644 crates/linter/src/errors.rs delete mode 100644 crates/linter/src/lib.rs delete mode 100644 crates/linter/src/rules/README.md delete mode 100644 crates/linter/src/rules/adding_field_with_default.rs delete mode 100644 crates/linter/src/rules/adding_foreign_key_constraint.rs delete mode 100644 crates/linter/src/rules/adding_not_null_field.rs delete mode 100644 crates/linter/src/rules/adding_primary_key_constraint.rs delete mode 100644 crates/linter/src/rules/adding_required_field.rs delete mode 100644 crates/linter/src/rules/ban_alter_domain_with_add_constraint.rs delete mode 100644 crates/linter/src/rules/ban_char_field.rs delete mode 100644 crates/linter/src/rules/ban_concurrent_index_creation_in_transaction.rs delete mode 100644 crates/linter/src/rules/ban_create_domain_with_constraint.rs delete mode 100644 crates/linter/src/rules/ban_drop_column.rs delete mode 100644 crates/linter/src/rules/ban_drop_database.rs delete mode 100644 crates/linter/src/rules/ban_drop_not_null.rs delete mode 100644 crates/linter/src/rules/ban_drop_table.rs delete mode 100644 crates/linter/src/rules/changing_column_type.rs delete mode 100644 crates/linter/src/rules/constraint_missing_not_valid.rs delete mode 100644 crates/linter/src/rules/disallow_unique_constraint.rs delete mode 100644 crates/linter/src/rules/mod.rs delete mode 100644 crates/linter/src/rules/non_volatile_built_in_functions.txt delete mode 100644 crates/linter/src/rules/prefer_big_int.rs delete mode 100644 crates/linter/src/rules/prefer_bigint_over_int.rs delete mode 100644 crates/linter/src/rules/prefer_bigint_over_smallint.rs delete mode 100644 crates/linter/src/rules/prefer_identity.rs delete mode 100644 crates/linter/src/rules/prefer_robust_stmts.rs delete mode 100644 crates/linter/src/rules/prefer_text_field.rs delete mode 100644 crates/linter/src/rules/prefer_timestamptz.rs delete mode 100644 crates/linter/src/rules/renaming_column.rs delete mode 100644 crates/linter/src/rules/renaming_table.rs delete mode 100644 crates/linter/src/rules/require_concurrent_index_creation.rs delete mode 100644 crates/linter/src/rules/require_concurrent_index_deletion.rs delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__add_numbers_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_arbitrary_func_err.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_bool_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_enum_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_integer_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_jsonb_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_now_func_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_random_with_args_err.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_str_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_uuid_err.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_volatile_func_err.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_bad.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_ok.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__generated_stored.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_in_version_11.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_without_default.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__set_not_null.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__serial_primary_key.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored_not_null.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_with_default.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_without_default.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__nullable.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_alter_domain_with_add_constraint__test_rules__ban_alter_domain_with_add_constraint_works.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_char_errors.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_var_char_and_text_okay.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction_but_outside.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_create_domain_with_constraint__test_rules__ban_create_domain_with_constraint_works.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_column__test_rules__drop_column.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_database__test_rules__ban_drop_database.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_not_null__test_rules__ban_drop_not_null.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_table__test_rules__ban_drop_table.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction_with_explicit_commit.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-3.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column_unique.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_bad.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_many_errors.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_int__test_rules__create_table_bad.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_smallint__test_rules__create_table_bad.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_identity__test_rules__prefer_identity_bad.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__create_index_concurrently_unnamed.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__disable_row_level_security.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security_without_exists_check.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_text_field__test_rules__adding_column_non_text.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_timestamptz__test_rules__alter_table.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_column__test_rules__renaming_column.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_table__test_rules__renaming_table.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently-2.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_repeated.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_repeated.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__rollback_with_assume_in_transaction.snap delete mode 100644 crates/linter/src/rules/test_utils.rs delete mode 100644 crates/linter/src/rules/transaction_nesting.rs delete mode 100644 crates/linter/src/rules/utils.rs delete mode 100644 crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_debug_snap.snap delete mode 100644 crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_display_snap.snap delete mode 100644 crates/linter/src/snapshots/squawk_linter__versions__test_pg_version__parse.snap delete mode 100644 crates/linter/src/versions.rs delete mode 100644 crates/linter/src/violations.rs delete mode 100644 crates/parser/Cargo.toml delete mode 100644 crates/parser/README.md delete mode 100644 crates/parser/src/ast.rs delete mode 100644 crates/parser/src/error.rs delete mode 100644 crates/parser/src/lib.rs delete mode 100644 crates/parser/src/parse.rs delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_collation.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__error_paths.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__migration.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_attach_table_partition.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt_2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_detach_table_partition.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt_2.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json_works.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_using_like.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap delete mode 100644 crates/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap diff --git a/Cargo.lock b/Cargo.lock index 6bb8339a..7aa2b883 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,28 +175,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bindgen" -version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 1.0.109", - "which", -] - [[package]] name = "bindgen" version = "0.66.1" @@ -1440,18 +1418,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "libpg_query-sys" -version = "0.4.0" -source = "git+https://github.com/chdsbd/libpg_query-sys.git?rev=ac223c7b197459d657d166449ccf99883f23bbcb#ac223c7b197459d657d166449ccf99883f23bbcb" -dependencies = [ - "bindgen 0.64.0", - "cc", - "fs_extra", - "glob", - "make-cmd", -] - [[package]] name = "line-index" version = "0.1.2" @@ -1489,12 +1455,6 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" -[[package]] -name = "make-cmd" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8ca8afbe8af1785e09636acb5a41e08a765f5f0340568716c18a8700ba3c0d3" - [[package]] name = "matches" version = "0.1.9" @@ -1844,7 +1804,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f71c7c56dfe299ec6f98aa210aa23458be3b0610c485be60a5873c2f3627c40e" dependencies = [ - "bindgen 0.66.1", + "bindgen", "cc", "fs_extra", "glob", @@ -2475,17 +2435,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_repr" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.101", -] - [[package]] name = "serde_urlencoded" version = "0.5.5" @@ -2629,29 +2578,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "squawk-linter" -version = "0.0.0" -dependencies = [ - "insta", - "lazy_static", - "serde", - "serde_json", - "serde_plain", - "squawk-parser", -] - -[[package]] -name = "squawk-parser" -version = "0.0.0" -dependencies = [ - "insta", - "libpg_query-sys", - "serde", - "serde_json", - "serde_repr", -] - [[package]] name = "squawk_lexer" version = "0.0.0" diff --git a/crates/linter/Cargo.toml b/crates/linter/Cargo.toml deleted file mode 100644 index a0cbde71..00000000 --- a/crates/linter/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "squawk-linter" -version = "0.0.0" -authors.workspace = true -edition.workspace = true -license.workspace = true -description = "Postgres SQL linter used in squawk" -repository = "https://github.com/sbdchd/squawk" -readme = "README.md" -keywords = ["postgres", "sql", "linter"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde.workspace = true -squawk-parser.workspace = true -serde_plain.workspace = true -lazy_static.workspace = true -serde_json.workspace = true - -[dev-dependencies] -insta.workspace = true diff --git a/crates/linter/README.md b/crates/linter/README.md deleted file mode 100644 index 467d22ec..00000000 --- a/crates/linter/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# squawk-linter - -Rule definitions for [`squawk`](https://github.com/sbdchd/squawk). The CLI -runs the rules over the files it finds. diff --git a/crates/linter/src/errors.rs b/crates/linter/src/errors.rs deleted file mode 100644 index 8ac0f1b6..00000000 --- a/crates/linter/src/errors.rs +++ /dev/null @@ -1,20 +0,0 @@ -use squawk_parser::error::PgQueryError; - -#[derive(Debug, PartialEq)] -pub enum CheckSqlError { - ParsingSql(PgQueryError), -} - -impl std::fmt::Display for CheckSqlError { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match *self { - Self::ParsingSql(ref err) => err.fmt(f), - } - } -} - -impl std::convert::From for CheckSqlError { - fn from(err: PgQueryError) -> Self { - Self::ParsingSql(err) - } -} diff --git a/crates/linter/src/lib.rs b/crates/linter/src/lib.rs deleted file mode 100644 index 0cb57775..00000000 --- a/crates/linter/src/lib.rs +++ /dev/null @@ -1,484 +0,0 @@ -#![allow(clippy::shadow_unrelated)] -#![allow(clippy::missing_errors_doc)] -pub mod errors; -pub mod rules; -pub mod versions; -pub mod violations; -#[macro_use] -extern crate lazy_static; - -use crate::errors::CheckSqlError; -use crate::rules::adding_required_field; -use crate::rules::ban_alter_domain_with_add_constraint; -use crate::rules::ban_concurrent_index_creation_in_transaction; -use crate::rules::ban_create_domain_with_constraint; -use crate::rules::ban_drop_not_null; -use crate::rules::prefer_big_int; -use crate::rules::prefer_identity; -use crate::rules::transaction_nesting; -use crate::rules::{ - adding_field_with_default, adding_foreign_key_constraint, adding_not_nullable_field, - adding_primary_key_constraint, ban_char_type, ban_drop_column, ban_drop_database, - ban_drop_table, changing_column_type, constraint_missing_not_valid, disallow_unique_constraint, - prefer_bigint_over_int, prefer_bigint_over_smallint, prefer_robust_stmts, prefer_text_field, - prefer_timestamptz, renaming_column, renaming_table, require_concurrent_index_creation, - require_concurrent_index_deletion, -}; -use crate::violations::{RuleViolation, RuleViolationKind, ViolationMessage}; -use squawk_parser::ast::RawStmt; -use squawk_parser::parse::parse_sql_query; -use std::collections::HashSet; -use versions::Version; - -#[derive(Clone)] -pub struct SquawkRule { - pub name: RuleViolationKind, - func: fn(&[RawStmt], Option, bool) -> Vec, - pub messages: Vec, -} - -lazy_static! { - pub static ref RULES: Vec = vec![ - // see ChangingColumnType - SquawkRule { - name: RuleViolationKind::AddingFieldWithDefault, - func: adding_field_with_default, - messages: vec![ - ViolationMessage::Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.".into(), - ), - ViolationMessage::Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.".into(), - ), - - ], - }, - SquawkRule { - name: RuleViolationKind::AddingForeignKeyConstraint, - func: adding_foreign_key_constraint, - messages: vec![ - ViolationMessage::Note( - "Requires a table scan of the table you're altering and a SHARE ROW EXCLUSIVE lock on both tables, which blocks writes to both tables while your table is scanned.".into() - ), - ViolationMessage::Help("Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.".into()), - ] - }, - // usually paired with a DEFAULT - SquawkRule { - name: RuleViolationKind::AddingNotNullableField, - func: adding_not_nullable_field, - messages: vec![ - // https://www.postgresql.org/docs/10/sql-altertable.html - ViolationMessage::Note( - "Adding a NOT NULL field requires exclusive locks and table rewrites.".into(), - ), - ViolationMessage::Help("Make the field nullable.".into()) - ], - }, - SquawkRule { - name: RuleViolationKind::AddingRequiredField, - func: adding_required_field, - messages: vec![ - ViolationMessage::Note( - "Adding a NOT NULL field without a DEFAULT will fail for a populated table.".into() - ), - ViolationMessage::Help( - "Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+).".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::AddingSerialPrimaryKeyField, - func: adding_primary_key_constraint, - messages: vec![ - ViolationMessage::Note( - "Adding a PRIMARY KEY constraint results in locks and table rewrites".into(), - ), - ViolationMessage::Help( - "Add the PRIMARY KEY constraint USING an index.".into(), - ), - - ], - }, - SquawkRule { - name: RuleViolationKind::BanAlterDomainWithAddConstraint, - func: ban_alter_domain_with_add_constraint, - messages: vec![ - ViolationMessage::Note( - "Domains with constraints have poor support for online migrations".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::BanCharField, - func: ban_char_type, - messages: vec![ - ViolationMessage::Help( - "Use text or varchar instead.".into() - ), - ] - }, - SquawkRule { - name: RuleViolationKind::BanConcurrentIndexCreationInTransaction, - func: ban_concurrent_index_creation_in_transaction, - messages: vec![ - ViolationMessage::Note( - "Concurrent index creation is not allowed inside a transaction.".into() - ), - ViolationMessage::Help( - "Build the index outside any transactions.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::BanCreateDomainWithConstraint, - func: ban_create_domain_with_constraint, - messages: vec![ - ViolationMessage::Note( - "Domains with constraints have poor support for online migrations".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::BanDropColumn, - func: ban_drop_column, - messages: vec![ - ViolationMessage::Note( - "Dropping a column may break existing clients.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::BanDropDatabase, - func: ban_drop_database, - messages: vec![ - ViolationMessage::Note( - "Dropping a database may break existing clients.".into() - ) - ], - }, - SquawkRule { - name: RuleViolationKind::BanDropNotNull, - func: ban_drop_not_null, - messages: vec![ - ViolationMessage::Note( - "Dropping a NOT NULL constraint may break existing clients.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::BanDropTable, - func: ban_drop_table, - messages: vec![ - ViolationMessage::Note( - "Dropping a table may break existing clients.".into() - ) - ], - }, - // > Adding a column with a volatile DEFAULT or changing the type of an - // > existing column will require the entire table and its indexes to be - // > rewritten. As an exception, when changing the type of an existing - // > column, if the USING clause does not change the column contents and - // > the old type is either binary coercible to the new type or an - // > unconstrained domain over the new type, a table rewrite is not - // > needed; but any indexes on the affected columns must still be - // > rebuilt. Table and/or index rebuilds may take a significant amount of - // > time for a large table; and will temporarily require as much as - // > double the disk space. - // https://www.postgresql.org/docs/current/sql-altertable.html - SquawkRule { - name: RuleViolationKind::ChangingColumnType, - func: changing_column_type, - messages: vec![ - ViolationMessage::Note("Requires an ACCESS EXCLUSIVE lock on the table which blocks reads.".into()), - ViolationMessage::Note("Changing the type may break existing clients.".into()), - ], - }, - - // > Scanning a large table to verify a new foreign key or check - // > constraint can take a long time, and other updates to the table are - // > locked out until the ALTER TABLE ADD CONSTRAINT command is committed. - // > The main purpose of the NOT VALID constraint option is to reduce the - // > impact of adding a constraint on concurrent updates. With NOT VALID, - // > the ADD CONSTRAINT command does not scan the table and can be - // > committed immediately. After that, a VALIDATE CONSTRAINT command can - // > be issued to verify that existing rows satisfy the constraint. The - // > validation step does not need to lock out concurrent updates, since - // > it knows that other transactions will be enforcing the constraint for - // > rows that they insert or update; only pre-existing rows need to be - // > checked. Hence, validation acquires only a SHARE UPDATE EXCLUSIVE - // > lock on the table being altered. (If the constraint is a foreign key - // > then a ROW SHARE lock is also required on the table referenced by the - // > constraint.) In addition to improving concurrency, it can be useful - // > to use NOT VALID and VALIDATE CONSTRAINT in cases where the table is - // > known to contain pre-existing violations. Once the constraint is in - // > place, no new violations can be inserted, and the existing problems - // > can be corrected at leisure until VALIDATE CONSTRAINT finally - // > succeeds. - // https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-NOTES - SquawkRule { - name: RuleViolationKind::ConstraintMissingNotValid, - func: constraint_missing_not_valid, - messages: vec![ - ViolationMessage::Note("Requires a table scan to verify constraint and an ACCESS EXCLUSIVE lock which blocks reads.".into()), - ViolationMessage::Help("Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.".into()), - ], - }, - // > Although most forms of ADD table_constraint require an ACCESS - // > EXCLUSIVE lock, ADD FOREIGN KEY requires only a SHARE ROW EXCLUSIVE - // > lock. - // https://www.postgresql.org/docs/current/sql-altertable.html - SquawkRule { - name: RuleViolationKind::DisallowedUniqueConstraint, - func: disallow_unique_constraint, - messages: vec![ - ViolationMessage::Note( - "Adding a UNIQUE constraint requires an ACCESS EXCLUSIVE lock which blocks reads.".into(), - ), - ViolationMessage::Help( - "Create an index CONCURRENTLY and create the constraint using the index.".into(), - ), - - ], - }, - SquawkRule { - name: RuleViolationKind::PreferBigInt, - func: prefer_big_int, - messages: vec![ - ViolationMessage::Note( - "Hitting the max 32 bit integer is possible and may break your application.".into() - ), - ViolationMessage::Help( - "Use 64bit integer values instead to prevent hitting this limit.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::PreferBigintOverInt, - func: prefer_bigint_over_int, - messages: vec![ - ViolationMessage::Note( - "Hitting the max 32 bit integer is possible and may break your application.".into() - ), - ViolationMessage::Help( - "Use 64bit integer values instead to prevent hitting this limit.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::PreferBigintOverSmallint, - func: prefer_bigint_over_smallint, - messages: vec![ - ViolationMessage::Note( - "Hitting the max 16 bit integer is possible and may break your application.".into() - ), - ViolationMessage::Help( - "Use 64bit integer values instead to prevent hitting this limit.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::PreferIdentity, - func: prefer_identity, - messages: vec![ - ViolationMessage::Note( - "Serial types have confusing behaviors that make schema management difficult.".into() - ), - ViolationMessage::Help( - "Use identity columns instead for more features and better usability.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::PreferRobustStmts, - func: prefer_robust_stmts, - messages: vec![ - ViolationMessage::Help( - "Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.".into() - ), - ] - }, - // see ConstraintMissingNotValid for more docs - SquawkRule { - name: RuleViolationKind::PreferTextField, - func: prefer_text_field, - messages: vec![ - ViolationMessage::Note( - "Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.".into() - ), - ViolationMessage::Help( - "Use a text field with a check constraint.".into() - ), - ] - }, - SquawkRule { - name: RuleViolationKind::PreferTimestampTz, - func: prefer_timestamptz, - messages: vec![ - ViolationMessage::Note( - "A timestamp field without a timezone can lead to data loss, depending on your database session timezone.".into() - ), - ViolationMessage::Help( - "Use timestamptz instead of timestamp for your column type.".into() - ), - ] - }, - // > The RENAME forms change the name of a table (or an index, sequence, - // > view, materialized view, or foreign table), the name of an individual - // > column in a table, or the name of a constraint of the table. There is - // > no effect on the stored data. - // https://www.postgresql.org/docs/10/sql-altertable.html - SquawkRule { - name: RuleViolationKind::RenamingColumn, - func: renaming_column, - messages: vec![ - ViolationMessage::Note( - "Renaming a column may break existing clients.".into() - ), - ], - }, - // see RenamingColumn rule - SquawkRule { - name: RuleViolationKind::RenamingTable, - func: renaming_table, - messages: vec![ - ViolationMessage::Note( - "Renaming a table may break existing clients.".into() - ), - ], - }, - // https://www.postgresql.org/docs/10/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY - SquawkRule { - name: RuleViolationKind::RequireConcurrentIndexCreation, - func: require_concurrent_index_creation, - messages: vec![ - ViolationMessage::Note( - "Creating an index blocks writes.".into() - ), - ViolationMessage::Help( - "Create the index CONCURRENTLY.".into() - ), - ], - }, - // https://www.postgresql.org/docs/10/sql-dropindex.html - SquawkRule { - name: RuleViolationKind::RequireConcurrentIndexDeletion, - func: require_concurrent_index_deletion, - messages: vec![ - ViolationMessage::Note( - "Deleting an index blocks selects, inserts, updates, and deletes on the index's table.".into() - ), - ViolationMessage::Help( - "Delete the index CONCURRENTLY.".into() - ), - ], - }, - SquawkRule { - name: RuleViolationKind::TransactionNesting, - func: transaction_nesting, - messages: vec![ - ViolationMessage::Note( - "There is an existing transaction already in progress.".into() - ), - ViolationMessage::Help( - "COMMIT the previous transaction before issuing a BEGIN or START TRANSACTION statement.".into() - ), - ], - }, - // generator::new-rule-above - ]; - -} - -pub fn check_sql( - sql: &str, - excluded_rules: &[RuleViolationKind], - pg_version: Option, - assume_in_transaction: bool, -) -> Result, CheckSqlError> { - let tree = parse_sql_query(sql)?; - - let excluded_rules: HashSet = excluded_rules.iter().cloned().collect(); - - let mut errs = vec![]; - for rule in RULES.iter().filter(|r| !excluded_rules.contains(&r.name)) { - errs.extend((rule.func)(&tree, pg_version, assume_in_transaction)); - } - - errs.sort_by_key(|v| v.span.start); - - Ok(errs) -} - -pub fn check_sql_with_rule( - sql: &str, - rule_kind: &RuleViolationKind, - pg_version: Option, - assume_in_transaction: bool, -) -> Result, CheckSqlError> { - let tree = parse_sql_query(sql)?; - let mut errs = vec![]; - for rule in RULES.iter() { - if rule.name == *rule_kind { - errs.extend((rule.func)(&tree, pg_version, assume_in_transaction)); - } - } - - errs.sort_by_key(|v| v.span.start); - - Ok(errs) -} - -#[cfg(test)] -mod test_rules { - use super::*; - use insta::{assert_debug_snapshot, assert_snapshot}; - use std::convert::TryFrom; - use std::str::FromStr; - - #[test] - fn rules_should_be_sorted() { - let original_rules: Vec = RULES.iter().map(|x| x.name.to_string()).collect(); - let mut sorted_rule_ids = original_rules.clone(); - sorted_rule_ids.sort(); - assert_eq!(original_rules, sorted_rule_ids); - } - /// Ensure we handle both serializing and deserializing `RuleViolationKind` - #[test] - fn parsing_rule_kind() { - let rule_names = RULES.iter().map(|r| r.name.clone()); - for rule in rule_names { - let rule_str = rule.to_string(); - assert_eq!(RuleViolationKind::from_str(&rule_str), Ok(rule.clone())); - assert_eq!(RuleViolationKind::try_from(rule_str.as_ref()), Ok(rule)); - } - } - /// Ensure rule names don't change - #[test] - fn rule_names_debug_snap() { - let rule_names: Vec = RULES.iter().map(|r| r.name.to_string()).collect(); - assert_debug_snapshot!(rule_names); - } - #[test] - fn rule_names_display_snap() { - let rule_names: Vec = RULES.iter().map(|r| r.name.to_string()).collect(); - assert_snapshot!(rule_names.join("\n")); - } - - /// Ensure we stort the resulting violations by where they occur in the file. - #[test] - fn check_rules_orderin() { - let sql = r#" - ALTER TABLE "table_name" RENAME COLUMN "column_name" TO "new_column_name"; - CREATE INDEX "field_name_idx" ON "table_name" ("field_name"); - "#; - - let res = check_sql(sql, &[RuleViolationKind::PreferRobustStmts], None, false) - .expect("valid parsing of SQL"); - let mut prev_span_start = -1; - for violation in &res { - assert!(violation.span.start > prev_span_start); - prev_span_start = violation.span.start; - } - } -} diff --git a/crates/linter/src/rules/README.md b/crates/linter/src/rules/README.md deleted file mode 100644 index 2126d61d..00000000 --- a/crates/linter/src/rules/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# linter/src/rules - -## Adding a new rule (automated) - -1. Install [plop](https://github.com/plopjs/plop) - ``` - npm install -g plop - ``` -2. Generate a new rule - ``` - s/new-rule 'my-rule-name' - ``` - -## Adding a new rule (manually) - -1. Create a new file in `squawk/linter/src/rules/my_new_rule.rs`. Use an existing rule as a template. -2. Add your module to `squawk/linter/src/rules/mod.rs`. - ```rust - pub mod my_new_rule; - pub use my_new_rule::*; - ``` -3. Add your linter to the `RULES` list in `squawk/linter/lib.rs`. -4. Document your rule in `squawk/docs/docs/my-new-rule.md`. -5. Add your docs page ID to `squawk/docs/sidebars.js`. -6. Add your docs page ID to `squawk/docs/src/pages/index.js`. diff --git a/crates/linter/src/rules/adding_field_with_default.rs b/crates/linter/src/rules/adding_field_with_default.rs deleted file mode 100644 index 42106c34..00000000 --- a/crates/linter/src/rules/adding_field_with_default.rs +++ /dev/null @@ -1,266 +0,0 @@ -use std::collections::HashSet; - -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind, ViolationMessage}, -}; - -use serde_json::{json, Value}; -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, ColumnDefConstraint, ConstrType, RawStmt, Stmt, -}; - -fn constraint_has_constant_expr(raw_expr: &Value) -> bool { - raw_expr["A_Const"] != Value::Null || raw_expr["TypeCast"]["arg"]["A_Const"] != Value::Null -} - -fn is_non_volatile_func_call(raw_expr: &Value, non_volatile_funcs: &HashSet) -> bool { - let func_name = raw_expr["FuncCall"]["funcname"][0]["String"]["sval"].as_str(); - - let Some(func_name) = func_name else { - return false; - }; - - // NOTE(chdsbd): we don't check functions with args, because I'm not certain - // if there's a problem with volatile functions there. If we need this - // functionality, we can add it later. - raw_expr["FuncCall"]["args"] == Value::Null && non_volatile_funcs.contains(func_name) -} - -// Generated via the following Postgres query: -// select proname from pg_proc where provolatile <> 'v'; -const NON_VOLATILE_BUILT_IN_FUNCTIONS: &str = include_str!("non_volatile_built_in_functions.txt"); - -#[must_use] -pub fn adding_field_with_default( - tree: &[RawStmt], - pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - - let non_volatile_funcs: HashSet<_> = NON_VOLATILE_BUILT_IN_FUNCTIONS - .split('\n') - .map(|x| x.trim().to_lowercase()) - .filter(|x| !x.is_empty()) - .collect(); - - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - match &cmd.def { - Some(AlterTableDef::ColumnDef(def)) => { - for ColumnDefConstraint::Constraint(constraint) in &def.constraints { - if constraint.contype == ConstrType::Default { - if let Some(pg_version) = pg_version { - let def = json!({}); - let raw_expr = constraint.raw_expr.as_ref().unwrap_or(&def); - if pg_version > Version::new(11, None, None) - && (constraint_has_constant_expr(raw_expr) - || is_non_volatile_func_call( - raw_expr, - &non_volatile_funcs, - )) - { - continue; - } - } - errs.push(RuleViolation::new( - RuleViolationKind::AddingFieldWithDefault, - raw_stmt.into(), - None, - )); - } - if constraint.contype == ConstrType::Generated { - errs.push(RuleViolation::new( - RuleViolationKind::AddingFieldWithDefault, - raw_stmt.into(), - Some(vec![ - ViolationMessage::Note( - "Adding a generated column requires a table rewrite with an ACCESS EXCLUSIVE lock.".into(), - ), - ViolationMessage::Help( - "Add the column as nullable, backfill existing rows, and add a trigger to update the column on write instead.".into(), - ), - ]), - )); - } - } - } - _ => continue, - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use std::str::FromStr; - - use crate::{ - check_sql_with_rule, - versions::Version, - violations::{RuleViolation, RuleViolationKind}, - }; - - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str, pg_version: Option) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::AddingFieldWithDefault, - pg_version, - false, - ) - .unwrap() - } - - /// - /// ```sql - /// -- instead of - /// ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; - /// -- use - /// ALTER TABLE "core_recipe" ADD COLUMN "foo" integer; - /// ALTER TABLE "core_recipe" ALTER COLUMN "foo" SET DEFAULT 10; - /// -- backfill - /// -- remove nullability - /// ``` - #[test] - fn docs_example_bad() { - let bad_sql = r#" --- instead of -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; -"#; - assert_debug_snapshot!(lint_sql(bad_sql, None)); - } - #[test] - fn docs_example_ok() { - let ok_sql = r#" --- use -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer; -ALTER TABLE "core_recipe" ALTER COLUMN "foo" SET DEFAULT 10; --- backfill --- remove nullability - "#; - assert_debug_snapshot!(lint_sql(ok_sql, None)); - } - - #[test] - fn default_integer_ok() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; -"#; - - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - - #[test] - fn default_uuid_err() { - let bad_sql = r#" --- VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT uuid(); -"#; - - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(bad_sql, pg_version_11)); - } - - #[test] - fn default_volatile_func_err() { - let bad_sql = r#" --- VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" boolean DEFAULT random(); -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(bad_sql, pg_version_11)); - } - #[test] - fn default_bool_ok() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" boolean DEFAULT true; -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn default_str_ok() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" text DEFAULT 'some-str'; -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn default_enum_ok() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" some_enum_type DEFAULT 'my-enum-variant'; -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn default_jsonb_ok() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" jsonb DEFAULT '{}'::jsonb; -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn default_arbitrary_func_err() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" jsonb DEFAULT myjsonb(); -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn default_random_with_args_err() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" timestamptz DEFAULT now(123); -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn default_now_func_ok() { - let ok_sql = r#" --- NON-VOLATILE -ALTER TABLE "core_recipe" ADD COLUMN "foo" timestamptz DEFAULT now(); -"#; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - #[test] - fn add_numbers_ok() { - // This should be okay, but we don't handle expressions like this at the moment. - let ok_sql = r" -alter table account_metadata add column blah integer default 2 + 2; -"; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(ok_sql, pg_version_11)); - } - - #[test] - fn generated_stored() { - let bad_sql = r" - ALTER TABLE foo - ADD COLUMN bar numeric GENERATED ALWAYS AS (bar + baz) STORED; - "; - let pg_version_11 = Some(Version::from_str("11.0.0").unwrap()); - assert_debug_snapshot!(lint_sql(bad_sql, pg_version_11)); - } -} diff --git a/crates/linter/src/rules/adding_foreign_key_constraint.rs b/crates/linter/src/rules/adding_foreign_key_constraint.rs deleted file mode 100644 index 1c73a330..00000000 --- a/crates/linter/src/rules/adding_foreign_key_constraint.rs +++ /dev/null @@ -1,150 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RawStmt, Stmt, -}; - -/// Adding a foreign key constraint requires a table scan and a -/// SHARE ROW EXCLUSIVE lock on both tables, which blocks writes. -/// -/// Adding the constraint as NOT VALID in one transaction and then using -/// VALIDATE in another transaction will allow writes when adding the -/// constraint. -#[must_use] -pub fn adding_foreign_key_constraint( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for cmd in &stmt.cmds { - match cmd { - AlterTableCmds::AlterTableCmd(ref command) => { - if let AlterTableType::AddConstraint = command.subtype { - if let Some(AlterTableDef::Constraint(constraint)) = &command.def { - // Adding foreign key is okay when NOT VALID is specified. - if constraint.skip_validation { - continue; - } - if constraint.contype == ConstrType::Foreign { - errs.push(RuleViolation::new( - RuleViolationKind::AddingForeignKeyConstraint, - raw_stmt.into(), - None, - )); - } - } - } else if AlterTableType::AddColumn == command.subtype { - if let Some(AlterTableDef::ColumnDef(column_def)) = &command.def { - for ColumnDefConstraint::Constraint(constraint) in - &column_def.constraints - { - if !constraint.skip_validation - && constraint.contype == ConstrType::Foreign - { - errs.push(RuleViolation::new( - RuleViolationKind::AddingForeignKeyConstraint, - raw_stmt.into(), - None, - )); - } - } - } - } - } - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::AddingForeignKeyConstraint, - None, - false, - ) - .unwrap() - } - - #[test] - fn create_table_with_foreign_key_constraint() { - let sql = r#" -BEGIN; -CREATE TABLE email ( - id BIGINT GENERATED ALWAYS AS IDENTITY, - user_id BIGINT, - email TEXT, - PRIMARY KEY(id), - CONSTRAINT fk_user - FOREIGN KEY ("user_id") - REFERENCES "user" ("id") -); -COMMIT; - "#; - - let violations = lint_sql(sql); - assert_eq!(violations.len(), 0); - } - #[test] - fn add_foreign_key_constraint_not_valid_validate() { - let sql = r#" -BEGIN; -ALTER TABLE "email" ADD COLUMN "user_id" INT; -ALTER TABLE "email" ADD CONSTRAINT "fk_user" FOREIGN KEY ("user_id") REFERENCES "user" ("id") NOT VALID; -ALTER TABLE "email" VALIDATE CONSTRAINT "fk_user"; -COMMIT; - "#; - - let violations = lint_sql(sql); - assert_eq!(violations.len(), 0); - } - #[test] - fn add_foreign_key_constraint_lock() { - let sql = r#" -BEGIN; -ALTER TABLE "email" ADD COLUMN "user_id" INT; -ALTER TABLE "email" ADD CONSTRAINT "fk_user" FOREIGN KEY ("user_id") REFERENCES "user" ("id"); -COMMIT; - "#; - - let violations = lint_sql(sql); - assert_eq!(violations.len(), 1); - assert_eq!( - violations[0].kind, - RuleViolationKind::AddingForeignKeyConstraint - ); - } - #[test] - fn add_column_references_lock() { - let sql = r#" -BEGIN; -ALTER TABLE "emails" ADD COLUMN "user_id" INT REFERENCES "user" ("id"); -COMMIT; - "#; - - let violations = lint_sql(sql); - assert_eq!(violations.len(), 1); - assert_eq!( - violations[0].kind, - RuleViolationKind::AddingForeignKeyConstraint - ); - } -} diff --git a/crates/linter/src/rules/adding_not_null_field.rs b/crates/linter/src/rules/adding_not_null_field.rs deleted file mode 100644 index 0aa6d8f2..00000000 --- a/crates/linter/src/rules/adding_not_null_field.rs +++ /dev/null @@ -1,79 +0,0 @@ -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind}; -use crate::ViolationMessage; - -use squawk_parser::ast::{AlterTableCmds, AlterTableType, RawStmt, Stmt}; - -#[must_use] -pub fn adding_not_nullable_field( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - if cmd.subtype == AlterTableType::SetNotNull { - errs.push(RuleViolation::new( - RuleViolationKind::AddingNotNullableField, - raw_stmt.into(), - Some(vec![ - ViolationMessage::Note("Setting a column NOT NULL blocks reads while the table is scanned.".into()), - ViolationMessage::Help("Use a check constraint instead.".into()) - ]), - )); - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::AddingNotNullableField, None, false).unwrap() - } - - use insta::assert_debug_snapshot; - - #[test] - fn set_not_null() { - let bad_sql = r#" -ALTER TABLE "core_recipe" ALTER COLUMN "foo" SET NOT NULL; - "#; - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - #[test] - fn adding_field_that_is_not_nullable() { - let ok_sql = r#" -BEGIN; --- This will cause a table rewrite for Postgres versions before 11, but that is handled by --- adding-field-with-default. -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10 NOT NULL; -ALTER TABLE "core_recipe" ALTER COLUMN "foo" DROP DEFAULT; -COMMIT; - "#; - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - #[test] - fn adding_field_that_is_not_nullable_without_default() { - let ok_sql = r#" --- This won't work if the table is populated, but that error is caught by adding-required-field. -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL; - "#; - assert_debug_snapshot!(lint_sql(ok_sql)); - } -} diff --git a/crates/linter/src/rules/adding_primary_key_constraint.rs b/crates/linter/src/rules/adding_primary_key_constraint.rs deleted file mode 100644 index 6804a54f..00000000 --- a/crates/linter/src/rules/adding_primary_key_constraint.rs +++ /dev/null @@ -1,103 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RawStmt, Stmt, -}; - -#[must_use] -pub fn adding_primary_key_constraint( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - match (&cmd.def, &cmd.subtype) { - ( - Some(AlterTableDef::Constraint(constraint)), - AlterTableType::AddConstraint, - ) => { - if constraint.contype == ConstrType::Primary - && constraint.indexname.is_none() - { - errs.push(RuleViolation::new( - RuleViolationKind::AddingSerialPrimaryKeyField, - raw_stmt.into(), - None, - )); - } - } - (Some(AlterTableDef::ColumnDef(def)), _) => { - for ColumnDefConstraint::Constraint(constraint) in &def.constraints { - if constraint.contype == ConstrType::Primary - && constraint.indexname.is_none() - { - errs.push(RuleViolation::new( - RuleViolationKind::AddingSerialPrimaryKeyField, - raw_stmt.into(), - None, - )); - } - } - } - _ => continue, - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::AddingSerialPrimaryKeyField, - None, - false, - ) - .unwrap() - } - - #[test] - fn serial_primary_key() { - let bad_sql = r" -ALTER TABLE a ADD COLUMN b SERIAL PRIMARY KEY; -"; - - let expected_bad_res = lint_sql(bad_sql); - assert_ne!(expected_bad_res, vec![]); - assert_debug_snapshot!(expected_bad_res); - } - - #[test] - fn plain_primary_key() { - let bad_sql = r" -ALTER TABLE items ADD PRIMARY KEY (id); -"; - - let expected_bad_res = lint_sql(bad_sql); - assert_ne!(expected_bad_res, vec![]); - assert_debug_snapshot!(expected_bad_res); - - let ok_sql = r" -ALTER TABLE items ADD CONSTRAINT items_pk PRIMARY KEY USING INDEX items_pk; -"; - assert_debug_snapshot!(lint_sql(ok_sql,)); - } -} diff --git a/crates/linter/src/rules/adding_required_field.rs b/crates/linter/src/rules/adding_required_field.rs deleted file mode 100644 index e667b458..00000000 --- a/crates/linter/src/rules/adding_required_field.rs +++ /dev/null @@ -1,116 +0,0 @@ -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind}; - -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RawStmt, Stmt, -}; -fn has_generated_constraint(constraints: &[ColumnDefConstraint]) -> bool { - for ColumnDefConstraint::Constraint(constraint) in constraints { - if constraint.contype == ConstrType::Generated { - return true; - } - } - false -} - -fn has_not_null_and_no_default_constraint(constraints: &[ColumnDefConstraint]) -> bool { - let mut has_not_null = false; - let mut has_default = false; - for ColumnDefConstraint::Constraint(constraint) in constraints { - if constraint.contype == ConstrType::NotNull { - has_not_null = true; - } - if constraint.contype == ConstrType::Default { - has_default = true; - } - } - has_not_null && !has_default -} - -#[must_use] -pub fn adding_required_field( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - if cmd.subtype == AlterTableType::AddColumn { - if let Some(AlterTableDef::ColumnDef(column_def)) = &cmd.def { - if has_generated_constraint(&column_def.constraints) { - continue; - } - if has_not_null_and_no_default_constraint(&column_def.constraints) { - errs.push(RuleViolation::new( - RuleViolationKind::AddingRequiredField, - raw_stmt.into(), - None, - )); - } - } - } - } - } - _ => continue, - } - } - - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::AddingRequiredField, None, false).unwrap() - } - - #[test] - fn nullable() { - let ok_sql = r#" -ALTER TABLE "recipe" ADD COLUMN "public" boolean; - "#; - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - #[test] - fn not_null_with_default() { - let ok_sql = r#" -ALTER TABLE "recipe" ADD COLUMN "public" boolean NOT NULL DEFAULT true; - "#; - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - #[test] - fn not_null_without_default() { - let bad_sql = r#" -ALTER TABLE "recipe" ADD COLUMN "public" boolean NOT NULL; - "#; - assert_debug_snapshot!(lint_sql(bad_sql)); - } - #[test] - fn generated_stored_not_null() { - let ok_sql = r" - ALTER TABLE foo - ADD COLUMN bar numeric GENERATED ALWAYS AS (bar + baz) STORED NOT NULL; - "; - assert_debug_snapshot!(lint_sql(ok_sql)); - } - #[test] - fn generated_stored() { - let ok_sql = r" - ALTER TABLE foo - ADD COLUMN bar numeric GENERATED ALWAYS AS (bar + baz) STORED ; - "; - assert_debug_snapshot!(lint_sql(ok_sql)); - } -} diff --git a/crates/linter/src/rules/ban_alter_domain_with_add_constraint.rs b/crates/linter/src/rules/ban_alter_domain_with_add_constraint.rs deleted file mode 100644 index 8227e94d..00000000 --- a/crates/linter/src/rules/ban_alter_domain_with_add_constraint.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{RawStmt, Stmt}; - -#[must_use] -pub fn ban_alter_domain_with_add_constraint( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterDomainStmt(stmt) if stmt.subtype == "C" => { - errs.push(RuleViolation::new( - RuleViolationKind::BanAlterDomainWithAddConstraint, - raw_stmt.into(), - None, - )); - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::BanAlterDomainWithAddConstraint, - None, - false, - ) - .unwrap() - } - - #[test] - fn ban_alter_domain_without_add_constraint_is_ok() { - let sql = r" - ALTER DOMAIN domain_name_1 SET DEFAULT 1; - ALTER DOMAIN domain_name_2 SET NOT NULL; - ALTER DOMAIN domain_name_3 DROP CONSTRAINT other_domain_name; - ALTER DOMAIN domain_name_4 RENAME CONSTRAINT constraint_name TO other_constraint_name; - ALTER DOMAIN domain_name_5 RENAME TO other_domain_name; - ALTER DOMAIN domain_name_6 VALIDATE CONSTRAINT constraint_name; - ALTER DOMAIN domain_name_7 OWNER TO you; - ALTER DOMAIN domain_name_8 SET SCHEMA foo; - "; - assert_eq!(lint_sql(sql), vec![]); - } - - #[test] - fn ban_alter_domain_with_add_constraint_works() { - let sql = r" - ALTER DOMAIN domain_name ADD CONSTRAINT constraint_name CHECK (value > 0); - "; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/ban_char_field.rs b/crates/linter/src/rules/ban_char_field.rs deleted file mode 100644 index dd796bd8..00000000 --- a/crates/linter/src/rules/ban_char_field.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{RawStmt, Stmt, TableElt}; - -#[must_use] -pub fn ban_char_type( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - 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 type_name = &column_def.type_name; - for field_type_name in &type_name.names { - if field_type_name.string.sval == "bpchar" { - errs.push(RuleViolation::new( - RuleViolationKind::BanCharField, - column_def.into(), - None, - )); - } - } - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::BanCharField, None, false).unwrap() - } - - #[test] - fn creating_table_with_char_errors() { - let sql = r#" -BEGIN; -CREATE TABLE "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "alpha" char(100) NOT NULL, - "beta" character(100) NOT NULL, - "charlie" char NOT NULL, - "delta" character NOT NULL -); -COMMIT; - "#; - assert_debug_snapshot!(lint_sql(sql)); - } - - #[test] - fn creating_table_with_var_char_and_text_okay() { - let sql = r#" -BEGIN; -CREATE TABLE "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "alpha" varchar(100) NOT NULL, - "beta" text NOT NULL -); -COMMIT; - "#; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/ban_concurrent_index_creation_in_transaction.rs b/crates/linter/src/rules/ban_concurrent_index_creation_in_transaction.rs deleted file mode 100644 index 25885ef1..00000000 --- a/crates/linter/src/rules/ban_concurrent_index_creation_in_transaction.rs +++ /dev/null @@ -1,122 +0,0 @@ -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind}; - -use squawk_parser::ast::{RawStmt, Stmt, TransactionStmtKind}; - -#[must_use] -pub fn ban_concurrent_index_creation_in_transaction( - tree: &[RawStmt], - _pg_version: Option, - assume_in_transaction: bool, -) -> Vec { - let mut in_transaction = assume_in_transaction; - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::TransactionStmt(stmt) => { - if (stmt.kind == TransactionStmtKind::Begin - || stmt.kind == TransactionStmtKind::Start) - && !in_transaction - { - in_transaction = true; - } - if stmt.kind == TransactionStmtKind::Commit { - in_transaction = false; - } - } - Stmt::IndexStmt(stmt) => { - if stmt.concurrent && in_transaction { - if assume_in_transaction && tree.len() == 1 { - // Migration tools should not require the transaction here so this is usually safe - continue; - } - errs.push(RuleViolation::new( - RuleViolationKind::BanConcurrentIndexCreationInTransaction, - raw_stmt.into(), - None, - )); - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::BanConcurrentIndexCreationInTransaction, - None, - false, - ) - .unwrap() - } - - fn lint_sql_assuming_in_transaction(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::BanConcurrentIndexCreationInTransaction, - None, - true, - ) - .unwrap() - } - - #[test] - fn adding_index_concurrently_in_transaction() { - let bad_sql = r#" - -- instead of - BEGIN; - CREATE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - COMMIT; - "#; - - assert_debug_snapshot!(lint_sql(bad_sql)); - - let ok_sql = r#" - -- run outside a transaction - CREATE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - "#; - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - #[test] - fn adding_index_concurrently_in_transaction_with_assume_in_transaction() { - let bad_sql = r#" - -- instead of - CREATE UNIQUE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - ALTER TABLE "table_name" ADD CONSTRAINT "field_name_id" UNIQUE USING INDEX "field_name_idx"; - "#; - - assert_debug_snapshot!(lint_sql_assuming_in_transaction(bad_sql)); - - let ok_sql = r#" - -- run index creation in a standalone migration - CREATE UNIQUE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - "#; - assert_debug_snapshot!(lint_sql_assuming_in_transaction(ok_sql)); - } - - #[test] - fn adding_index_concurrently_in_transaction_with_assume_in_transaction_but_outside() { - let ok_sql = r#" - -- the following will work too - COMMIT; - CREATE UNIQUE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - BEGIN; - ALTER TABLE "table_name" ADD CONSTRAINT "field_name_id" UNIQUE USING INDEX "field_name_idx"; - "#; - - assert_debug_snapshot!(lint_sql_assuming_in_transaction(ok_sql)); - } -} diff --git a/crates/linter/src/rules/ban_create_domain_with_constraint.rs b/crates/linter/src/rules/ban_create_domain_with_constraint.rs deleted file mode 100644 index 77b614e2..00000000 --- a/crates/linter/src/rules/ban_create_domain_with_constraint.rs +++ /dev/null @@ -1,64 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{RawStmt, Stmt}; - -#[must_use] -pub fn ban_create_domain_with_constraint( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::CreateDomainStmt(stmt) if !stmt.constraints.is_empty() => { - errs.push(RuleViolation::new( - RuleViolationKind::BanCreateDomainWithConstraint, - raw_stmt.into(), - None, - )); - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::BanCreateDomainWithConstraint, - None, - false, - ) - .unwrap() - } - - #[test] - fn ban_create_domain_without_constraint_is_ok() { - let sql = r" - CREATE DOMAIN domain_name_1 AS TEXT; - CREATE DOMAIN domain_name_2 AS CHARACTER VARYING; - "; - assert_eq!(lint_sql(sql), vec![]); - } - - #[test] - fn ban_create_domain_with_constraint_works() { - let sql = r" - CREATE DOMAIN domain_name_3 AS NUMERIC(15,5) CHECK (value > 0); - "; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/ban_drop_column.rs b/crates/linter/src/rules/ban_drop_column.rs deleted file mode 100644 index 78fd8983..00000000 --- a/crates/linter/src/rules/ban_drop_column.rs +++ /dev/null @@ -1,55 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{AlterTableCmds, AlterTableType, RawStmt, Stmt}; - -#[must_use] -pub fn ban_drop_column( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for cmd in &stmt.cmds { - let AlterTableCmds::AlterTableCmd(cmd) = cmd; - if cmd.subtype == AlterTableType::DropColumn { - errs.push(RuleViolation::new( - RuleViolationKind::BanDropColumn, - raw_stmt.into(), - None, - )); - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::BanDropColumn, None, false).unwrap() - } - - #[test] - fn drop_column() { - let sql = r#" -ALTER TABLE "bar_tbl" DROP COLUMN "foo_col" CASCADE; - "#; - - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/ban_drop_database.rs b/crates/linter/src/rules/ban_drop_database.rs deleted file mode 100644 index 15cd88e9..00000000 --- a/crates/linter/src/rules/ban_drop_database.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{RawStmt, Stmt}; - -/// Brad's Rule aka ban dropping database statements. -#[must_use] -pub fn ban_drop_database( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::DropdbStmt(_) => { - errs.push(RuleViolation::new( - RuleViolationKind::BanDropDatabase, - raw_stmt.into(), - None, - )); - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::BanDropDatabase, None, false).unwrap() - } - - #[test] - fn ban_drop_database() { - let sql = r#" -DROP DATABASE "table_name"; -DROP DATABASE IF EXISTS "table_name"; -DROP DATABASE IF EXISTS "table_name" - "#; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/ban_drop_not_null.rs b/crates/linter/src/rules/ban_drop_not_null.rs deleted file mode 100644 index e89c9217..00000000 --- a/crates/linter/src/rules/ban_drop_not_null.rs +++ /dev/null @@ -1,51 +0,0 @@ -use crate::{versions::Version, violations::RuleViolation, violations::RuleViolationKind}; - -use squawk_parser::ast::{AlterTableCmds, AlterTableType, RawStmt, Stmt}; - -#[must_use] -pub fn ban_drop_not_null( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for cmd in &stmt.cmds { - let AlterTableCmds::AlterTableCmd(cmd) = cmd; - if cmd.subtype == AlterTableType::DropNotNull { - errs.push(RuleViolation::new( - RuleViolationKind::BanDropNotNull, - raw_stmt.into(), - None, - )); - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::BanDropNotNull, None, false).unwrap() - } - - #[test] - fn ban_drop_not_null() { - let bad_sql = r#" -ALTER TABLE "bar_tbl" ALTER COLUMN "foo_col" DROP NOT NULL; - "#; - assert_debug_snapshot!(lint_sql(bad_sql)); - } -} diff --git a/crates/linter/src/rules/ban_drop_table.rs b/crates/linter/src/rules/ban_drop_table.rs deleted file mode 100644 index ed7466fe..00000000 --- a/crates/linter/src/rules/ban_drop_table.rs +++ /dev/null @@ -1,51 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; - -#[must_use] -pub fn ban_drop_table( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::DropStmt(stmt) if stmt.remove_type == ObjectType::Table => { - errs.push(RuleViolation::new( - RuleViolationKind::BanDropTable, - raw_stmt.into(), - None, - )); - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::BanDropTable, None, false).unwrap() - } - - #[test] - fn ban_drop_table() { - let sql = r#" -DROP TABLE "table_name"; -DROP TABLE IF EXISTS "table_name"; -DROP TABLE IF EXISTS "table_name" - "#; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/changing_column_type.rs b/crates/linter/src/rules/changing_column_type.rs deleted file mode 100644 index 43ef516d..00000000 --- a/crates/linter/src/rules/changing_column_type.rs +++ /dev/null @@ -1,70 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{AlterTableCmds, AlterTableType, RawStmt, Stmt}; - -#[must_use] -pub fn changing_column_type( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - if cmd.subtype == AlterTableType::AlterColumnType { - errs.push(RuleViolation::new( - RuleViolationKind::ChangingColumnType, - raw_stmt.into(), - None, - )); - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::ChangingColumnType, None, false).unwrap() - } - - #[test] - fn changing_field_type() { - let bad_sql = r#" -BEGIN; --- --- Alter field edits on recipe --- -ALTER TABLE "core_recipe" ALTER COLUMN "edits" TYPE text USING "edits"::text; -COMMIT; - "#; - assert_debug_snapshot!(lint_sql(bad_sql)); - - let bad_sql = r#" -BEGIN; --- --- Alter field foo on recipe --- -ALTER TABLE "core_recipe" ALTER COLUMN "foo" TYPE varchar(255) USING "foo"::varchar(255); -ALTER TABLE "core_recipe" ALTER COLUMN "foo" TYPE text USING "foo"::text; -COMMIT; - "#; - - assert_debug_snapshot!(lint_sql(bad_sql)); - } -} diff --git a/crates/linter/src/rules/constraint_missing_not_valid.rs b/crates/linter/src/rules/constraint_missing_not_valid.rs deleted file mode 100644 index 0fa41724..00000000 --- a/crates/linter/src/rules/constraint_missing_not_valid.rs +++ /dev/null @@ -1,282 +0,0 @@ -use std::collections::HashSet; - -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind, ViolationMessage}; -use crate::{rules::utils::tables_created_in_transaction, violations::Span}; -use squawk_parser::ast::{ - 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: &[RawStmt], assume_in_transaction: bool) -> Vec { - let mut not_valid_names = HashSet::new(); - let mut in_transaction = assume_in_transaction; - let mut bad_spans = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::TransactionStmt(stmt) => { - if (stmt.kind == TransactionStmtKind::Begin - || stmt.kind == TransactionStmtKind::Start) - && !in_transaction - { - in_transaction = true; - not_valid_names.clear(); - } - if stmt.kind == TransactionStmtKind::Commit { - in_transaction = false; - } - } - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - if cmd.subtype == AlterTableType::ValidateConstraint { - if let Some(constraint_name) = &cmd.name { - if in_transaction && not_valid_names.contains(constraint_name) { - bad_spans.push(raw_stmt.into()); - } - } - } - match &cmd.def { - Some(AlterTableDef::Constraint(constraint)) => { - if !constraint.initially_valid { - if let Some(constraint_name) = &constraint.conname { - not_valid_names.insert(constraint_name); - } - } - } - _ => continue, - } - } - } - _ => continue, - } - } - bad_spans -} - -#[must_use] -pub fn constraint_missing_not_valid( - tree: &[RawStmt], - _pg_version: Option, - assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - let tables_created = tables_created_in_transaction(tree, assume_in_transaction); - for span in not_valid_validate_in_transaction(tree, assume_in_transaction) { - errs.push(RuleViolation::new( - RuleViolationKind::ConstraintMissingNotValid, - span, - Some(vec![ - ViolationMessage::Note("Using NOT VALID and VALIDATE CONSTRAINT in the same transaction will block all reads while the constraint is validated.".into()), ViolationMessage::Help("Add constraint as NOT VALID in one transaction and VALIDATE CONSTRAINT in a separate transaction.".into()) - ]), - )); - } - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - let range = &stmt.relation; - let tbl_name = &range.relname; - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - match &cmd.def { - Some(AlterTableDef::Constraint(constraint)) => { - if !tables_created.contains(tbl_name) && constraint.initially_valid { - errs.push(RuleViolation::new( - RuleViolationKind::ConstraintMissingNotValid, - raw_stmt.into(), - None, - )); - } - } - _ => continue, - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::ConstraintMissingNotValid, - None, - false, - ) - .unwrap() - } - - fn lint_sql_assuming_in_transaction(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::ConstraintMissingNotValid, - None, - true, - ) - .unwrap() - } - - #[test] - fn ensure_ignored_when_new_table() { - let sql = r#" -BEGIN; -CREATE TABLE "core_foo" ( -"id" serial NOT NULL PRIMARY KEY, -"age" integer NOT NULL -); -ALTER TABLE "core_foo" ADD CONSTRAINT "age_restriction" CHECK ("age" >= 25); -COMMIT; - "#; - - assert_debug_snapshot!(lint_sql(sql)); - } - - #[test] - fn ensure_ignored_when_new_table_with_assume_in_transaction() { - let sql = r#" -CREATE TABLE "core_foo" ( -"id" serial NOT NULL PRIMARY KEY, -"age" integer NOT NULL -); -ALTER TABLE "core_foo" ADD CONSTRAINT "age_restriction" CHECK ("age" >= 25); - "#; - - assert_debug_snapshot!(lint_sql_assuming_in_transaction(sql)); - } - - /// Using NOT VALID and VALIDATE in a single transaction is equivalent to - /// adding a constraint without NOT VALID. It will block! - #[test] - fn not_valid_validate_in_transaction() { - let sql = r#" -BEGIN; -ALTER TABLE "app_email" ADD CONSTRAINT "fk_user" FOREIGN KEY (user_id) REFERENCES "app_user" (id) NOT VALID; -ALTER TABLE "app_email" VALIDATE CONSTRAINT "fk_user"; -COMMIT; -"#; - let res = lint_sql(sql); - assert_eq!( - res.len(), - 1, - "it's unsafe to run NOT VALID with VALIDATE in a transaction." - ); - assert_eq!(res[0].kind, RuleViolationKind::ConstraintMissingNotValid); - // We have a custom error message for this case. - assert_debug_snapshot!(res[0].messages); - } - - /// Using NOT VALID and VALIDATE in a single transaction is equivalent to - /// adding a constraint without NOT VALID. It will block! - #[test] - fn not_valid_validate_with_assume_in_transaction() { - let sql = r#" -ALTER TABLE "app_email" ADD CONSTRAINT "fk_user" FOREIGN KEY (user_id) REFERENCES "app_user" (id) NOT VALID; -ALTER TABLE "app_email" VALIDATE CONSTRAINT "fk_user"; -"#; - let res = lint_sql_assuming_in_transaction(sql); - assert_eq!( - res.len(), - 1, - "it's unsafe to run NOT VALID with VALIDATE in a transaction." - ); - assert_eq!(res[0].kind, RuleViolationKind::ConstraintMissingNotValid); - // We have a custom error message for this case. - assert_debug_snapshot!(res[0].messages); - } - - /// This builds off of the previous test to see that the error is correctly - /// attributed when using the "assume in transaction" option and an - /// explicit COMMIT. - #[test] - fn not_valid_validate_with_assume_in_transaction_with_explicit_commit() { - let sql = r#" -ALTER TABLE "app_email" ADD CONSTRAINT "fk_user" FOREIGN KEY (user_id) REFERENCES "app_user" (id) NOT VALID; -ALTER TABLE "app_email" VALIDATE CONSTRAINT "fk_user"; -COMMIT; -"#; - let res = lint_sql_assuming_in_transaction(sql); - assert_eq!( - res.len(), - 1, - "it's unsafe to run NOT VALID with VALIDATE in a transaction." - ); - assert_eq!(res[0].kind, RuleViolationKind::ConstraintMissingNotValid); - // We have a custom error message for this case. - assert_debug_snapshot!(res[0].messages); - } - - /// ```sql - /// -- instead of - /// ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses (address); - /// -- use `NOT VALID` - /// ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses (address) NOT VALID; - /// ALTER TABLE distributors VALIDATE CONSTRAINT distfk; - /// ``` - #[test] - fn adding_foreign_key() { - let bad_sql = r" --- instead of -ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses (address); - "; - - assert_debug_snapshot!(lint_sql(bad_sql)); - - let ok_sql = r" --- use `NOT VALID` -ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses (address) NOT VALID; -ALTER TABLE distributors VALIDATE CONSTRAINT distfk; - "; - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - /// - /// ```sql - /// -- instead of - /// ALTER TABLE "accounts" ADD CONSTRAINT "positive_balance" CHECK ("balance" >= 0); - /// - /// -- use `NOT VALID` - /// ALTER TABLE "accounts" ADD CONSTRAINT "positive_balance" CHECK ("balance" >= 0) NOT VALID; - /// ALTER TABLE accounts VALIDATE CONSTRAINT positive_balance; - /// ``` - #[test] - fn adding_check_constraint() { - let bad_sql = r#" --- instead of -ALTER TABLE "accounts" ADD CONSTRAINT "positive_balance" CHECK ("balance" >= 0); - "#; - - let ok_sql = r#" --- use `NOT VALID` -ALTER TABLE "accounts" ADD CONSTRAINT "positive_balance" CHECK ("balance" >= 0) NOT VALID; -ALTER TABLE accounts VALIDATE CONSTRAINT positive_balance; - "#; - - assert_debug_snapshot!(lint_sql(bad_sql)); - - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - #[test] - fn regression_with_indexing_2() { - let sql = r#" -BEGIN; -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; -ALTER TABLE "core_recipe" ADD CONSTRAINT foo_not_null - CHECK ("foo" IS NOT NULL) NOT VALID; -COMMIT; -BEGIN; - -"#; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/disallow_unique_constraint.rs b/crates/linter/src/rules/disallow_unique_constraint.rs deleted file mode 100644 index 4d122eac..00000000 --- a/crates/linter/src/rules/disallow_unique_constraint.rs +++ /dev/null @@ -1,172 +0,0 @@ -use crate::rules::utils::tables_created_in_transaction; -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind}; - -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDefConstraint, ConstrType, RawStmt, Stmt, -}; - -#[must_use] -pub fn disallow_unique_constraint( - tree: &[RawStmt], - _pg_version: Option, - assume_in_transaction: bool, -) -> Vec { - let tables_created = tables_created_in_transaction(tree, assume_in_transaction); - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::AlterTableStmt(stmt) => { - let range = &stmt.relation; - let tbl_name = &range.relname; - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - match (&cmd.def, &cmd.subtype) { - ( - Some(AlterTableDef::Constraint(constraint)), - AlterTableType::AddConstraint, - ) => { - if !tables_created.contains(tbl_name) - && constraint.contype == ConstrType::Unique - && constraint.indexname.is_none() - { - errs.push(RuleViolation::new( - RuleViolationKind::DisallowedUniqueConstraint, - raw_stmt.into(), - None, - )); - } - } - (Some(AlterTableDef::ColumnDef(col)), AlterTableType::AddColumn) => { - for ColumnDefConstraint::Constraint(constraint) in &col.constraints { - if constraint.contype == ConstrType::Unique { - errs.push(RuleViolation::new( - RuleViolationKind::DisallowedUniqueConstraint, - raw_stmt.into(), - None, - )); - } - } - } - _ => continue, - } - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::DisallowedUniqueConstraint, - None, - false, - ) - .unwrap() - } - - fn lint_sql_assuming_in_transaction(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::DisallowedUniqueConstraint, - None, - true, - ) - .unwrap() - } - - /// ```sql - /// -- instead of - /// ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name); - /// -- also works with PRIMARY KEY - /// -- use: - /// -- To recreate a primary key constraint, without blocking updates while the index is rebuilt: - /// CREATE UNIQUE INDEX CONCURRENTLY dist_id_temp_idx ON distributors (dist_id); - /// ALTER TABLE distributors DROP CONSTRAINT distributors_pkey, - /// ADD CONSTRAINT distributors_pkey PRIMARY KEY USING INDEX dist_id_temp_idx; - /// ``` - #[test] - fn adding_unique_constraint() { - let bad_sql = r" -ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name); - "; - - let ignored_sql = r" -ALTER TABLE table_name DROP CONSTRAINT field_name_constraint; - "; - - let ok_sql = r" -CREATE UNIQUE INDEX CONCURRENTLY dist_id_temp_idx ON distributors (dist_id); -ALTER TABLE distributors DROP CONSTRAINT distributors_pkey, -ADD CONSTRAINT distributors_pkey PRIMARY KEY USING INDEX dist_id_temp_idx; - "; - - assert_debug_snapshot!(lint_sql(bad_sql)); - assert_debug_snapshot!(lint_sql(ignored_sql)); - assert_debug_snapshot!(lint_sql(ok_sql)); - } - - /// Creating a UNIQUE constraint from an existing index should be considered - /// safe - #[test] - fn unique_constraint_ok() { - let sql = r#" -CREATE UNIQUE INDEX CONCURRENTLY "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq_idx" - ON "legacy_questiongrouppg" ("mongo_id"); -ALTER TABLE "legacy_questiongrouppg" ADD CONSTRAINT "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq" UNIQUE USING INDEX "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq_idx"; - "#; - assert_eq!(lint_sql(sql), vec![]); - } - - /// Creating a UNIQUE constraint in the same transaction as the table is create is OK. - #[test] - fn unique_constraint_after_create_table() { - let sql = r" -BEGIN; -CREATE TABLE products ( - id bigint generated by default as identity primary key, - sku text not null -); -ALTER TABLE products ADD CONSTRAINT sku_constraint UNIQUE (sku); -COMMIT; - "; - assert_eq!(lint_sql(sql), vec![]); - } - - /// Creating a UNIQUE constraint in the same transaction as the table is create is OK. - #[test] - fn unique_constraint_after_create_table_with_assume_in_transaction() { - let sql = r" -CREATE TABLE products ( - id bigint generated by default as identity primary key, - sku text not null -); -ALTER TABLE products ADD CONSTRAINT sku_constraint UNIQUE (sku); - "; - assert_eq!(lint_sql_assuming_in_transaction(sql), vec![]); - } - #[test] - fn unique_constraint_inline_add_column() { - let sql = r" -ALTER TABLE foo ADD COLUMN bar text CONSTRAINT foo_bar_unique UNIQUE; - "; - assert_debug_snapshot!(lint_sql(sql)); - } - #[test] - fn unique_constraint_inline_add_column_unique() { - let sql = r" -ALTER TABLE foo ADD COLUMN bar text UNIQUE; -"; - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/mod.rs b/crates/linter/src/rules/mod.rs deleted file mode 100644 index 1dc3fbc9..00000000 --- a/crates/linter/src/rules/mod.rs +++ /dev/null @@ -1,58 +0,0 @@ -pub mod adding_field_with_default; -mod test_utils; -mod utils; -pub use adding_field_with_default::*; -pub mod adding_not_null_field; -pub use adding_not_null_field::*; -pub mod adding_primary_key_constraint; -pub use adding_primary_key_constraint::*; -pub mod ban_drop_database; -pub use ban_drop_database::*; -pub mod changing_column_type; -pub use changing_column_type::*; -pub mod constraint_missing_not_valid; -pub use constraint_missing_not_valid::*; -pub mod disallow_unique_constraint; -pub use disallow_unique_constraint::*; -pub mod prefer_robust_stmts; -pub use prefer_robust_stmts::*; -pub mod prefer_text_field; -pub use prefer_text_field::*; -pub mod renaming_column; -pub use renaming_column::*; -pub mod renaming_table; -pub use renaming_table::*; -pub mod ban_drop_column; -pub use ban_drop_column::*; -pub mod require_concurrent_index_creation; -pub use require_concurrent_index_creation::*; -pub mod ban_char_field; -pub mod require_concurrent_index_deletion; -pub use ban_char_field::*; -pub use require_concurrent_index_deletion::*; -pub mod adding_foreign_key_constraint; -pub use adding_foreign_key_constraint::*; -pub mod prefer_timestamptz; -pub use prefer_timestamptz::*; -pub mod prefer_identity; -pub use prefer_identity::*; -pub mod prefer_big_int; -pub use prefer_big_int::*; -pub mod prefer_bigint_over_int; -pub use prefer_bigint_over_int::*; -pub mod prefer_bigint_over_smallint; -pub use prefer_bigint_over_smallint::*; -pub mod ban_drop_table; -pub use ban_drop_table::*; -pub mod ban_drop_not_null; -pub use ban_drop_not_null::*; -pub mod transaction_nesting; -pub use transaction_nesting::*; -pub mod adding_required_field; -pub use adding_required_field::*; -pub mod ban_concurrent_index_creation_in_transaction; -pub use ban_concurrent_index_creation_in_transaction::*; -pub mod ban_create_domain_with_constraint; -pub use ban_create_domain_with_constraint::*; -pub mod ban_alter_domain_with_add_constraint; -pub use ban_alter_domain_with_add_constraint::*; diff --git a/crates/linter/src/rules/non_volatile_built_in_functions.txt b/crates/linter/src/rules/non_volatile_built_in_functions.txt deleted file mode 100644 index cc13e6d7..00000000 --- a/crates/linter/src/rules/non_volatile_built_in_functions.txt +++ /dev/null @@ -1,2963 +0,0 @@ -boolin -boolout -byteain -byteaout -charin -charout -namein -nameout -int2in -int2out -int2vectorin -int2vectorout -int4in -int4out -regprocin -regprocout -to_regproc -to_regprocedure -textin -textout -tidin -tidout -xidin -xidout -xid8in -xid8out -xid8recv -xid8send -cidin -cidout -oidvectorin -oidvectorout -boollt -boolgt -booleq -chareq -nameeq -int2eq -int2lt -int4eq -int4lt -texteq -starts_with -xideq -xidneq -xid8eq -xid8ne -xid8lt -xid8gt -xid8le -xid8ge -xid8cmp -xid -cideq -charne -charlt -charle -chargt -charge -int4 -char -nameregexeq -nameregexne -textregexeq -textregexne -textregexeq_support -textlen -textcat -boolne -version -pg_ddl_command_in -pg_ddl_command_out -pg_ddl_command_recv -pg_ddl_command_send -eqsel -neqsel -scalarltsel -scalargtsel -eqjoinsel -neqjoinsel -scalarltjoinsel -scalargtjoinsel -scalarlesel -scalargesel -scalarlejoinsel -scalargejoinsel -unknownin -unknownout -box_above_eq -box_below_eq -point_in -point_out -lseg_in -lseg_out -path_in -path_out -box_in -box_out -box_overlap -box_ge -box_gt -box_eq -box_lt -box_le -point_above -point_left -point_right -point_below -point_eq -on_pb -on_ppath -box_center -areasel -areajoinsel -int4mul -int4ne -int2ne -int2gt -int4gt -int2le -int4le -int4ge -int2ge -int2mul -int2div -int4div -int2mod -int4mod -textne -int24eq -int42eq -int24lt -int42lt -int24gt -int42gt -int24ne -int42ne -int24le -int42le -int24ge -int42ge -int24mul -int42mul -int24div -int42div -int2pl -int4pl -int24pl -int42pl -int2mi -int4mi -int24mi -int42mi -oideq -oidne -box_same -box_contain -box_left -box_overleft -box_overright -box_right -box_contained -box_contain_pt -pg_node_tree_in -pg_node_tree_out -pg_node_tree_recv -pg_node_tree_send -float4in -float4out -float4mul -float4div -float4pl -float4mi -float4um -float4abs -float4_accum -float4larger -float4smaller -int4um -int2um -float8in -float8out -float8mul -float8div -float8pl -float8mi -float8um -float8abs -float8_accum -float8_combine -float8larger -float8smaller -lseg_center -path_center -poly_center -dround -dtrunc -ceil -ceiling -floor -sign -dsqrt -dcbrt -dpow -dexp -dlog1 -float8 -float4 -int2 -int2 -line_distance -nameeqtext -namelttext -nameletext -namegetext -namegttext -namenetext -btnametextcmp -texteqname -textltname -textlename -textgename -textgtname -textnename -bttextnamecmp -nameconcatoid -inter_sl -inter_lb -float48mul -float48div -float48pl -float48mi -float84mul -float84div -float84pl -float84mi -float4eq -float4ne -float4lt -float4le -float4gt -float4ge -float8eq -float8ne -float8lt -float8le -float8gt -float8ge -float48eq -float48ne -float48lt -float48le -float48gt -float48ge -float84eq -float84ne -float84lt -float84le -float84gt -float84ge -width_bucket -float8 -float4 -int4 -int2 -float8 -int4 -float4 -int4 -pg_indexam_has_property -pg_index_has_property -pg_index_column_has_property -pg_indexam_progress_phasename -poly_same -poly_contain -poly_left -poly_overleft -poly_overright -poly_right -poly_contained -poly_overlap -poly_in -poly_out -btint2cmp -btint2sortsupport -btint4cmp -btint4sortsupport -btint8cmp -btint8sortsupport -btfloat4cmp -btfloat4sortsupport -btfloat8cmp -btfloat8sortsupport -btoidcmp -btoidsortsupport -btoidvectorcmp -btcharcmp -btnamecmp -btnamesortsupport -bttextcmp -bttextsortsupport -btvarstrequalimage -cash_cmp -btarraycmp -in_range -in_range -in_range -in_range -in_range -in_range -in_range -in_range -in_range -in_range -lseg_distance -lseg_interpt -dist_ps -dist_sp -dist_pb -dist_bp -dist_sb -dist_bs -close_ps -close_pb -close_sb -on_ps -path_distance -dist_ppath -dist_pathp -on_sb -inter_sb -text -text -name -bpchar -name -hashint2 -hashint2extended -hashint4 -hashint4extended -hashint8 -hashint8extended -hashfloat4 -hashfloat4extended -hashfloat8 -hashfloat8extended -hashoid -hashoidextended -hashchar -hashcharextended -hashname -hashnameextended -hashtext -hashtextextended -hashvarlena -hashvarlenaextended -hashoidvector -hashoidvectorextended -hash_aclitem -hash_aclitem_extended -hashmacaddr -hashmacaddrextended -hashinet -hashinetextended -hash_numeric -hash_numeric_extended -hashmacaddr8 -hashmacaddr8extended -num_nulls -num_nonnulls -text_larger -text_smaller -int8in -int8out -int8um -int8pl -int8mi -int8mul -int8div -int8eq -int8ne -int8lt -int8gt -int8le -int8ge -int84eq -int84ne -int84lt -int84gt -int84le -int84ge -int4 -int8 -float8 -int8 -hash_array -hash_array_extended -float4 -int8 -int2 -int8 -namelt -namele -namegt -namege -namene -bpchar -varchar_support -varchar -oidvectorne -oidvectorlt -oidvectorle -oidvectoreq -oidvectorge -oidvectorgt -getpgusername -oidlt -oidle -octet_length -get_byte -set_byte -get_bit -set_bit -overlay -overlay -bit_count -dist_pl -dist_lp -dist_lb -dist_bl -dist_sl -dist_ls -dist_cpoly -dist_polyc -poly_distance -dist_ppoly -dist_polyp -dist_cpoint -text_lt -text_le -text_gt -text_ge -current_user -session_user -array_eq -array_ne -array_lt -array_gt -array_le -array_ge -array_dims -array_ndims -array_in -array_out -array_lower -array_upper -array_length -cardinality -array_append -array_prepend -array_cat -string_to_array -string_to_array -string_to_table -string_to_table -array_to_string -array_to_string -array_larger -array_smaller -array_position -array_position -array_positions -generate_subscripts -generate_subscripts -array_fill -array_fill -unnest -array_unnest_support -array_remove -array_replace -array_agg_transfn -array_agg_finalfn -array_agg -array_agg_array_transfn -array_agg_array_finalfn -array_agg -width_bucket -trim_array -array_typanalyze -arraycontsel -arraycontjoinsel -int4inc -int4larger -int4smaller -int2larger -int2smaller -cash_mul_flt4 -cash_div_flt4 -flt4_mul_cash -position -textlike -textlike_support -textnlike -int48eq -int48ne -int48lt -int48gt -int48le -int48ge -namelike -namenlike -bpchar -current_database -int8_mul_cash -int4_mul_cash -int2_mul_cash -cash_mul_int8 -cash_div_int8 -cash_mul_int4 -cash_div_int4 -cash_mul_int2 -cash_div_int2 -cash_in -cash_out -cash_eq -cash_ne -cash_lt -cash_le -cash_gt -cash_ge -cash_pl -cash_mi -cash_mul_flt8 -cash_div_flt8 -cashlarger -cashsmaller -flt8_mul_cash -cash_words -cash_div_cash -numeric -money -money -money -mod -mod -int8mod -mod -gcd -gcd -lcm -lcm -char -text -on_pl -on_sl -close_pl -close_sl -close_lb -path_inter -area -width -height -box_distance -area -box_intersect -bound_box -diagonal -path_n_lt -path_n_gt -path_n_eq -path_n_le -path_n_ge -path_length -point_ne -point_vert -point_horiz -point_distance -slope -lseg -lseg_intersect -lseg_parallel -lseg_perp -lseg_vertical -lseg_horizontal -lseg_eq -timezone -aclitemin -aclitemout -aclinsert -aclremove -aclcontains -aclitemeq -makeaclitem -acldefault -aclexplode -bpcharin -bpcharout -bpchartypmodin -bpchartypmodout -varcharin -varcharout -varchartypmodin -varchartypmodout -bpchareq -bpcharlt -bpcharle -bpchargt -bpcharge -bpcharne -bpchar_larger -bpchar_smaller -bpcharcmp -bpchar_sortsupport -hashbpchar -hashbpcharextended -format_type -date_in -date_out -date_eq -date_lt -date_le -date_gt -date_ge -date_ne -date_cmp -date_sortsupport -in_range -time_lt -time_le -time_gt -time_ge -time_ne -time_cmp -date_larger -date_smaller -date_mi -date_pli -date_mii -time_in -time_out -timetypmodin -timetypmodout -time_eq -circle_add_pt -circle_sub_pt -circle_mul_pt -circle_div_pt -timestamptz_in -timestamptz_out -timestamptztypmodin -timestamptztypmodout -timestamptz_eq -timestamptz_ne -timestamptz_lt -timestamptz_le -timestamptz_ge -timestamptz_gt -to_timestamp -timezone -interval_in -interval_out -intervaltypmodin -intervaltypmodout -interval_eq -interval_ne -interval_lt -interval_le -interval_ge -interval_gt -interval_um -interval_pl -interval_mi -date_part -extract -date_part -extract -timestamptz -justify_interval -justify_hours -justify_days -date -age -mxid_age -timestamptz_mi -timestamptz_pl_interval -timestamptz_mi_interval -timestamptz_smaller -timestamptz_larger -interval_smaller -interval_larger -age -interval_support -interval -date_trunc -date_trunc -date_trunc -int8inc -int8dec -int8inc_any -int8dec_any -int8abs -int8larger -int8smaller -texticregexeq -texticregexeq_support -texticregexne -nameicregexeq -nameicregexne -int4abs -int2abs -overlaps -datetime_pl -date_part -extract -int84pl -int84mi -int84mul -int84div -int48pl -int48mi -int48mul -int48div -int82pl -int82mi -int82mul -int82div -int28pl -int28mi -int28mul -int28div -oid -int8 -tideq -tidne -tidgt -tidlt -tidge -tidle -bttidcmp -tidlarger -tidsmaller -hashtid -hashtidextended -datetimetz_pl -now -transaction_timestamp -statement_timestamp -positionsel -positionjoinsel -contsel -contjoinsel -overlaps -overlaps -timestamp_in -timestamp_out -timestamptypmodin -timestamptypmodout -timestamptz_cmp -interval_cmp -time -length -length -xideqint4 -xidneqint4 -interval_div -dlog10 -log -log10 -ln -round -trunc -sqrt -cbrt -pow -power -exp -oidvectortypes -timetz_in -timetz_out -timetztypmodin -timetztypmodout -timetz_eq -timetz_ne -obj_description -timetz_lt -timetz_le -timetz_ge -timetz_gt -timetz_cmp -timestamptz -character_length -character_length -interval -char_length -octet_length -octet_length -time_larger -time_smaller -timetz_larger -timetz_smaller -char_length -extract -date_part -extract -timetz -isfinite -isfinite -isfinite -factorial -abs -abs -abs -abs -abs -name -varchar -current_schema -current_schemas -overlay -overlay -isvertical -ishorizontal -isparallel -isperp -isvertical -ishorizontal -isparallel -isperp -isvertical -ishorizontal -point -time -box -box_add -box_sub -box_mul -box_div -poly_contain_pt -pt_contained_poly -isclosed -isopen -path_npoints -pclose -popen -path_add -path_add_pt -path_sub_pt -path_mul_pt -path_div_pt -point -point_add -point_sub -point_mul -point_div -poly_npoints -box -path -polygon -polygon -circle_in -circle_out -circle_same -circle_contain -circle_left -circle_overleft -circle_overright -circle_right -circle_contained -circle_overlap -circle_below -circle_above -circle_eq -circle_ne -circle_lt -circle_gt -circle_le -circle_ge -area -diameter -radius -circle_distance -circle_center -circle -circle -polygon -dist_pc -circle_contain_pt -pt_contained_circle -box -circle -box -lseg_ne -lseg_lt -lseg_le -lseg_gt -lseg_ge -lseg_length -close_ls -close_lseg -line_in -line_out -line_eq -line -line_interpt -line_intersect -line_parallel -line_perp -line_vertical -line_horizontal -length -length -point -point -point -point -lseg -center -center -npoints -npoints -bit_in -bit_out -bittypmodin -bittypmodout -like -notlike -like -notlike -pg_sequence_parameters -varbit_in -varbit_out -varbittypmodin -varbittypmodout -biteq -bitne -bitge -bitgt -bitle -bitlt -bitcmp -asin -acos -atan -atan2 -sin -cos -tan -cot -asind -acosd -atand -atan2d -sind -cosd -tand -cotd -degrees -radians -pi -sinh -cosh -tanh -asinh -acosh -atanh -interval_mul -ascii -chr -repeat -similar_escape -similar_to_escape -similar_to_escape -mul_d_interval -bpcharlike -bpcharnlike -texticlike -texticlike_support -texticnlike -nameiclike -nameicnlike -like_escape -bpcharicregexeq -bpcharicregexne -bpcharregexeq -bpcharregexne -bpchariclike -bpcharicnlike -strpos -lower -upper -initcap -lpad -rpad -ltrim -rtrim -substr -translate -ltrim -rtrim -substr -btrim -btrim -substring -substring -replace -regexp_replace -regexp_replace -regexp_match -regexp_match -regexp_matches -regexp_matches -split_part -regexp_split_to_table -regexp_split_to_table -regexp_split_to_array -regexp_split_to_array -to_hex -to_hex -getdatabaseencoding -pg_client_encoding -length -convert_from -convert_to -convert -pg_char_to_encoding -pg_encoding_to_char -pg_encoding_max_length -oidgt -oidge -pg_get_ruledef -pg_get_viewdef -pg_get_viewdef -pg_get_userbyid -pg_get_indexdef -pg_get_statisticsobjdef -pg_get_statisticsobjdef_columns -pg_get_statisticsobjdef_expressions -pg_get_partkeydef -pg_get_partition_constraintdef -pg_get_triggerdef -pg_get_constraintdef -pg_get_expr -pg_get_serial_sequence -pg_get_functiondef -pg_get_function_arguments -pg_get_function_identity_arguments -pg_get_function_result -pg_get_function_arg_default -pg_get_function_sqlbody -pg_get_keywords -pg_get_catalog_foreign_keys -pg_options_to_table -pg_typeof -pg_collation_for -pg_relation_is_updatable -pg_column_is_updatable -pg_get_replica_identity_index -varbiteq -varbitne -varbitge -varbitgt -varbitle -varbitlt -varbitcmp -bitand -bitor -bitxor -bitnot -bitshiftleft -bitshiftright -bitcat -substring -length -octet_length -bit -int4 -bit -varbit_support -varbit -position -substring -overlay -overlay -get_bit -set_bit -bit_count -macaddr_in -macaddr_out -trunc -macaddr_eq -macaddr_lt -macaddr_le -macaddr_gt -macaddr_ge -macaddr_ne -macaddr_cmp -macaddr_not -macaddr_and -macaddr_or -macaddr_sortsupport -macaddr8_in -macaddr8_out -trunc -macaddr8_eq -macaddr8_lt -macaddr8_le -macaddr8_gt -macaddr8_ge -macaddr8_ne -macaddr8_cmp -macaddr8_not -macaddr8_and -macaddr8_or -macaddr8 -macaddr -macaddr8_set7bit -inet_in -inet_out -cidr_in -cidr_out -network_eq -network_lt -network_le -network_gt -network_ge -network_ne -network_larger -network_smaller -network_cmp -network_sub -network_subeq -network_sup -network_supeq -network_subset_support -network_overlap -network_sortsupport -abbrev -abbrev -set_masklen -set_masklen -family -network -netmask -masklen -broadcast -host -text -hostmask -cidr -inet_client_addr -inet_client_port -inet_server_addr -inet_server_port -inetnot -inetand -inetor -inetpl -inetmi_int8 -inetmi -inet_same_family -inet_merge -inet_gist_consistent -inet_gist_union -inet_gist_compress -inet_gist_fetch -inet_gist_penalty -inet_gist_picksplit -inet_gist_same -inet_spg_config -inet_spg_choose -inet_spg_picksplit -inet_spg_inner_consistent -inet_spg_leaf_consistent -networksel -networkjoinsel -time_mi_time -boolle -boolge -btboolcmp -time_hash -time_hash_extended -timetz_hash -timetz_hash_extended -interval_hash -interval_hash_extended -numeric_in -numeric_out -numerictypmodin -numerictypmodout -numeric_support -numeric -numeric_abs -abs -sign -round -trunc -ceil -ceiling -floor -numeric_eq -numeric_ne -numeric_gt -numeric_ge -numeric_lt -numeric_le -numeric_add -numeric_sub -numeric_mul -numeric_div -mod -numeric_mod -gcd -lcm -sqrt -numeric_sqrt -exp -numeric_exp -ln -numeric_ln -log -numeric_log -pow -power -numeric_power -scale -min_scale -trim_scale -numeric -numeric -numeric -int4 -float4 -float8 -div -numeric_div_trunc -width_bucket -time_pl_interval -time_mi_interval -timetz_pl_interval -timetz_mi_interval -numeric_inc -numeric_smaller -numeric_larger -numeric_cmp -numeric_sortsupport -numeric_uminus -int8 -numeric -numeric -int2 -pg_lsn -bool -numeric -int2 -int4 -int8 -float4 -float8 -to_char -to_char -to_char -to_char -to_char -to_char -to_number -to_timestamp -to_date -to_char -quote_ident -quote_literal -quote_literal -quote_nullable -quote_nullable -oidin -oidout -concat -concat_ws -left -right -reverse -format -format -iclikesel -icnlikesel -iclikejoinsel -icnlikejoinsel -regexeqsel -likesel -icregexeqsel -regexnesel -nlikesel -icregexnesel -regexeqjoinsel -likejoinsel -icregexeqjoinsel -regexnejoinsel -nlikejoinsel -icregexnejoinsel -prefixsel -prefixjoinsel -float8_avg -float8_var_pop -float8_var_samp -float8_stddev_pop -float8_stddev_samp -numeric_accum -numeric_combine -numeric_avg_accum -numeric_avg_combine -numeric_avg_serialize -numeric_avg_deserialize -numeric_serialize -numeric_deserialize -numeric_accum_inv -int2_accum -int4_accum -int8_accum -numeric_poly_combine -numeric_poly_serialize -numeric_poly_deserialize -int8_avg_accum -int2_accum_inv -int4_accum_inv -int8_accum_inv -int8_avg_accum_inv -int8_avg_combine -int8_avg_serialize -int8_avg_deserialize -int4_avg_combine -numeric_sum -numeric_avg -numeric_var_pop -numeric_var_samp -numeric_stddev_pop -numeric_stddev_samp -int2_sum -int4_sum -int8_sum -numeric_poly_sum -numeric_poly_avg -numeric_poly_var_pop -numeric_poly_var_samp -numeric_poly_stddev_pop -numeric_poly_stddev_samp -interval_accum -interval_combine -interval_accum_inv -interval_avg -int2_avg_accum -int4_avg_accum -int2_avg_accum_inv -int4_avg_accum_inv -int8_avg -int2int4_sum -int8inc_float8_float8 -float8_regr_accum -float8_regr_combine -float8_regr_sxx -float8_regr_syy -float8_regr_sxy -float8_regr_avgx -float8_regr_avgy -float8_regr_r2 -float8_regr_slope -float8_regr_intercept -float8_covar_pop -float8_covar_samp -float8_corr -string_agg_transfn -string_agg_finalfn -string_agg -bytea_string_agg_transfn -bytea_string_agg_finalfn -string_agg -to_ascii -to_ascii -to_ascii -int28eq -int28ne -int28lt -int28gt -int28le -int28ge -int82eq -int82ne -int82lt -int82gt -int82le -int82ge -int2and -int2or -int2xor -int2not -int2shl -int2shr -int4and -int4or -int4xor -int4not -int4shl -int4shr -int8and -int8or -int8xor -int8not -int8shl -int8shr -int8up -int2up -int4up -float4up -float8up -numeric_uplus -has_table_privilege -has_table_privilege -has_table_privilege -has_table_privilege -has_table_privilege -has_table_privilege -has_sequence_privilege -has_sequence_privilege -has_sequence_privilege -has_sequence_privilege -has_sequence_privilege -has_sequence_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_column_privilege -has_any_column_privilege -has_any_column_privilege -has_any_column_privilege -has_any_column_privilege -has_any_column_privilege -has_any_column_privilege -pg_ndistinct_in -pg_ndistinct_out -pg_ndistinct_recv -pg_ndistinct_send -pg_dependencies_in -pg_dependencies_out -pg_dependencies_recv -pg_dependencies_send -pg_mcv_list_in -pg_mcv_list_out -pg_mcv_list_recv -pg_mcv_list_send -pg_mcv_list_items -pg_stat_get_numscans -pg_stat_get_tuples_returned -pg_stat_get_tuples_fetched -pg_stat_get_tuples_inserted -pg_stat_get_tuples_updated -pg_stat_get_tuples_deleted -pg_stat_get_tuples_hot_updated -pg_stat_get_live_tuples -pg_stat_get_dead_tuples -pg_stat_get_mod_since_analyze -pg_stat_get_ins_since_vacuum -pg_stat_get_blocks_fetched -pg_stat_get_blocks_hit -pg_stat_get_last_vacuum_time -pg_stat_get_last_autovacuum_time -pg_stat_get_last_analyze_time -pg_stat_get_last_autoanalyze_time -pg_stat_get_vacuum_count -pg_stat_get_autovacuum_count -pg_stat_get_analyze_count -pg_stat_get_autoanalyze_count -pg_stat_get_backend_idset -pg_stat_get_db_tuples_deleted -pg_stat_get_db_conflict_tablespace -pg_stat_get_db_conflict_lock -pg_stat_get_db_conflict_snapshot -pg_stat_get_activity -pg_stat_get_progress_info -pg_stat_get_wal_senders -pg_stat_get_wal_receiver -pg_stat_get_replication_slot -pg_stat_get_subscription -pg_backend_pid -pg_stat_get_backend_pid -pg_stat_get_backend_dbid -pg_stat_get_backend_userid -pg_stat_get_backend_activity -pg_stat_get_backend_wait_event_type -pg_stat_get_backend_wait_event -pg_stat_get_backend_activity_start -pg_stat_get_backend_xact_start -pg_stat_get_backend_start -pg_stat_get_backend_client_addr -pg_stat_get_backend_client_port -pg_stat_get_db_numbackends -pg_stat_get_db_xact_commit -pg_stat_get_db_xact_rollback -pg_stat_get_db_blocks_fetched -pg_stat_get_db_blocks_hit -pg_stat_get_db_tuples_returned -pg_stat_get_db_tuples_fetched -pg_stat_get_db_tuples_inserted -pg_stat_get_db_tuples_updated -pg_stat_get_db_conflict_bufferpin -pg_stat_get_db_conflict_startup_deadlock -pg_stat_get_db_conflict_all -pg_stat_get_db_deadlocks -pg_stat_get_db_checksum_failures -pg_stat_get_db_checksum_last_failure -pg_stat_get_db_stat_reset_time -pg_stat_get_db_temp_files -pg_stat_get_db_temp_bytes -pg_stat_get_db_blk_read_time -pg_stat_get_db_blk_write_time -pg_stat_get_db_session_time -pg_stat_get_db_active_time -pg_stat_get_db_idle_in_transaction_time -pg_stat_get_db_sessions -pg_stat_get_db_sessions_abandoned -pg_stat_get_db_sessions_fatal -pg_stat_get_db_sessions_killed -pg_stat_get_archiver -pg_stat_get_bgwriter_timed_checkpoints -pg_stat_get_bgwriter_requested_checkpoints -pg_stat_get_bgwriter_buf_written_checkpoints -pg_stat_get_bgwriter_buf_written_clean -pg_stat_get_bgwriter_maxwritten_clean -pg_stat_get_bgwriter_stat_reset_time -pg_stat_get_checkpoint_write_time -pg_stat_get_checkpoint_sync_time -pg_stat_get_buf_written_backend -pg_stat_get_buf_fsync_backend -pg_stat_get_buf_alloc -pg_stat_get_wal -pg_stat_get_slru -pg_stat_get_function_calls -pg_stat_get_function_total_time -pg_stat_get_function_self_time -pg_stat_get_snapshot_timestamp -pg_trigger_depth -pg_tablespace_location -encode -decode -byteaeq -bytealt -byteale -byteagt -byteage -byteane -byteacmp -bytea_sortsupport -timestamp_support -time_support -timestamp -oidlarger -oidsmaller -timestamptz -time -timetz -textanycat -anytextcat -bytealike -byteanlike -like -notlike -like_escape -length -byteacat -substring -substring -substr -substr -position -btrim -ltrim -rtrim -time -date_trunc -date_bin -date_bin -date_part -extract -timestamp -timestamp -timestamp -timestamptz -date -timestamp_mi -timestamp_pl_interval -timestamp_mi_interval -timestamp_smaller -timestamp_larger -timezone -timestamp_hash -timestamp_hash_extended -overlaps -timestamp_cmp -timestamp_sortsupport -in_range -in_range -in_range -in_range -in_range -time -timetz -isfinite -to_char -timestamp_eq -timestamp_ne -timestamp_lt -timestamp_le -timestamp_ge -timestamp_gt -age -timezone -timezone -date_pl_interval -date_mi_interval -substring -bit -int8 -current_setting -current_setting -pg_show_all_settings -pg_describe_object -pg_identify_object -pg_identify_object_as_address -pg_get_object_address -pg_table_is_visible -pg_type_is_visible -pg_function_is_visible -pg_operator_is_visible -pg_opclass_is_visible -pg_opfamily_is_visible -pg_conversion_is_visible -pg_statistics_obj_is_visible -pg_ts_parser_is_visible -pg_ts_dict_is_visible -pg_ts_template_is_visible -pg_ts_config_is_visible -pg_collation_is_visible -pg_my_temp_schema -pg_is_other_temp_schema -pg_backup_start_time -pg_walfile_name_offset -pg_walfile_name -pg_wal_lsn_diff -text -avg -avg -avg -avg -avg -avg -avg -sum -sum -sum -sum -sum -sum -sum -sum -max -max -max -max -max -max -max -max -max -max -max -max -max -max -max -max -max -max -max -max -min -min -min -min -min -min -min -min -min -min -min -min -min -min -min -min -min -min -min -min -count -count -var_pop -var_pop -var_pop -var_pop -var_pop -var_pop -var_samp -var_samp -var_samp -var_samp -var_samp -var_samp -variance -variance -variance -variance -variance -variance -stddev_pop -stddev_pop -stddev_pop -stddev_pop -stddev_pop -stddev_pop -stddev_samp -stddev_samp -stddev_samp -stddev_samp -stddev_samp -stddev_samp -stddev -stddev -stddev -stddev -stddev -stddev -regr_count -regr_sxx -regr_syy -regr_sxy -regr_avgx -regr_avgy -regr_r2 -regr_slope -regr_intercept -covar_pop -covar_samp -corr -text_pattern_lt -text_pattern_le -text_pattern_ge -text_pattern_gt -bttext_pattern_cmp -bttext_pattern_sortsupport -bpchar_pattern_lt -bpchar_pattern_le -bpchar_pattern_ge -bpchar_pattern_gt -btbpchar_pattern_cmp -btbpchar_pattern_sortsupport -btint48cmp -btint84cmp -btint24cmp -btint42cmp -btint28cmp -btint82cmp -btfloat48cmp -btfloat84cmp -regprocedurein -regprocedureout -regoperin -regoperout -to_regoper -to_regoperator -regoperatorin -regoperatorout -regclassin -regclassout -to_regclass -regcollationin -regcollationout -to_regcollation -regtypein -regtypeout -to_regtype -regclass -regrolein -regroleout -to_regrole -regnamespacein -regnamespaceout -to_regnamespace -fmgr_internal_validator -fmgr_c_validator -fmgr_sql_validator -has_database_privilege -has_database_privilege -has_database_privilege -has_database_privilege -has_database_privilege -has_database_privilege -has_function_privilege -has_function_privilege -language_handler_in -has_function_privilege -has_function_privilege -has_function_privilege -has_function_privilege -has_language_privilege -has_language_privilege -has_language_privilege -has_language_privilege -has_language_privilege -has_language_privilege -has_schema_privilege -has_schema_privilege -has_schema_privilege -has_schema_privilege -has_schema_privilege -has_schema_privilege -has_tablespace_privilege -has_tablespace_privilege -has_tablespace_privilege -has_tablespace_privilege -has_tablespace_privilege -has_tablespace_privilege -has_foreign_data_wrapper_privilege -has_foreign_data_wrapper_privilege -has_foreign_data_wrapper_privilege -has_foreign_data_wrapper_privilege -has_foreign_data_wrapper_privilege -has_foreign_data_wrapper_privilege -has_server_privilege -has_server_privilege -has_server_privilege -has_server_privilege -has_server_privilege -has_server_privilege -has_type_privilege -has_type_privilege -has_type_privilege -has_type_privilege -has_type_privilege -has_type_privilege -pg_has_role -pg_has_role -pg_has_role -pg_has_role -pg_has_role -pg_has_role -pg_column_size -pg_column_compression -pg_size_pretty -pg_size_pretty -pg_size_bytes -pg_relation_filenode -pg_filenode_relation -pg_relation_filepath -postgresql_fdw_validator -record_in -record_out -cstring_in -cstring_out -any_in -any_out -anyarray_in -anyarray_out -void_in -void_out -trigger_in -trigger_out -event_trigger_in -event_trigger_out -language_handler_out -internal_in -internal_out -anyelement_in -anyelement_out -shell_in -shell_out -domain_in -domain_recv -anynonarray_in -anynonarray_out -fdw_handler_in -fdw_handler_out -index_am_handler_in -index_am_handler_out -tsm_handler_in -tsm_handler_out -table_am_handler_in -table_am_handler_out -anycompatible_in -anycompatible_out -anycompatiblearray_in -anycompatiblearray_out -anycompatiblearray_recv -anycompatiblearray_send -anycompatiblenonarray_in -anycompatiblenonarray_out -anycompatiblerange_in -anycompatiblerange_out -anycompatiblemultirange_in -anycompatiblemultirange_out -md5 -md5 -sha224 -sha256 -sha384 -sha512 -date_lt_timestamp -date_le_timestamp -date_eq_timestamp -date_gt_timestamp -date_ge_timestamp -date_ne_timestamp -date_cmp_timestamp -date_lt_timestamptz -date_le_timestamptz -date_eq_timestamptz -date_gt_timestamptz -date_ge_timestamptz -date_ne_timestamptz -date_cmp_timestamptz -timestamp_lt_date -timestamp_le_date -timestamp_eq_date -timestamp_gt_date -timestamp_ge_date -timestamp_ne_date -timestamp_cmp_date -timestamptz_lt_date -timestamptz_le_date -timestamptz_eq_date -timestamptz_gt_date -timestamptz_ge_date -timestamptz_ne_date -timestamptz_cmp_date -timestamp_lt_timestamptz -timestamp_le_timestamptz -timestamp_eq_timestamptz -timestamp_gt_timestamptz -timestamp_ge_timestamptz -timestamp_ne_timestamptz -timestamp_cmp_timestamptz -timestamptz_lt_timestamp -timestamptz_le_timestamp -timestamptz_eq_timestamp -timestamptz_gt_timestamp -timestamptz_ge_timestamp -timestamptz_ne_timestamp -timestamptz_cmp_timestamp -array_recv -array_send -record_recv -record_send -int2recv -int2send -int4recv -int4send -int8recv -int8send -int2vectorrecv -int2vectorsend -bytearecv -byteasend -textrecv -textsend -unknownrecv -unknownsend -oidrecv -oidsend -oidvectorrecv -oidvectorsend -namerecv -namesend -float4recv -float4send -float8recv -float8send -point_recv -point_send -bpcharrecv -bpcharsend -varcharrecv -varcharsend -charrecv -charsend -boolrecv -boolsend -tidrecv -tidsend -xidrecv -xidsend -cidrecv -cidsend -regprocrecv -regprocsend -regprocedurerecv -regproceduresend -regoperrecv -regopersend -regoperatorrecv -regoperatorsend -regclassrecv -regclasssend -regcollationrecv -regcollationsend -regtyperecv -regtypesend -regrolerecv -regrolesend -regnamespacerecv -regnamespacesend -bit_recv -bit_send -varbit_recv -varbit_send -numeric_recv -numeric_send -date_recv -date_send -time_recv -time_send -timetz_recv -timetz_send -timestamp_recv -timestamp_send -timestamptz_recv -timestamptz_send -interval_recv -interval_send -lseg_recv -lseg_send -path_recv -path_send -box_recv -box_send -poly_recv -poly_send -line_recv -line_send -circle_recv -circle_send -cash_recv -cash_send -macaddr_recv -macaddr_send -inet_recv -inet_send -cidr_recv -cidr_send -cstring_recv -cstring_send -anyarray_recv -anyarray_send -void_recv -void_send -macaddr8_recv -macaddr8_send -pg_get_ruledef -pg_get_viewdef -pg_get_viewdef -pg_get_viewdef -pg_get_indexdef -pg_get_constraintdef -pg_get_expr -pg_prepared_statement -pg_cursor -pg_timezone_abbrevs -pg_timezone_names -pg_get_triggerdef -pg_listening_channels -generate_series -generate_series -generate_series_int4_support -generate_series -generate_series -generate_series_int8_support -generate_series -generate_series -generate_series -generate_series -booland_statefunc -boolor_statefunc -bool_accum -bool_accum_inv -bool_alltrue -bool_anytrue -bool_and -bool_or -every -bit_and -bit_or -bit_xor -bit_and -bit_or -bit_xor -bit_and -bit_or -bit_xor -bit_and -bit_or -bit_xor -pg_tablespace_databases -bool -int4 -pg_postmaster_start_time -pg_conf_load_time -box_below -box_overbelow -box_overabove -box_above -poly_below -poly_overbelow -poly_overabove -poly_above -circle_overbelow -circle_overabove -gist_box_consistent -gist_box_penalty -gist_box_picksplit -gist_box_union -gist_box_same -gist_box_distance -gist_poly_consistent -gist_poly_compress -gist_circle_consistent -gist_circle_compress -gist_point_compress -gist_point_fetch -gist_point_consistent -gist_point_distance -gist_circle_distance -gist_poly_distance -gist_point_sortsupport -ginarrayextract -ginqueryarrayextract -ginarrayconsistent -pg_lsn_lt -ginarraytriconsistent -ginarrayextract -arrayoverlap -arraycontains -arraycontained -brin_minmax_opcinfo -brin_minmax_add_value -brin_minmax_consistent -brin_minmax_union -brin_minmax_multi_opcinfo -brin_minmax_multi_add_value -brin_minmax_multi_consistent -brin_minmax_multi_union -brin_minmax_multi_options -brin_minmax_multi_distance_int2 -brin_minmax_multi_distance_int4 -brin_minmax_multi_distance_int8 -brin_minmax_multi_distance_float4 -brin_minmax_multi_distance_float8 -brin_minmax_multi_distance_numeric -brin_minmax_multi_distance_tid -brin_minmax_multi_distance_uuid -brin_minmax_multi_distance_date -brin_minmax_multi_distance_time -brin_minmax_multi_distance_interval -brin_minmax_multi_distance_timetz -brin_minmax_multi_distance_pg_lsn -brin_minmax_multi_distance_macaddr -brin_minmax_multi_distance_macaddr8 -brin_minmax_multi_distance_inet -brin_minmax_multi_distance_timestamp -brin_inclusion_opcinfo -brin_inclusion_add_value -brin_inclusion_consistent -brin_inclusion_union -brin_bloom_opcinfo -brin_bloom_add_value -brin_bloom_consistent -brin_bloom_union -brin_bloom_options -xml_in -xml_out -xmlcomment -xml -xmlvalidate -xml_recv -xml_send -xmlconcat2 -xmlagg -text -table_to_xml -table_to_xmlschema -table_to_xml_and_xmlschema -schema_to_xml -schema_to_xmlschema -schema_to_xml_and_xmlschema -database_to_xml -database_to_xmlschema -database_to_xml_and_xmlschema -xpath -xmlexists -xpath_exists -xml_is_well_formed -xml_is_well_formed_document -xml_is_well_formed_content -json_in -json_out -json_recv -json_send -array_to_json -array_to_json -row_to_json -row_to_json -json_agg_transfn -json_agg_finalfn -json_agg -json_object_agg_transfn -json_object_agg_finalfn -json_object_agg -json_build_array -json_build_array -json_build_object -json_build_object -json_object -json_object -to_json -json_strip_nulls -json_object_field -json_object_field_text -json_array_element -json_array_element_text -json_extract_path -json_extract_path_text -json_array_elements -json_array_elements_text -json_array_length -json_object_keys -json_each -json_each_text -json_to_record -json_to_recordset -json_typeof -uuid_in -uuid_out -uuid_lt -uuid_le -uuid_eq -uuid_ge -uuid_gt -uuid_ne -uuid_cmp -uuid_sortsupport -uuid_recv -uuid_send -uuid_hash -uuid_hash_extended -pg_lsn_in -pg_lsn_out -pg_lsn_le -pg_lsn_eq -pg_lsn_ge -pg_lsn_gt -pg_lsn_ne -pg_lsn_mi -pg_lsn_recv -pg_lsn_send -pg_lsn_cmp -pg_lsn_hash -pg_lsn_hash_extended -pg_lsn_larger -pg_lsn_smaller -pg_lsn_pli -pg_lsn_mii -anyenum_in -anyenum_out -enum_in -enum_out -enum_eq -enum_ne -enum_lt -enum_gt -enum_le -enum_ge -enum_cmp -hashenum -hashenumextended -enum_smaller -enum_larger -max -min -enum_first -enum_last -enum_range -enum_range -enum_recv -enum_send -tsvectorin -tsvectorrecv -tsvectorout -tsvectorsend -tsqueryin -tsqueryrecv -tsqueryout -tsquerysend -gtsvectorin -gtsvectorout -tsvector_lt -tsvector_le -tsvector_eq -tsvector_ne -tsvector_ge -tsvector_gt -tsvector_cmp -length -strip -setweight -setweight -tsvector_concat -ts_delete -ts_delete -unnest -tsvector_to_array -array_to_tsvector -ts_filter -ts_match_vq -ts_match_qv -ts_match_tt -ts_match_tq -gtsvector_compress -gtsvector_decompress -gtsvector_picksplit -gtsvector_union -gtsvector_same -gtsvector_penalty -gtsvector_consistent -gtsvector_consistent -gtsvector_options -gin_extract_tsvector -gin_extract_tsquery -gin_tsquery_consistent -gin_tsquery_triconsistent -gin_cmp_tslexeme -gin_cmp_prefix -gin_extract_tsvector -gin_extract_tsquery -gin_tsquery_consistent -gin_extract_tsquery -gin_tsquery_consistent -tsquery_lt -tsquery_le -tsquery_eq -tsquery_ne -tsquery_ge -tsquery_gt -tsquery_cmp -tsquery_and -tsquery_or -tsquery_phrase -tsquery_phrase -tsquery_not -tsq_mcontains -tsq_mcontained -numnode -querytree -ts_rewrite -gtsquery_compress -gtsquery_picksplit -gtsquery_union -gtsquery_same -gtsquery_penalty -gtsquery_consistent -gtsquery_consistent -tsmatchsel -tsmatchjoinsel -ts_typanalyze -ts_rank -ts_rank -ts_rank -ts_rank -ts_rank_cd -ts_rank_cd -ts_rank_cd -ts_rank_cd -ts_token_type -ts_token_type -ts_parse -ts_parse -prsd_start -prsd_nexttoken -prsd_end -prsd_headline -prsd_lextype -ts_lexize -dsimple_init -dsimple_lexize -dsynonym_init -dsynonym_lexize -dispell_init -dispell_lexize -thesaurus_init -thesaurus_lexize -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -ts_headline -to_tsvector -to_tsquery -plainto_tsquery -phraseto_tsquery -websearch_to_tsquery -to_tsvector -to_tsquery -plainto_tsquery -phraseto_tsquery -websearch_to_tsquery -to_tsvector -jsonb_to_tsvector -to_tsvector -json_to_tsvector -to_tsvector -jsonb_to_tsvector -to_tsvector -json_to_tsvector -get_current_ts_config -regconfigin -regconfigout -regconfigrecv -regconfigsend -regdictionaryin -regdictionaryout -regdictionaryrecv -regdictionarysend -jsonb_in -jsonb_recv -jsonb_out -jsonb_send -jsonb_object -jsonb_object -to_jsonb -jsonb_agg_transfn -jsonb_agg_finalfn -jsonb_agg -jsonb_object_agg_transfn -jsonb_object_agg_finalfn -jsonb_object_agg -jsonb_build_array -jsonb_build_array -jsonb_build_object -jsonb_build_object -jsonb_strip_nulls -jsonb_object_field -jsonb_object_field_text -jsonb_array_element -jsonb_array_element_text -jsonb_extract_path -jsonb_extract_path_text -jsonb_array_elements -jsonb_array_elements_text -jsonb_array_length -jsonb_object_keys -jsonb_each -jsonb_each_text -jsonb_populate_record -jsonb_populate_recordset -jsonb_to_record -jsonb_to_recordset -jsonb_typeof -jsonb_ne -jsonb_lt -jsonb_gt -jsonb_le -jsonb_ge -jsonb_eq -jsonb_cmp -jsonb_hash -jsonb_hash_extended -jsonb_contains -jsonb_exists -jsonb_exists_any -jsonb_exists_all -jsonb_contained -gin_compare_jsonb -gin_extract_jsonb -gin_extract_jsonb_query -gin_consistent_jsonb -gin_triconsistent_jsonb -gin_extract_jsonb_path -gin_extract_jsonb_query_path -gin_consistent_jsonb_path -gin_triconsistent_jsonb_path -jsonb_concat -jsonb_delete -jsonb_delete -jsonb_delete -jsonb_delete_path -jsonb_pretty -jsonpath_in -jsonpath_recv -jsonpath_out -jsonpath_send -jsonb_insert -jsonb_path_query -jsonb_path_query_first -jsonb_path_query_array_tz -jsonb_path_exists_opr -jsonb_path_match_opr -txid_snapshot_in -txid_snapshot_out -txid_snapshot_recv -txid_snapshot_send -txid_current -txid_current_if_assigned -txid_current_snapshot -txid_snapshot_xmin -txid_snapshot_xmax -txid_snapshot_xip -txid_visible_in_snapshot -pg_snapshot_in -pg_snapshot_out -pg_snapshot_recv -pg_snapshot_send -pg_current_snapshot -pg_snapshot_xmin -pg_snapshot_xmax -pg_snapshot_xip -pg_visible_in_snapshot -pg_current_xact_id -pg_current_xact_id_if_assigned -record_eq -record_ne -record_lt -record_gt -record_le -record_ge -btrecordcmp -hash_record -hash_record_extended -record_image_eq -record_image_ne -record_image_lt -record_image_gt -record_image_le -record_image_ge -btrecordimagecmp -btequalimage -pg_available_extensions -pg_available_extension_versions -pg_extension_update_paths -row_number -rank -dense_rank -percent_rank -cume_dist -ntile -lag -lag -lag -lead -lead -lead -first_value -last_value -nth_value -anyrange_in -anyrange_out -range_in -range_out -range_recv -range_send -lower -upper -isempty -lower_inc -upper_inc -lower_inf -upper_inf -range_eq -range_ne -range_overlaps -range_contains_elem -range_contains -elem_contained_by_range -range_contained_by -range_adjacent -range_before -range_after -range_overleft -range_overright -range_union -range_merge -range_merge -range_intersect -range_minus -range_cmp -range_lt -range_le -range_ge -range_gt -range_gist_consistent -range_gist_union -range_gist_penalty -range_gist_picksplit -range_gist_same -multirange_gist_consistent -multirange_gist_compress -hash_range -hash_range_extended -range_typanalyze -rangesel -range_intersect_agg_transfn -range_intersect_agg -int4range_canonical -int8range_canonical -daterange_canonical -int4range_subdiff -int8range_subdiff -numrange_subdiff -daterange_subdiff -tsrange_subdiff -tstzrange_subdiff -int4range -int4range -numrange -numrange -tsrange -tsrange -tstzrange -tstzrange -daterange -daterange -int8range -int8range -anymultirange_in -anymultirange_out -multirange_in -multirange_out -multirange_recv -multirange_send -lower -upper -isempty -lower_inc -upper_inc -lower_inf -upper_inf -multirange_typanalyze -multirangesel -multirange_eq -multirange_ne -range_overlaps_multirange -multirange_overlaps_range -multirange_overlaps_multirange -multirange_contains_elem -multirange_contains_range -multirange_contains_multirange -elem_contained_by_multirange -range_contained_by_multirange -range_contains_multirange -multirange_contained_by_range -multirange_contained_by_multirange -range_adjacent_multirange -multirange_adjacent_multirange -multirange_adjacent_range -range_before_multirange -multirange_before_range -multirange_before_multirange -range_after_multirange -multirange_after_range -multirange_after_multirange -range_overleft_multirange -multirange_overleft_range -multirange_overleft_multirange -range_overright_multirange -multirange_overright_range -multirange_overright_multirange -multirange_union -multirange_minus -multirange_intersect -multirange_cmp -multirange_lt -multirange_le -multirange_ge -multirange_gt -hash_multirange -hash_multirange_extended -int4multirange -int4multirange -int4multirange -nummultirange -nummultirange -nummultirange -tsmultirange -tsmultirange -tsmultirange -tstzmultirange -tstzmultirange -spg_range_quad_inner_consistent -tstzmultirange -datemultirange -datemultirange -datemultirange -int8multirange -int8multirange -int8multirange -multirange -range_agg_transfn -range_agg_finalfn -range_agg -multirange_intersect_agg_transfn -range_intersect_agg -unnest -make_date -make_time -make_timestamp -make_timestamptz -make_timestamptz -spg_quad_config -spg_quad_choose -spg_quad_picksplit -spg_quad_inner_consistent -spg_quad_leaf_consistent -spg_kd_config -spg_kd_choose -spg_kd_picksplit -spg_kd_inner_consistent -spg_text_config -spg_text_choose -spg_text_picksplit -spg_text_inner_consistent -spg_text_leaf_consistent -spg_range_quad_config -spg_range_quad_choose -spg_range_quad_picksplit -spg_range_quad_leaf_consistent -spg_box_quad_config -spg_box_quad_choose -spg_box_quad_picksplit -spg_box_quad_inner_consistent -spg_box_quad_leaf_consistent -spg_bbox_quad_config -spg_poly_quad_compress -pg_get_replication_slots -pg_event_trigger_dropped_objects -pg_event_trigger_table_rewrite_oid -pg_event_trigger_table_rewrite_reason -pg_event_trigger_ddl_commands -ordered_set_transition -ordered_set_transition_multi -percentile_disc -percentile_disc_final -percentile_cont -percentile_cont_float8_final -percentile_cont -percentile_cont_interval_final -percentile_disc -percentile_disc_multi_final -percentile_cont -percentile_cont_float8_multi_final -percentile_cont -percentile_cont_interval_multi_final -mode -mode_final -rank -rank_final -percent_rank -percent_rank_final -cume_dist -cume_dist_final -dense_rank -dense_rank_final -koi8r_to_mic -mic_to_koi8r -iso_to_mic -mic_to_iso -win1251_to_mic -mic_to_win1251 -win866_to_mic -mic_to_win866 -koi8r_to_win1251 -win1251_to_koi8r -koi8r_to_win866 -win866_to_koi8r -win866_to_win1251 -win1251_to_win866 -iso_to_koi8r -koi8r_to_iso -iso_to_win1251 -win1251_to_iso -iso_to_win866 -win866_to_iso -euc_cn_to_mic -mic_to_euc_cn -euc_jp_to_sjis -sjis_to_euc_jp -euc_jp_to_mic -sjis_to_mic -mic_to_euc_jp -mic_to_sjis -euc_kr_to_mic -mic_to_euc_kr -euc_tw_to_big5 -big5_to_euc_tw -euc_tw_to_mic -big5_to_mic -mic_to_euc_tw -mic_to_big5 -latin2_to_mic -mic_to_latin2 -win1250_to_mic -mic_to_win1250 -latin2_to_win1250 -win1250_to_latin2 -latin1_to_mic -mic_to_latin1 -latin3_to_mic -mic_to_latin3 -latin4_to_mic -mic_to_latin4 -big5_to_utf8 -utf8_to_big5 -utf8_to_koi8r -koi8r_to_utf8 -utf8_to_koi8u -koi8u_to_utf8 -utf8_to_win -win_to_utf8 -euc_cn_to_utf8 -utf8_to_euc_cn -euc_jp_to_utf8 -utf8_to_euc_jp -euc_kr_to_utf8 -utf8_to_euc_kr -euc_tw_to_utf8 -utf8_to_euc_tw -gb18030_to_utf8 -utf8_to_gb18030 -gbk_to_utf8 -utf8_to_gbk -utf8_to_iso8859 -iso8859_to_utf8 -iso8859_1_to_utf8 -utf8_to_iso8859_1 -johab_to_utf8 -utf8_to_johab -sjis_to_utf8 -utf8_to_sjis -uhc_to_utf8 -utf8_to_uhc -euc_jis_2004_to_utf8 -utf8_to_euc_jis_2004 -shift_jis_2004_to_utf8 -utf8_to_shift_jis_2004 -euc_jis_2004_to_shift_jis_2004 -shift_jis_2004_to_euc_jis_2004 -matchingsel -matchingjoinsel -pg_replication_origin_oid -pg_get_publication_tables -pg_relation_is_publishable -row_security_active -row_security_active -array_subscript_handler -raw_array_subscript_handler -jsonb_subscript_handler -satisfies_hash_partition -pg_partition_root -unistr -brin_bloom_summary_in -brin_bloom_summary_out -brin_bloom_summary_recv -pg_config -brin_bloom_summary_send -brin_minmax_multi_summary_in -brin_minmax_multi_summary_out -brin_minmax_multi_summary_recv -brin_minmax_multi_summary_send -lpad -rpad -substring -bit_length -trunc -bit_length -bit_length -log -log10 -round -numeric_pl_pg_lsn -path_contain_pt -polygon -age -age -interval_pl_timetz -date_part -timestamptz -timedate_pl -timetzdate_pl -interval_pl_time -interval_pl_date -interval_pl_timestamp -interval_pl_timestamptz -integer_pl_date -overlaps -overlaps -overlaps -overlaps -overlaps -overlaps -overlaps -overlaps -overlaps -int8pl_inet -xpath -xpath_exists -obj_description -shobj_description -col_description -ts_debug -ts_debug -json_populate_record -json_populate_recordset -make_interval -jsonb_set -jsonb_set_lax -parse_ident -jsonb_path_exists -jsonb_path_match -jsonb_path_query_array -jsonb_path_exists_tz -jsonb_path_match_tz -jsonb_path_query_tz -jsonb_path_query_first_tz -normalize -is_normalized -_pg_expandarray -_pg_index_position -_pg_truetypid -_pg_truetypmod -_pg_char_max_length -_pg_char_octet_length -_pg_numeric_precision -_pg_numeric_precision_radix -_pg_numeric_scale -_pg_datetime_precision -_pg_interval_type diff --git a/crates/linter/src/rules/prefer_big_int.rs b/crates/linter/src/rules/prefer_big_int.rs deleted file mode 100644 index 64941a03..00000000 --- a/crates/linter/src/rules/prefer_big_int.rs +++ /dev/null @@ -1,140 +0,0 @@ -use std::collections::HashSet; - -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ColumnDef, RawStmt}; - -use super::utils::columns_create_or_modified; - -#[must_use] -pub fn prefer_big_int( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - for column in columns_create_or_modified(&raw_stmt.stmt) { - check_column_def(&mut errs, column); - } - } - errs -} - -lazy_static! { - static ref SMALL_INT_TYPES: HashSet<&'static str> = HashSet::from([ - "smallint", - "integer", - "int2", - "int4", - "serial", - "serial2", - "serial4", - "smallserial", - ]); -} - -fn check_column_def(errs: &mut Vec, column_def: &ColumnDef) { - if let Some(column_name) = column_def.type_name.names.last() { - if SMALL_INT_TYPES.contains(column_name.string.sval.as_str()) { - errs.push(RuleViolation::new( - RuleViolationKind::PreferBigInt, - column_def.into(), - None, - )); - } - } -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - rules::test_utils::violations_to_kinds, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::PreferBigInt, None, false).unwrap() - } - - #[test] - fn create_table_ok() { - let ok_sql = r" -create table users ( - id bigint -); -create table users ( - id int8 -); -create table users ( - id bigserial -); -create table users ( - id serial8 -); - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } - #[test] - fn create_table_bad() { - let bad_sql = r" -create table users ( - id smallint -); -create table users ( - id int2 -); -create table users ( - id integer -); -create table users ( - id int4 -); -create table users ( - id serial -); -create table users ( - id serial2 -); -create table users ( - id serial4 -); -create table users ( - id smallserial -); - "; - let res = lint_sql(bad_sql); - let violations = violations_to_kinds(&res); - assert_eq!( - violations.len(), - 8, - "we should have 8 statements with violations" - ); - assert_eq!( - violations.len(), - violations - .into_iter() - .filter(|v| { *v == RuleViolationKind::PreferBigInt }) - .count(), - "all violations should be big int violations" - ); - assert_debug_snapshot!(res); - } - #[test] - fn create_table_many_errors() { - let bad_sql = r" -create table users ( - foo integer, - bar serial -); - "; - let res = lint_sql(bad_sql); - assert_debug_snapshot!(res); - } -} diff --git a/crates/linter/src/rules/prefer_bigint_over_int.rs b/crates/linter/src/rules/prefer_bigint_over_int.rs deleted file mode 100644 index 2dad3f65..00000000 --- a/crates/linter/src/rules/prefer_bigint_over_int.rs +++ /dev/null @@ -1,121 +0,0 @@ -use std::collections::HashSet; - -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ColumnDef, RawStmt}; - -use super::utils::columns_create_or_modified; - -#[must_use] -pub fn prefer_bigint_over_int( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - for column in columns_create_or_modified(&raw_stmt.stmt) { - check_column_def(&mut errs, column); - } - } - errs -} - -lazy_static! { - static ref INT_TYPES: HashSet<&'static str> = - HashSet::from(["integer", "int4", "serial", "serial4",]); -} - -fn check_column_def(errs: &mut Vec, column_def: &ColumnDef) { - if let Some(column_name) = column_def.type_name.names.last() { - if INT_TYPES.contains(column_name.string.sval.as_str()) { - errs.push(RuleViolation::new( - RuleViolationKind::PreferBigintOverInt, - column_def.into(), - None, - )); - } - } -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - rules::test_utils::violations_to_kinds, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::PreferBigintOverInt, None, false).unwrap() - } - - #[test] - fn create_table_ok() { - let ok_sql = r" -create table users ( - id bigint -); -create table users ( - id int8 -); -create table users ( - id bigserial -); -create table users ( - id serial8 -); -create table users ( - id smallint -); -create table users ( - id int2 -); -create table users ( - id smallserial -); -create table users ( - id serial2 -); - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } - #[test] - fn create_table_bad() { - let bad_sql = r" -create table users ( - id integer -); -create table users ( - id int4 -); -create table users ( - id serial -); -create table users ( - id serial4 -); - "; - let res = lint_sql(bad_sql); - let violations = violations_to_kinds(&res); - assert_eq!( - violations.len(), - 4, - "we should have 4 statements with violations" - ); - assert_eq!( - violations.len(), - violations - .into_iter() - .filter(|v| { *v == RuleViolationKind::PreferBigintOverInt }) - .count(), - "all violations should be big int violations" - ); - assert_debug_snapshot!(res); - } -} diff --git a/crates/linter/src/rules/prefer_bigint_over_smallint.rs b/crates/linter/src/rules/prefer_bigint_over_smallint.rs deleted file mode 100644 index ecbab033..00000000 --- a/crates/linter/src/rules/prefer_bigint_over_smallint.rs +++ /dev/null @@ -1,127 +0,0 @@ -use std::collections::HashSet; - -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ColumnDef, RawStmt}; - -use super::utils::columns_create_or_modified; - -#[must_use] -pub fn prefer_bigint_over_smallint( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - for column in columns_create_or_modified(&raw_stmt.stmt) { - check_column_def(&mut errs, column); - } - } - errs -} - -lazy_static! { - static ref SMALL_INT_TYPES: HashSet<&'static str> = - HashSet::from(["smallint", "int2", "smallserial", "serial2",]); -} - -fn check_column_def(errs: &mut Vec, column_def: &ColumnDef) { - if let Some(column_name) = column_def.type_name.names.last() { - if SMALL_INT_TYPES.contains(column_name.string.sval.as_str()) { - errs.push(RuleViolation::new( - RuleViolationKind::PreferBigintOverSmallint, - column_def.into(), - None, - )); - } - } -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - rules::test_utils::violations_to_kinds, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::PreferBigintOverSmallint, - None, - false, - ) - .unwrap() - } - - #[test] - fn create_table_ok() { - let ok_sql = r" -create table users ( - id bigint -); -create table users ( - id int8 -); -create table users ( - id bigserial -); -create table users ( - id serial8 -); -create table users ( - id integer -); -create table users ( - id int4 -); -create table users ( - id serial -); -create table users ( - id serial4 -); - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } - #[test] - fn create_table_bad() { - let bad_sql = r" -create table users ( - id smallint -); -create table users ( - id int2 -); -create table users ( - id smallserial -); -create table users ( - id serial2 -); - "; - let res = lint_sql(bad_sql); - let violations = violations_to_kinds(&res); - assert_eq!( - violations.len(), - 4, - "we should have 4 statements with violations" - ); - assert_eq!( - violations.len(), - violations - .into_iter() - .filter(|v| { *v == RuleViolationKind::PreferBigintOverSmallint }) - .count(), - "all violations should be big int violations" - ); - assert_debug_snapshot!(res); - } -} diff --git a/crates/linter/src/rules/prefer_identity.rs b/crates/linter/src/rules/prefer_identity.rs deleted file mode 100644 index 638ec614..00000000 --- a/crates/linter/src/rules/prefer_identity.rs +++ /dev/null @@ -1,117 +0,0 @@ -use std::collections::HashSet; - -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ColumnDef, RawStmt}; - -use super::utils::columns_create_or_modified; - -#[must_use] -pub fn prefer_identity( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - for column in columns_create_or_modified(&raw_stmt.stmt) { - check_column_def(&mut errs, column); - } - } - errs -} - -lazy_static! { - static ref SERIAL_TYPES: HashSet<&'static str> = HashSet::from([ - "serial", - "serial2", - "serial4", - "serial8", - "smallserial", - "bigserial", - ]); -} - -fn check_column_def(errs: &mut Vec, column_def: &ColumnDef) { - if let Some(column_name) = column_def.type_name.names.last() { - if SERIAL_TYPES.contains(column_name.string.sval.as_str()) { - errs.push(RuleViolation::new( - RuleViolationKind::PreferIdentity, - column_def.into(), - None, - )); - } - } -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - rules::test_utils::violations_to_kinds, - violations::{RuleViolation, RuleViolationKind}, - }; - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::PreferIdentity, None, false).unwrap() - } - - #[test] - fn prefer_identity_bad() { - let bad_sql = r" -create table users ( - id serial -); -create table users ( - id serial2 -); -create table users ( - id serial4 -); -create table users ( - id serial8 -); -create table users ( - id smallserial -); -create table users ( - id bigserial -); - "; - - let res = lint_sql(bad_sql); - let violations = violations_to_kinds(&res); - assert_eq!( - violations.len(), - 6, - "we should have 6 statements with violations" - ); - assert_eq!( - violations.len(), - violations - .into_iter() - .filter(|v| { *v == RuleViolationKind::PreferIdentity }) - .count(), - "all violations should be prefer-identity violations" - ); - - assert_debug_snapshot!(res); - } - #[test] - fn prefer_identity_ok() { - let ok_sql = r" -create table users ( - id bigint generated by default as identity primary key -); -create table users ( - id bigint generated always as identity primary key -); - "; - - assert_eq!(lint_sql(ok_sql), vec![]); - } -} diff --git a/crates/linter/src/rules/prefer_robust_stmts.rs b/crates/linter/src/rules/prefer_robust_stmts.rs deleted file mode 100644 index 7a92564b..00000000 --- a/crates/linter/src/rules/prefer_robust_stmts.rs +++ /dev/null @@ -1,486 +0,0 @@ -use std::collections::HashMap; - -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind, ViolationMessage}, -}; -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, RawStmt, Stmt, TransactionStmtKind, -}; -#[derive(PartialEq)] -enum Constraint { - Dropped, - Added, -} - -/// If a migration is running in a transaction, then we skip the statements -/// because if it fails part way through, it will revert. -/// For the cases where statements aren't running in a transaction, for instance, -/// when we CREATE INDEX CONCURRENTLY, we should try and make those migrations -/// 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: &[RawStmt], - _pg_version: Option, - assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - let mut inside_transaction = assume_in_transaction; - let mut constraint_names: HashMap = HashMap::new(); - // if we only have one statement in our file, Postgres will run that - // statement in an implicit transaction, so we don't need to worry about - // wrapping with `BEGIN;COMMIT;`. - if tree.len() == 1 { - return errs; - } - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::TransactionStmt(stmt) => match stmt.kind { - TransactionStmtKind::Begin | TransactionStmtKind::Start => { - inside_transaction = true; - } - TransactionStmtKind::Commit => inside_transaction = false, - _ => continue, - }, - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - if let Some(constraint_name) = &cmd.name { - if cmd.subtype == AlterTableType::DropConstraint { - constraint_names.insert(constraint_name.clone(), Constraint::Dropped); - } - if (cmd.subtype == AlterTableType::AddConstraint - || cmd.subtype == AlterTableType::ValidateConstraint) - && constraint_names.contains_key(constraint_name) - { - continue; - } - } - - if cmd.subtype == AlterTableType::EnableRowSecurity - || cmd.subtype == AlterTableType::DisableRowSecurity - { - continue; - } - - if let Some(AlterTableDef::Constraint(constraint)) = &cmd.def { - if let Some(constraint_name) = &constraint.conname { - if let Some(constraint) = constraint_names.get_mut(constraint_name) { - if *constraint == Constraint::Dropped { - *constraint = Constraint::Added; - continue; - } - } - } - } - if cmd.missing_ok || inside_transaction { - continue; - } - errs.push(RuleViolation::new( - RuleViolationKind::PreferRobustStmts, - raw_stmt.into(), - None, - )); - } - } - // bad: CREATE INDEX CONCURRENTLY ON .. - // good: CREATE INDEX CONCURRENTLY somename ON .. - Stmt::IndexStmt(stmt) if stmt.concurrent && stmt.idxname.is_none() => { - errs.push(RuleViolation::new( - RuleViolationKind::PreferRobustStmts, - raw_stmt.into(), - Some(vec![ViolationMessage::Help( - "Use an explicit name for a concurrently created index".into(), - )]), - )); - } - Stmt::IndexStmt(stmt) - if !stmt.if_not_exists && (stmt.concurrent || !inside_transaction) => - { - errs.push(RuleViolation::new( - RuleViolationKind::PreferRobustStmts, - raw_stmt.into(), - None, - )); - } - Stmt::CreateStmt(stmt) if !stmt.if_not_exists && !inside_transaction => { - errs.push(RuleViolation::new( - RuleViolationKind::PreferRobustStmts, - raw_stmt.into(), - None, - )); - } - Stmt::DropStmt(stmt) if !stmt.missing_ok && !inside_transaction => { - errs.push(RuleViolation::new( - RuleViolationKind::PreferRobustStmts, - raw_stmt.into(), - None, - )); - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - errors::CheckSqlError, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - use squawk_parser::parse::parse_sql_query; - - use super::prefer_robust_stmts; - - fn lint_sql(sql: &str) -> Result, CheckSqlError> { - let mut sql = sql.to_owned(); - // our check ignores single statement queries, so we add an extra statement to ensure we check that case - sql.push_str(";\nSELECT 1;"); - let tree = parse_sql_query(&sql)?; - Ok(prefer_robust_stmts(&tree, None, false)) - } - - fn lint_sql_assuming_in_transaction(sql: &str) -> Result, CheckSqlError> { - let mut sql = sql.to_owned(); - // our check ignores single statement queries, so we add an extra statement to ensure we check that case - sql.push_str(";\nSELECT 1;"); - let tree = parse_sql_query(&sql)?; - Ok(prefer_robust_stmts(&tree, None, true)) - } - - #[test] - /// If we drop the constraint before adding it, we don't need the IF EXISTS or a transaction. - fn drop_before_add() { - let sql = r#" -ALTER TABLE "app_email" DROP CONSTRAINT IF EXISTS "email_uniq"; -ALTER TABLE "app_email" ADD CONSTRAINT "email_uniq" UNIQUE USING INDEX "email_idx"; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - } - #[test] - fn drop_index() { - let sql = r#" -DROP INDEX CONCURRENTLY "email_idx"; -"#; - let res = lint_sql(sql).unwrap(); - assert_eq!(res.len(), 1); - assert_eq!(res[0].kind, RuleViolationKind::PreferRobustStmts); - } - #[test] - fn drop_index_if_exists() { - let sql = r#" -DROP INDEX CONCURRENTLY IF EXISTS "email_idx"; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - } - #[test] - /// DROP CONSTRAINT and then ADD CONSTRAINT is safe. We can also safely run VALIDATE CONSTRAINT. - fn drop_before_add_foreign_key() { - let sql = r#" -ALTER TABLE "app_email" DROP CONSTRAINT IF EXISTS "fk_user"; -ALTER TABLE "app_email" ADD CONSTRAINT "fk_user" FOREIGN KEY ("user_id") REFERENCES "app_user" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID; -ALTER TABLE "app_email" VALIDATE CONSTRAINT "fk_user"; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - } - #[test] - /// We can only use the dropped constraint in one ADD CONSTRAINT statement. - fn double_add_after_drop() { - let sql = r#" -ALTER TABLE "app_email" DROP CONSTRAINT IF EXISTS "email_uniq"; -ALTER TABLE "app_email" ADD CONSTRAINT "email_uniq" UNIQUE USING INDEX "email_idx"; --- this second add constraint should error because it's not robust -ALTER TABLE "app_email" ADD CONSTRAINT "email_uniq" UNIQUE USING INDEX "email_idx"; - "#; - let res = lint_sql(sql).unwrap(); - assert_eq!(res.len(), 1); - assert_eq!(res[0].kind, RuleViolationKind::PreferRobustStmts); - } - - /// If the statement is in a transaction, or it has a guard like IF NOT - /// EXISTS, then it is considered valid by the `prefer-robust-stmt` rule. - #[test] - fn prefer_robust_stmt_okay_cases() { - let sql = r#" -BEGIN; -ALTER TABLE "core_foo" ADD COLUMN "answer_id" integer NULL; -COMMIT; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - - let sql = r#" -ALTER TABLE "core_foo" ADD COLUMN IF NOT EXISTS "answer_id" integer NULL; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - - let sql = r#" -CREATE INDEX CONCURRENTLY IF NOT EXISTS "core_foo_idx" ON "core_foo" ("answer_id"); -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - - let sql = r#" -BEGIN; -CREATE TABLE "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "bravo" text NOT NULL -); -COMMIT; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - - let sql = r#" -CREATE TABLE IF NOT EXISTS "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "bravo" text NOT NULL -); -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - - // If done in a transaction, most forms of drop are fine - let sql = r#" -BEGIN; -DROP INDEX "core_bar_foo_id_idx"; -DROP TABLE "core_bar"; -DROP TYPE foo; -COMMIT; -"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - - // select is fine, we're only interested in modifications to the tables - let sql = r" -SELECT 1; -"; - assert_eq!(lint_sql(sql), Ok(vec![])); - - // inserts are also okay - let sql = r" -INSERT INTO tbl VALUES (a); -"; - assert_eq!(lint_sql(sql), Ok(vec![])); - - let sql = r#" -ALTER TABLE "core_foo" DROP CONSTRAINT IF EXISTS "core_foo_idx"; - "#; - assert_eq!(lint_sql(sql), Ok(vec![])); - } - - /// If the statement is in a transaction, or it has a guard like IF NOT - /// EXISTS, then it is considered valid by the `prefer-robust-stmt` rule. - #[test] - fn prefer_robust_stmt_okay_cases_with_assume_in_transaction() { - let sql = r#" -ALTER TABLE "core_foo" ADD COLUMN "answer_id" integer NULL; -"#; - assert_eq!(lint_sql_assuming_in_transaction(sql), Ok(vec![])); - - let sql = r#" -CREATE TABLE "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "bravo" text NOT NULL -); -"#; - assert_eq!(lint_sql_assuming_in_transaction(sql), Ok(vec![])); - - let sql = r#" -DROP INDEX "core_bar_foo_id_idx"; -DROP TABLE "core_bar"; -DROP TYPE foo; -"#; - assert_eq!(lint_sql_assuming_in_transaction(sql), Ok(vec![])); - } - - #[test] - fn create_index_concurrently_unnamed() { - let bad_sql = r#" - CREATE INDEX CONCURRENTLY ON "table_name" ("field_name"); - "#; - - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - #[test] - fn enable_row_level_security() { - let bad_sql = r" -CREATE TABLE IF NOT EXISTS test(); -ALTER TABLE IF EXISTS test ENABLE ROW LEVEL SECURITY; - "; - - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - #[test] - fn enable_row_level_security_without_exists_check() { - let bad_sql = r" -CREATE TABLE IF NOT EXISTS test(); -ALTER TABLE test ENABLE ROW LEVEL SECURITY; - "; - - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - #[test] - fn disable_row_level_security() { - let bad_sql = r" -CREATE TABLE IF NOT EXISTS test(); -ALTER TABLE IF EXISTS test DISABLE ROW LEVEL SECURITY; - "; - - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - fn violations( - res: Result, CheckSqlError>, - ) -> Result, CheckSqlError> { - match res { - Ok(res) => Ok(res.into_iter().map(|x| x.kind).collect()), - Err(err) => Err(err), - } - } - - #[test] - fn ignore_single_stmts() { - let bad_sql = r#" - CREATE INDEX CONCURRENTLY ON "table_name" ("field_name"); - "#; - assert_eq!( - check_sql_with_rule(bad_sql, &RuleViolationKind::PreferRobustStmts, None, false), - Ok(vec![]) - ); - let bad_sql = r#" - CREATE INDEX CONCURRENTLY ON "table_name" ("field_name"); - CREATE INDEX CONCURRENTLY ON "table_name" ("field_name"); - "#; - - assert_eq!( - violations(check_sql_with_rule( - bad_sql, - &RuleViolationKind::PreferRobustStmts, - None, - false, - )), - Ok(vec![ - RuleViolationKind::PreferRobustStmts, - RuleViolationKind::PreferRobustStmts - ]) - ); - } - - #[test] - fn start_transaction() { - let sql = r#" -START TRANSACTION; - -ALTER TABLE "A" DROP CONSTRAINT "UQ_c4fb579a038211909ee524ccf29"; - -ALTER TABLE "B" DROP CONSTRAINT "UQ_791c01fe9438d66a94490d0da28"; - -ALTER TABLE "C" DROP CONSTRAINT "UQ_23fbf20e8ab4e806941359f4f79"; - -ALTER TABLE "D" DROP CONSTRAINT "UQ_468cad3743146a81c94b0b114ac"; - -COMMIT;"#; - assert_eq!(lint_sql(sql), Ok(vec![])); - } - - #[test] - fn prefer_robust_stmt_failure_cases() { - let sql = r#" -ALTER TABLE "core_foo" ADD COLUMN "answer_id" integer NULL; -"#; - assert_debug_snapshot!(lint_sql(sql), @r#" - Ok( - [ - RuleViolation { - kind: PreferRobustStmts, - span: Span { - start: 0, - len: Some( - 59, - ), - }, - messages: [ - Help( - "Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.", - ), - ], - }, - ], - ) - "#); - - let sql = r#" -CREATE INDEX CONCURRENTLY "core_foo_idx" ON "core_foo" ("answer_id"); -"#; - assert_debug_snapshot!(lint_sql(sql), @r#" - Ok( - [ - RuleViolation { - kind: PreferRobustStmts, - span: Span { - start: 0, - len: Some( - 69, - ), - }, - messages: [ - Help( - "Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.", - ), - ], - }, - ], - ) - "#); - - let sql = r#" -CREATE TABLE "core_bar" ( "id" serial NOT NULL PRIMARY KEY, "bravo" text NOT NULL); -"#; - assert_debug_snapshot!(lint_sql(sql), @r#" - Ok( - [ - RuleViolation { - kind: PreferRobustStmts, - span: Span { - start: 0, - len: Some( - 83, - ), - }, - messages: [ - Help( - "Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.", - ), - ], - }, - ], - ) - "#); - - let sql = r#" -ALTER TABLE "core_foo" DROP CONSTRAINT "core_foo_idx"; - "#; - assert_debug_snapshot!(lint_sql(sql), @r#" - Ok( - [ - RuleViolation { - kind: PreferRobustStmts, - span: Span { - start: 0, - len: Some( - 54, - ), - }, - messages: [ - Help( - "Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.", - ), - ], - }, - ], - ) - "#); - } -} diff --git a/crates/linter/src/rules/prefer_text_field.rs b/crates/linter/src/rules/prefer_text_field.rs deleted file mode 100644 index 570c1930..00000000 --- a/crates/linter/src/rules/prefer_text_field.rs +++ /dev/null @@ -1,157 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ColumnDef, RawStmt}; - -use crate::rules::utils::columns_create_or_modified; - -/// 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: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - for column in columns_create_or_modified(&raw_stmt.stmt) { - check_column_def(&mut errs, column); - } - } - errs -} - -fn check_column_def(errs: &mut Vec, column_def: &ColumnDef) { - let type_name = &column_def.type_name; - for field_type_name in &type_name.names { - if field_type_name.string.sval == "varchar" && !type_name.typmods.is_empty() { - errs.push(RuleViolation::new( - RuleViolationKind::PreferTextField, - column_def.into(), - None, - )); - } - } -} - -#[cfg(test)] -mod test_rules { - - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::PreferTextField, None, false).unwrap() - } - - /// Changing a column of varchar(255) to varchar(1000) requires an ACCESS - /// EXCLUSIVE lock - #[test] - fn increasing_varchar_size() { - let sql = r#" -BEGIN; --- --- Alter field kind on foo --- -ALTER TABLE "core_foo" ALTER COLUMN "kind" TYPE varchar(1000) USING "kind"::varchar(1000); -COMMIT; -"#; - assert_debug_snapshot!(lint_sql(sql), @r#" - [ - RuleViolation { - kind: PreferTextField, - span: Span { - start: 77, - len: None, - }, - messages: [ - Note( - "Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.", - ), - Help( - "Use a text field with a check constraint.", - ), - ], - }, - ] - "#); - } - - #[test] - fn prefer_text_field() { - let bad_sql = r#" -BEGIN; --- --- Create model Bar --- -CREATE TABLE "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "alpha" varchar(100) NOT NULL -); -COMMIT; -"#; - assert_debug_snapshot!(lint_sql(bad_sql), @r#" - [ - RuleViolation { - kind: PreferTextField, - span: Span { - start: 103, - len: None, - }, - messages: [ - Note( - "Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.", - ), - Help( - "Use a text field with a check constraint.", - ), - ], - }, - ] - "#); - - let ok_sql = r#" -BEGIN; --- --- Create model Bar --- -CREATE TABLE "core_bar" ( - "id" serial NOT NULL PRIMARY KEY, - "bravo" text NOT NULL -); --- --- Create constraint text_size on model bar --- -ALTER TABLE "core_bar" ADD CONSTRAINT "text_size" CHECK (LENGTH("bravo") <= 100); -COMMIT;"#; - assert_debug_snapshot!(lint_sql(ok_sql), @"[]"); - } - - #[test] - fn adding_column_non_text() { - let bad_sql = r#" -BEGIN; -ALTER TABLE "foo_table" ADD COLUMN "foo_column" varchar(256) NULL; -COMMIT; -"#; - - let res = lint_sql(bad_sql); - assert_debug_snapshot!(res); - } - - #[test] - fn allow_varchar_without_specified_limit() { - let ok_sql = r" - CREATE TABLE IF NOT EXISTS foo_table(bar_col varchar); - "; - let res = lint_sql(ok_sql); - assert_eq!(res, vec![]); - } -} diff --git a/crates/linter/src/rules/prefer_timestamptz.rs b/crates/linter/src/rules/prefer_timestamptz.rs deleted file mode 100644 index 5686c6fd..00000000 --- a/crates/linter/src/rules/prefer_timestamptz.rs +++ /dev/null @@ -1,111 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ColumnDef, RawStmt}; - -use crate::rules::utils::columns_create_or_modified; - -#[must_use] -pub fn prefer_timestamptz( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - for column in columns_create_or_modified(&raw_stmt.stmt) { - check_column_def(&mut errs, column); - } - } - errs -} - -fn check_column_def(errs: &mut Vec, column_def: &ColumnDef) { - if let Some(type_name) = column_def.type_name.names.last() { - if type_name.string.sval == "timestamp" { - errs.push(RuleViolation::new( - RuleViolationKind::PreferTimestampTz, - column_def.into(), - None, - )); - } - } -} - -#[cfg(test)] -mod test_rules { - use crate::check_sql_with_rule; - use crate::rules::test_utils::violations_to_kinds; - use crate::violations::{RuleViolation, RuleViolationKind}; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::PreferTimestampTz, None, false).unwrap() - } - - #[test] - fn create_with_timestamp() { - let bad_sql = r" -create table app.users -( - created_ts timestamp -); -create table app.accounts -( - created_ts timestamp without time zone -); - "; - let res = lint_sql(bad_sql); - assert_eq!( - violations_to_kinds(&res), - vec![ - RuleViolationKind::PreferTimestampTz, - RuleViolationKind::PreferTimestampTz - ] - ); - - let ok_sql = r" -create table app.users -( - created_ts timestamptz -); -create table app.accounts -( - created_ts timestamp with time zone -); - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } - - #[test] - fn alter_table() { - let bad_sql = r" - alter table app.users - alter column created_ts type timestamp; - alter table app.accounts - alter column created_ts type timestamp without time zone; - "; - let res = lint_sql(bad_sql); - - assert_debug_snapshot!(res); - assert_eq!( - violations_to_kinds(&res), - vec![ - RuleViolationKind::PreferTimestampTz, - RuleViolationKind::PreferTimestampTz - ] - ); - - let ok_sql = r" -alter table app.users - alter column created_ts type timestamptz; -alter table app.accounts - alter column created_ts type timestamp with time zone; -alter table app.accounts - alter column created_ts type timestamptz using created_ts at time zone 'UTC'; - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } -} diff --git a/crates/linter/src/rules/renaming_column.rs b/crates/linter/src/rules/renaming_column.rs deleted file mode 100644 index c8812ce7..00000000 --- a/crates/linter/src/rules/renaming_column.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; - -#[must_use] -pub fn renaming_column( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::RenameStmt(stmt) => match stmt.rename_type { - ObjectType::Column => { - errs.push(RuleViolation::new( - RuleViolationKind::RenamingColumn, - raw_stmt.into(), - None, - )); - } - _ => continue, - }, - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::RenamingColumn, None, false).unwrap() - } - - #[test] - fn renaming_column() { - let sql = r#" -ALTER TABLE "table_name" RENAME COLUMN "column_name" TO "new_column_name"; - "#; - - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/renaming_table.rs b/crates/linter/src/rules/renaming_table.rs deleted file mode 100644 index 3456f1f9..00000000 --- a/crates/linter/src/rules/renaming_table.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; - -#[must_use] -pub fn renaming_table( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::RenameStmt(stmt) => match stmt.rename_type { - ObjectType::Table => { - errs.push(RuleViolation::new( - RuleViolationKind::RenamingTable, - raw_stmt.into(), - None, - )); - } - _ => continue, - }, - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::RenamingTable, None, false).unwrap() - } - - #[test] - fn renaming_table() { - let sql = r#" -ALTER TABLE "table_name" RENAME TO "new_table_name"; - "#; - - assert_debug_snapshot!(lint_sql(sql)); - } -} diff --git a/crates/linter/src/rules/require_concurrent_index_creation.rs b/crates/linter/src/rules/require_concurrent_index_creation.rs deleted file mode 100644 index 150e9672..00000000 --- a/crates/linter/src/rules/require_concurrent_index_creation.rs +++ /dev/null @@ -1,112 +0,0 @@ -use crate::rules::utils::tables_created_in_transaction; -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind}; - -use squawk_parser::ast::{RawStmt, Stmt}; - -#[must_use] -pub fn require_concurrent_index_creation( - tree: &[RawStmt], - _pg_version: Option, - assume_in_transaction: bool, -) -> Vec { - let tables_created = tables_created_in_transaction(tree, assume_in_transaction); - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::IndexStmt(stmt) => { - let range = &stmt.relation; - let tbl_name = &range.relname; - if !stmt.concurrent && !tables_created.contains(tbl_name) { - errs.push(RuleViolation::new( - RuleViolationKind::RequireConcurrentIndexCreation, - raw_stmt.into(), - None, - )); - } - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use insta::assert_debug_snapshot; - - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::RequireConcurrentIndexCreation, - None, - false, - ) - .unwrap() - } - - fn lint_sql_assuming_in_transaction(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::RequireConcurrentIndexCreation, - None, - true, - ) - .unwrap() - } - - #[test] - fn ensure_ignored_when_new_table() { - let sql = r#" -BEGIN; -CREATE TABLE "core_foo" ( -"id" serial NOT NULL PRIMARY KEY, -"tenant_id" integer NULL -); -CREATE INDEX "core_foo_tenant_id_4d397ef9" ON "core_foo" ("tenant_id"); -COMMIT; - "#; - - assert_debug_snapshot!(lint_sql(sql)); - } - - #[test] - fn ensure_ignored_when_new_table_with_assume_in_transaction() { - let sql = r#" -CREATE TABLE "core_foo" ( -"id" serial NOT NULL PRIMARY KEY, -"tenant_id" integer NULL -); -CREATE INDEX "core_foo_tenant_id_4d397ef9" ON "core_foo" ("tenant_id"); - "#; - - assert_debug_snapshot!(lint_sql_assuming_in_transaction(sql)); - } - - /// ```sql - /// -- instead of - /// CREATE INDEX "field_name_idx" ON "table_name" ("field_name"); - /// -- use CONCURRENTLY - /// CREATE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - /// ``` - #[test] - fn adding_index_non_concurrently() { - let bad_sql = r#" - -- instead of - CREATE INDEX "field_name_idx" ON "table_name" ("field_name"); - "#; - - assert_debug_snapshot!(lint_sql(bad_sql)); - - let ok_sql = r#" - -- use CONCURRENTLY - CREATE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - "#; - assert_debug_snapshot!(lint_sql(ok_sql)); - } -} diff --git a/crates/linter/src/rules/require_concurrent_index_deletion.rs b/crates/linter/src/rules/require_concurrent_index_deletion.rs deleted file mode 100644 index b964b539..00000000 --- a/crates/linter/src/rules/require_concurrent_index_deletion.rs +++ /dev/null @@ -1,88 +0,0 @@ -use crate::{ - versions::Version, - violations::{RuleViolation, RuleViolationKind}, -}; - -use squawk_parser::ast::{ObjectType, RawStmt, Stmt}; - -#[must_use] -pub fn require_concurrent_index_deletion( - tree: &[RawStmt], - _pg_version: Option, - _assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::DropStmt(stmt) if !stmt.concurrent && stmt.remove_type == ObjectType::Index => { - errs.push(RuleViolation::new( - RuleViolationKind::RequireConcurrentIndexDeletion, - raw_stmt.into(), - None, - )); - } - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule( - sql, - &RuleViolationKind::RequireConcurrentIndexDeletion, - None, - false, - ) - .unwrap() - } - - #[test] - fn drop_index_concurrently() { - let bad_sql = r#" - -- instead of - DROP INDEX IF EXISTS "field_name_idx"; - "#; - let res = lint_sql(bad_sql); - assert_eq!(res.len(), 1); - assert_eq!( - res[0].kind, - RuleViolationKind::RequireConcurrentIndexDeletion - ); - - let ok_sql = r#" - DROP INDEX CONCURRENTLY IF EXISTS "field_name_idx"; - "#; - assert_eq!(lint_sql(ok_sql), vec![]); - } - - #[test] - fn regression_false_positive_drop_type() { - let sql = r" - DROP TYPE IF EXISTS foo; - "; - assert_eq!(lint_sql(sql), vec![]); - } - - #[test] - fn regression_false_positive_drop_table() { - let sql = r" - DROP TABLE IF EXISTS some_table; - "; - assert_eq!(lint_sql(sql), vec![]); - } - - #[test] - fn regression_false_positive_drop_trigger() { - let sql = r" - DROP TRIGGER IF EXISTS trigger on foo_table; - "; - assert_eq!(lint_sql(sql), vec![]); - } -} diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__add_numbers_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__add_numbers_ok.snap deleted file mode 100644 index b5bb7aaa..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__add_numbers_ok.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 67, - ), - }, - messages: [ - Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.", - ), - Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_arbitrary_func_err.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_arbitrary_func_err.snap deleted file mode 100644 index fd918004..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_arbitrary_func_err.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 83, - ), - }, - messages: [ - Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.", - ), - Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_bool_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_bool_ok.snap deleted file mode 100644 index dda100d2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_bool_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_enum_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_enum_ok.snap deleted file mode 100644 index dda100d2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_enum_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_integer_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_integer_ok.snap deleted file mode 100644 index dda100d2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_integer_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_jsonb_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_jsonb_ok.snap deleted file mode 100644 index dda100d2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_jsonb_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_now_func_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_now_func_ok.snap deleted file mode 100644 index dda100d2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_now_func_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_random_with_args_err.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_random_with_args_err.snap deleted file mode 100644 index db00c896..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_random_with_args_err.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 88, - ), - }, - messages: [ - Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.", - ), - Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_str_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_str_ok.snap deleted file mode 100644 index dda100d2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_str_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, pg_version_11)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_uuid_err.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_uuid_err.snap deleted file mode 100644 index 64d089d4..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_uuid_err.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(bad_sql, pg_version_11)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 78, - ), - }, - messages: [ - Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.", - ), - Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_volatile_func_err.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_volatile_func_err.snap deleted file mode 100644 index 1247c104..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__default_volatile_func_err.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(bad_sql, pg_version_11)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 80, - ), - }, - messages: [ - Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.", - ), - Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_bad.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_bad.snap deleted file mode 100644 index f1047c73..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_bad.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(bad_sql, None)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 76, - ), - }, - messages: [ - Note( - "Adding a field with a VOLATILE DEFAULT requires a table rewrite with an ACCESS EXCLUSIVE lock. In Postgres versions 11+, non-VOLATILE DEFAULTs can be added without a rewrite.", - ), - Help( - "Add the field as nullable, then set a default, backfill, and remove nullabilty.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_ok.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_ok.snap deleted file mode 100644 index 31b449f6..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__docs_example_ok.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(ok_sql, None)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__generated_stored.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__generated_stored.snap deleted file mode 100644 index fd39b05c..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_field_with_default__test_rules__generated_stored.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_field_with_default.rs -expression: "lint_sql(bad_sql, pg_version_11)" ---- -[ - RuleViolation { - kind: AddingFieldWithDefault, - span: Span { - start: 0, - len: Some( - 90, - ), - }, - messages: [ - Note( - "Adding a generated column requires a table rewrite with an ACCESS EXCLUSIVE lock.", - ), - Help( - "Add the column as nullable, backfill existing rows, and add a trigger to update the column on write instead.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable.snap deleted file mode 100644 index c832477c..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_not_null_field.rs -expression: "lint_sql(ok_sql, None)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_in_version_11.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_in_version_11.snap deleted file mode 100644 index c2b259d9..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_in_version_11.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_not_null_field.rs -expression: "lint_sql(ok_sql, Some(Version::from_str(\"11.0.0\").unwrap()),)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_without_default.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_without_default.snap deleted file mode 100644 index c832477c..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__adding_field_that_is_not_nullable_without_default.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_not_null_field.rs -expression: "lint_sql(ok_sql, None)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__set_not_null.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__set_not_null.snap deleted file mode 100644 index a760c793..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_not_null_field__test_rules__set_not_null.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_not_null_field.rs -expression: "lint_sql(sql, None)" ---- -[ - RuleViolation { - kind: AddingNotNullableField, - span: Span { - start: 0, - len: Some( - 58, - ), - }, - messages: [ - Note( - "Setting a column NOT NULL blocks reads while the table is scanned.", - ), - Help( - "Use a check constraint instead.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key-2.snap deleted file mode 100644 index e4a99056..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_primary_key_constraint.rs -expression: "lint_sql(ok_sql,)" ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key.snap deleted file mode 100644 index 37d7d79d..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__plain_primary_key.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_primary_key_constraint.rs -expression: expected_bad_res ---- -[ - RuleViolation { - kind: AddingSerialPrimaryKeyField, - span: Span { - start: 0, - len: Some( - 39, - ), - }, - messages: [ - Note( - "Adding a PRIMARY KEY constraint results in locks and table rewrites", - ), - Help( - "Add the PRIMARY KEY constraint USING an index.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__serial_primary_key.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__serial_primary_key.snap deleted file mode 100644 index 12c03b74..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_primary_key_constraint__test_rules__serial_primary_key.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_primary_key_constraint.rs -expression: expected_bad_res ---- -[ - RuleViolation { - kind: AddingSerialPrimaryKeyField, - span: Span { - start: 0, - len: Some( - 46, - ), - }, - messages: [ - Note( - "Adding a PRIMARY KEY constraint results in locks and table rewrites", - ), - Help( - "Add the PRIMARY KEY constraint USING an index.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored.snap deleted file mode 100644 index 86aef5e3..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_required_field.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored_not_null.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored_not_null.snap deleted file mode 100644 index 86aef5e3..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__generated_stored_not_null.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_required_field.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_with_default.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_with_default.snap deleted file mode 100644 index 86aef5e3..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_with_default.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_required_field.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_without_default.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_without_default.snap deleted file mode 100644 index 9867dac4..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__not_null_without_default.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/adding_required_field.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: AddingRequiredField, - span: Span { - start: 0, - len: Some( - 58, - ), - }, - messages: [ - Note( - "Adding a NOT NULL field without a DEFAULT will fail for a populated table.", - ), - Help( - "Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+).", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__nullable.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__nullable.snap deleted file mode 100644 index 86aef5e3..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__adding_required_field__test_rules__nullable.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/adding_required_field.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_alter_domain_with_add_constraint__test_rules__ban_alter_domain_with_add_constraint_works.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_alter_domain_with_add_constraint__test_rules__ban_alter_domain_with_add_constraint_works.snap deleted file mode 100644 index 7adad1c2..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_alter_domain_with_add_constraint__test_rules__ban_alter_domain_with_add_constraint_works.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: linter/src/rules/ban_alter_domain_with_add_constraint.rs -expression: lint_sql(sql) - ---- -[ - RuleViolation { - kind: BanAlterDomainWithAddConstraint, - span: Span { - start: 0, - len: Some( - 79, - ), - }, - messages: [ - Note( - "Domains with constraints have poor support for online migrations", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_char_errors.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_char_errors.snap deleted file mode 100644 index 58189170..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_char_errors.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: linter/src/rules/ban_char_field.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: BanCharField, - span: Span { - start: 76, - len: None, - }, - messages: [ - Help( - "Use text or varchar instead.", - ), - ], - }, - RuleViolation { - kind: BanCharField, - span: Span { - start: 108, - len: None, - }, - messages: [ - Help( - "Use text or varchar instead.", - ), - ], - }, - RuleViolation { - kind: BanCharField, - span: Span { - start: 144, - len: None, - }, - messages: [ - Help( - "Use text or varchar instead.", - ), - ], - }, - RuleViolation { - kind: BanCharField, - span: Span { - start: 173, - len: None, - }, - messages: [ - Help( - "Use text or varchar instead.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_var_char_and_text_okay.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_var_char_and_text_okay.snap deleted file mode 100644 index 2cc2d49c..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_char_field__test_rules__creating_table_with_var_char_and_text_okay.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/ban_char_field.rs -expression: lint_sql(sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction-2.snap deleted file mode 100644 index 20689329..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/ban_concurrent_index_creation_in_transaction.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction.snap deleted file mode 100644 index f55b9641..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/ban_concurrent_index_creation_in_transaction.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: BanConcurrentIndexCreationInTransaction, - span: Span { - start: 25, - len: Some( - 76, - ), - }, - messages: [ - Note( - "Concurrent index creation is not allowed inside a transaction.", - ), - Help( - "Build the index outside any transactions.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction-2.snap deleted file mode 100644 index ae384db7..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/ban_concurrent_index_creation_in_transaction.rs -expression: lint_sql_assuming_in_transaction(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction.snap deleted file mode 100644 index 7a497e46..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/ban_concurrent_index_creation_in_transaction.rs -expression: lint_sql_assuming_in_transaction(bad_sql) ---- -[ - RuleViolation { - kind: BanConcurrentIndexCreationInTransaction, - span: Span { - start: 0, - len: Some( - 99, - ), - }, - messages: [ - Note( - "Concurrent index creation is not allowed inside a transaction.", - ), - Help( - "Build the index outside any transactions.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction_but_outside.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction_but_outside.snap deleted file mode 100644 index ae384db7..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_concurrent_index_creation_in_transaction__test_rules__adding_index_concurrently_in_transaction_with_assume_in_transaction_but_outside.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/ban_concurrent_index_creation_in_transaction.rs -expression: lint_sql_assuming_in_transaction(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_create_domain_with_constraint__test_rules__ban_create_domain_with_constraint_works.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_create_domain_with_constraint__test_rules__ban_create_domain_with_constraint_works.snap deleted file mode 100644 index bb1fd486..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_create_domain_with_constraint__test_rules__ban_create_domain_with_constraint_works.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: linter/src/rules/ban_create_domain_with_constraint.rs -expression: lint_sql(sql) - ---- -[ - RuleViolation { - kind: BanCreateDomainWithConstraint, - span: Span { - start: 0, - len: Some( - 67, - ), - }, - messages: [ - Note( - "Domains with constraints have poor support for online migrations", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_column__test_rules__drop_column.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_column__test_rules__drop_column.snap deleted file mode 100644 index c15dd473..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_column__test_rules__drop_column.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: linter/src/rules/ban_drop_column.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: BanDropColumn, - span: Span { - start: 0, - len: Some( - 52, - ), - }, - messages: [ - Note( - "Dropping a column may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_database__test_rules__ban_drop_database.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_database__test_rules__ban_drop_database.snap deleted file mode 100644 index d76a567e..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_database__test_rules__ban_drop_database.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: linter/src/rules/ban_drop_database.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: BanDropDatabase, - span: Span { - start: 0, - len: Some( - 27, - ), - }, - messages: [ - Note( - "Dropping a database may break existing clients.", - ), - ], - }, - RuleViolation { - kind: BanDropDatabase, - span: Span { - start: 28, - len: Some( - 37, - ), - }, - messages: [ - Note( - "Dropping a database may break existing clients.", - ), - ], - }, - RuleViolation { - kind: BanDropDatabase, - span: Span { - start: 66, - len: None, - }, - messages: [ - Note( - "Dropping a database may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_not_null__test_rules__ban_drop_not_null.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_not_null__test_rules__ban_drop_not_null.snap deleted file mode 100644 index 1cd8fd13..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_not_null__test_rules__ban_drop_not_null.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: linter/src/rules/ban_drop_not_null.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: BanDropNotNull, - span: Span { - start: 0, - len: Some( - 59, - ), - }, - messages: [ - Note( - "Dropping a NOT NULL constraint may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_table__test_rules__ban_drop_table.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_table__test_rules__ban_drop_table.snap deleted file mode 100644 index 214dfed6..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__ban_drop_table__test_rules__ban_drop_table.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: linter/src/rules/ban_drop_table.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: BanDropTable, - span: Span { - start: 0, - len: Some( - 24, - ), - }, - messages: [ - Note( - "Dropping a table may break existing clients.", - ), - ], - }, - RuleViolation { - kind: BanDropTable, - span: Span { - start: 25, - len: Some( - 34, - ), - }, - messages: [ - Note( - "Dropping a table may break existing clients.", - ), - ], - }, - RuleViolation { - kind: BanDropTable, - span: Span { - start: 60, - len: None, - }, - messages: [ - Note( - "Dropping a table may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type-2.snap deleted file mode 100644 index 23bc3df5..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type-2.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: linter/src/rules/changing_column_type.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: ChangingColumnType, - span: Span { - start: 7, - len: Some( - 124, - ), - }, - messages: [ - Note( - "Requires an ACCESS EXCLUSIVE lock on the table which blocks reads.", - ), - Note( - "Changing the type may break existing clients.", - ), - ], - }, - RuleViolation { - kind: ChangingColumnType, - span: Span { - start: 132, - len: Some( - 73, - ), - }, - messages: [ - Note( - "Requires an ACCESS EXCLUSIVE lock on the table which blocks reads.", - ), - Note( - "Changing the type may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type.snap deleted file mode 100644 index ff7aa4d4..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__changing_column_type__test_rules__changing_field_type.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/changing_column_type.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: ChangingColumnType, - span: Span { - start: 7, - len: Some( - 114, - ), - }, - messages: [ - Note( - "Requires an ACCESS EXCLUSIVE lock on the table which blocks reads.", - ), - Note( - "Changing the type may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint-2.snap deleted file mode 100644 index 6830d9c8..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint.snap deleted file mode 100644 index c58dc0b9..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_check_constraint.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: ConstraintMissingNotValid, - span: Span { - start: 0, - len: Some( - 94, - ), - }, - messages: [ - Note( - "Requires a table scan to verify constraint and an ACCESS EXCLUSIVE lock which blocks reads.", - ), - Help( - "Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key-2.snap deleted file mode 100644 index 6830d9c8..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key.snap deleted file mode 100644 index 9316efa8..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__adding_foreign_key.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: ConstraintMissingNotValid, - span: Span { - start: 0, - len: Some( - 114, - ), - }, - messages: [ - Note( - "Requires a table scan to verify constraint and an ACCESS EXCLUSIVE lock which blocks reads.", - ), - Help( - "Add NOT VALID to the constraint in one transaction and then VALIDATE the constraint in a separate transaction.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table.snap deleted file mode 100644 index dcab9ba5..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql(sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap deleted file mode 100644 index 6eba8426..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql_assuming_in_transaction(sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_in_transaction.snap deleted file mode 100644 index fae9c8f1..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_in_transaction.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: "res[0].messages" ---- -[ - Note( - "Using NOT VALID and VALIDATE CONSTRAINT in the same transaction will block all reads while the constraint is validated.", - ), - Help( - "Add constraint as NOT VALID in one transaction and VALIDATE CONSTRAINT in a separate transaction.", - ), -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction.snap deleted file mode 100644 index fae9c8f1..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: "res[0].messages" ---- -[ - Note( - "Using NOT VALID and VALIDATE CONSTRAINT in the same transaction will block all reads while the constraint is validated.", - ), - Help( - "Add constraint as NOT VALID in one transaction and VALIDATE CONSTRAINT in a separate transaction.", - ), -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction_with_explicit_commit.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction_with_explicit_commit.snap deleted file mode 100644 index fae9c8f1..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__not_valid_validate_with_assume_in_transaction_with_explicit_commit.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: "res[0].messages" ---- -[ - Note( - "Using NOT VALID and VALIDATE CONSTRAINT in the same transaction will block all reads while the constraint is validated.", - ), - Help( - "Add constraint as NOT VALID in one transaction and VALIDATE CONSTRAINT in a separate transaction.", - ), -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap deleted file mode 100644 index dcab9ba5..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/constraint_missing_not_valid.rs -expression: lint_sql(sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-2.snap deleted file mode 100644 index 5f4087a6..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/disallow_unique_constraint.rs -expression: lint_sql(ignored_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-3.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-3.snap deleted file mode 100644 index 62695ba5..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint-3.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/disallow_unique_constraint.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint.snap deleted file mode 100644 index 6af2dd02..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__adding_unique_constraint.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/disallow_unique_constraint.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: DisallowedUniqueConstraint, - span: Span { - start: 0, - len: Some( - 80, - ), - }, - messages: [ - Note( - "Adding a UNIQUE constraint requires an ACCESS EXCLUSIVE lock which blocks reads.", - ), - Help( - "Create an index CONCURRENTLY and create the constraint using the index.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column.snap deleted file mode 100644 index f6c7c6c9..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/disallow_unique_constraint.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: DisallowedUniqueConstraint, - span: Span { - start: 0, - len: Some( - 69, - ), - }, - messages: [ - Note( - "Adding a UNIQUE constraint requires an ACCESS EXCLUSIVE lock which blocks reads.", - ), - Help( - "Create an index CONCURRENTLY and create the constraint using the index.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column_unique.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column_unique.snap deleted file mode 100644 index 071f423e..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__disallow_unique_constraint__test_rules__unique_constraint_inline_add_column_unique.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/disallow_unique_constraint.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: DisallowedUniqueConstraint, - span: Span { - start: 0, - len: Some( - 43, - ), - }, - messages: [ - Note( - "Adding a UNIQUE constraint requires an ACCESS EXCLUSIVE lock which blocks reads.", - ), - Help( - "Create an index CONCURRENTLY and create the constraint using the index.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_bad.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_bad.snap deleted file mode 100644 index ef5c09b7..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_bad.snap +++ /dev/null @@ -1,126 +0,0 @@ ---- -source: linter/src/rules/prefer_big_int.rs -expression: res ---- -[ - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 26, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 66, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 102, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 141, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 177, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 215, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 254, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 293, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_many_errors.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_many_errors.snap deleted file mode 100644 index fdb4d463..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_big_int__test_rules__create_table_many_errors.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: linter/src/rules/prefer_big_int.rs -expression: res ---- -[ - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 26, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigInt, - span: Span { - start: 43, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_int__test_rules__create_table_bad.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_int__test_rules__create_table_bad.snap deleted file mode 100644 index ff2691f9..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_int__test_rules__create_table_bad.snap +++ /dev/null @@ -1,66 +0,0 @@ ---- -source: linter/src/rules/prefer_bigint_over_int.rs -expression: res ---- -[ - RuleViolation { - kind: PreferBigintOverInt, - span: Span { - start: 26, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigintOverInt, - span: Span { - start: 65, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigintOverInt, - span: Span { - start: 101, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigintOverInt, - span: Span { - start: 139, - len: None, - }, - messages: [ - Note( - "Hitting the max 32 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_smallint__test_rules__create_table_bad.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_smallint__test_rules__create_table_bad.snap deleted file mode 100644 index 9559895d..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_bigint_over_smallint__test_rules__create_table_bad.snap +++ /dev/null @@ -1,66 +0,0 @@ ---- -source: linter/src/rules/prefer_bigint_over_smallint.rs -expression: res ---- -[ - RuleViolation { - kind: PreferBigintOverSmallint, - span: Span { - start: 26, - len: None, - }, - messages: [ - Note( - "Hitting the max 16 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigintOverSmallint, - span: Span { - start: 66, - len: None, - }, - messages: [ - Note( - "Hitting the max 16 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigintOverSmallint, - span: Span { - start: 102, - len: None, - }, - messages: [ - Note( - "Hitting the max 16 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, - RuleViolation { - kind: PreferBigintOverSmallint, - span: Span { - start: 145, - len: None, - }, - messages: [ - Note( - "Hitting the max 16 bit integer is possible and may break your application.", - ), - Help( - "Use 64bit integer values instead to prevent hitting this limit.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_identity__test_rules__prefer_identity_bad.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_identity__test_rules__prefer_identity_bad.snap deleted file mode 100644 index 5f1a8399..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_identity__test_rules__prefer_identity_bad.snap +++ /dev/null @@ -1,96 +0,0 @@ ---- -source: linter/src/rules/prefer_identity.rs -expression: res ---- -[ - RuleViolation { - kind: PreferIdentity, - span: Span { - start: 26, - len: None, - }, - messages: [ - Note( - "Serial types have confusing behaviors that make schema management difficult.", - ), - Help( - "Use identity columns instead for more features and better usability.", - ), - ], - }, - RuleViolation { - kind: PreferIdentity, - span: Span { - start: 64, - len: None, - }, - messages: [ - Note( - "Serial types have confusing behaviors that make schema management difficult.", - ), - Help( - "Use identity columns instead for more features and better usability.", - ), - ], - }, - RuleViolation { - kind: PreferIdentity, - span: Span { - start: 103, - len: None, - }, - messages: [ - Note( - "Serial types have confusing behaviors that make schema management difficult.", - ), - Help( - "Use identity columns instead for more features and better usability.", - ), - ], - }, - RuleViolation { - kind: PreferIdentity, - span: Span { - start: 142, - len: None, - }, - messages: [ - Note( - "Serial types have confusing behaviors that make schema management difficult.", - ), - Help( - "Use identity columns instead for more features and better usability.", - ), - ], - }, - RuleViolation { - kind: PreferIdentity, - span: Span { - start: 181, - len: None, - }, - messages: [ - Note( - "Serial types have confusing behaviors that make schema management difficult.", - ), - Help( - "Use identity columns instead for more features and better usability.", - ), - ], - }, - RuleViolation { - kind: PreferIdentity, - span: Span { - start: 224, - len: None, - }, - messages: [ - Note( - "Serial types have confusing behaviors that make schema management difficult.", - ), - Help( - "Use identity columns instead for more features and better usability.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__create_index_concurrently_unnamed.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__create_index_concurrently_unnamed.snap deleted file mode 100644 index da9b5685..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__create_index_concurrently_unnamed.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: linter/src/rules/prefer_robust_stmts.rs -expression: lint_sql(bad_sql) ---- -Ok( - [ - RuleViolation { - kind: PreferRobustStmts, - span: Span { - start: 0, - len: Some( - 59, - ), - }, - messages: [ - Help( - "Use an explicit name for a concurrently created index", - ), - ], - }, - ], -) diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__disable_row_level_security.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__disable_row_level_security.snap deleted file mode 100644 index d9f80a7e..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__disable_row_level_security.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: linter/src/rules/prefer_robust_stmts.rs -expression: lint_sql(bad_sql) ---- -Ok( - [], -) diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security.snap deleted file mode 100644 index d9f80a7e..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: linter/src/rules/prefer_robust_stmts.rs -expression: lint_sql(bad_sql) ---- -Ok( - [], -) diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security_without_exists_check.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security_without_exists_check.snap deleted file mode 100644 index d9f80a7e..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_robust_stmts__test_rules__enable_row_level_security_without_exists_check.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: linter/src/rules/prefer_robust_stmts.rs -expression: lint_sql(bad_sql) ---- -Ok( - [], -) diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_text_field__test_rules__adding_column_non_text.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_text_field__test_rules__adding_column_non_text.snap deleted file mode 100644 index fa57f4b5..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_text_field__test_rules__adding_column_non_text.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: linter/src/rules/prefer_text_field.rs -expression: res ---- -[ - RuleViolation { - kind: PreferTextField, - span: Span { - start: 43, - len: None, - }, - messages: [ - Note( - "Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.", - ), - Help( - "Use a text field with a check constraint.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_timestamptz__test_rules__alter_table.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_timestamptz__test_rules__alter_table.snap deleted file mode 100644 index ff7c07a7..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__prefer_timestamptz__test_rules__alter_table.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: linter/src/rules/prefer_timestamptz.rs -expression: res ---- -[ - RuleViolation { - kind: PreferTimestampTz, - span: Span { - start: 48, - len: None, - }, - messages: [ - Note( - "A timestamp field without a timezone can lead to data loss, depending on your database session timezone.", - ), - Help( - "Use timestamptz instead of timestamp for your column type.", - ), - ], - }, - RuleViolation { - kind: PreferTimestampTz, - span: Span { - start: 125, - len: None, - }, - messages: [ - Note( - "A timestamp field without a timezone can lead to data loss, depending on your database session timezone.", - ), - Help( - "Use timestamptz instead of timestamp for your column type.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_column__test_rules__renaming_column.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_column__test_rules__renaming_column.snap deleted file mode 100644 index c26e62a6..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_column__test_rules__renaming_column.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: linter/src/rules/renaming_column.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: RenamingColumn, - span: Span { - start: 0, - len: Some( - 74, - ), - }, - messages: [ - Note( - "Renaming a column may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_table__test_rules__renaming_table.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_table__test_rules__renaming_table.snap deleted file mode 100644 index b6dea2c0..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__renaming_table__test_rules__renaming_table.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: linter/src/rules/renaming_table.rs -expression: lint_sql(sql) ---- -[ - RuleViolation { - kind: RenamingTable, - span: Span { - start: 0, - len: Some( - 52, - ), - }, - messages: [ - Note( - "Renaming a table may break existing clients.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently-2.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently-2.snap deleted file mode 100644 index 7d7c0221..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/require_concurrent_index_creation.rs -expression: lint_sql(ok_sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently.snap deleted file mode 100644 index 8de86b9f..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__adding_index_non_concurrently.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/require_concurrent_index_creation.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: RequireConcurrentIndexCreation, - span: Span { - start: 0, - len: Some( - 79, - ), - }, - messages: [ - Note( - "Creating an index blocks writes.", - ), - Help( - "Create the index CONCURRENTLY.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table.snap deleted file mode 100644 index e5426c85..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/require_concurrent_index_creation.rs -expression: lint_sql(sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap deleted file mode 100644 index c0703600..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__require_concurrent_index_creation__test_rules__ensure_ignored_when_new_table_with_assume_in_transaction.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: linter/src/rules/require_concurrent_index_creation.rs -expression: lint_sql_assuming_in_transaction(sql) ---- -[] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_repeated.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_repeated.snap deleted file mode 100644 index dc96dfcb..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_repeated.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/transaction_nesting.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: TransactionNesting, - span: Span { - start: 7, - len: Some( - 6, - ), - }, - messages: [ - Note( - "There is an existing transaction already in progress.", - ), - Help( - "COMMIT the previous transaction before issuing a BEGIN or START TRANSACTION statement.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_with_assume_in_transaction.snap deleted file mode 100644 index 255e1c80..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__begin_with_assume_in_transaction.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/transaction_nesting.rs -expression: lint_sql_assuming_in_transaction(bad_sql) ---- -[ - RuleViolation { - kind: TransactionNesting, - span: Span { - start: 0, - len: Some( - 6, - ), - }, - messages: [ - Note( - "There is an existing transaction already in progress, managed by your migration tool.", - ), - Help( - "Put migration statements in separate files to have them be in separate transactions or don't use the assume-in-transaction setting.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_repeated.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_repeated.snap deleted file mode 100644 index 9df2e40e..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_repeated.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/transaction_nesting.rs -expression: lint_sql(bad_sql) ---- -[ - RuleViolation { - kind: TransactionNesting, - span: Span { - start: 25, - len: Some( - 7, - ), - }, - messages: [ - Note( - "There is no transaction to COMMIT or ROLLBACK.", - ), - Help( - "BEGIN a transaction at an earlier point in the migration or remove this statement.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_with_assume_in_transaction.snap deleted file mode 100644 index 3feaf142..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__commit_with_assume_in_transaction.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/transaction_nesting.rs -expression: lint_sql_assuming_in_transaction(bad_sql) ---- -[ - RuleViolation { - kind: TransactionNesting, - span: Span { - start: 10, - len: Some( - 7, - ), - }, - messages: [ - Note( - "Attempting to end the transaction that is managed by your migration tool.", - ), - Help( - "Put migration statements in separate files to have them be in separate transactions or don't use the assume-in-transaction setting.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__rollback_with_assume_in_transaction.snap b/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__rollback_with_assume_in_transaction.snap deleted file mode 100644 index 82609f74..00000000 --- a/crates/linter/src/rules/snapshots/squawk_linter__rules__transaction_nesting__test_rules__rollback_with_assume_in_transaction.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: linter/src/rules/transaction_nesting.rs -expression: lint_sql_assuming_in_transaction(bad_sql) ---- -[ - RuleViolation { - kind: TransactionNesting, - span: Span { - start: 10, - len: Some( - 90, - ), - }, - messages: [ - Note( - "Attempting to end the transaction that is managed by your migration tool.", - ), - Help( - "Put migration statements in separate files to have them be in separate transactions or don't use the assume-in-transaction setting.", - ), - ], - }, -] diff --git a/crates/linter/src/rules/test_utils.rs b/crates/linter/src/rules/test_utils.rs deleted file mode 100644 index 8767c9a9..00000000 --- a/crates/linter/src/rules/test_utils.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[cfg(test)] -use crate::violations::{RuleViolation, RuleViolationKind}; - -#[cfg(test)] -pub fn violations_to_kinds(violations: &[RuleViolation]) -> Vec { - violations - .iter() - .map(|v| v.kind.clone()) - .collect::>() -} diff --git a/crates/linter/src/rules/transaction_nesting.rs b/crates/linter/src/rules/transaction_nesting.rs deleted file mode 100644 index 2851bff8..00000000 --- a/crates/linter/src/rules/transaction_nesting.rs +++ /dev/null @@ -1,178 +0,0 @@ -use crate::versions::Version; -use crate::violations::{RuleViolation, RuleViolationKind}; -use crate::ViolationMessage; - -use squawk_parser::ast::{RawStmt, Stmt, TransactionStmtKind}; - -#[must_use] -pub fn transaction_nesting( - tree: &[RawStmt], - _pg_version: Option, - assume_in_transaction: bool, -) -> Vec { - let mut errs = vec![]; - let mut in_explicit_transaction = false; - let assume_in_transaction_help = ViolationMessage::Help( - "Put migration statements in separate files to have them be in separate transactions or \ - don't use the assume-in-transaction setting." - .into(), - ); - - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::TransactionStmt(stmt) => match stmt.kind { - TransactionStmtKind::Begin | TransactionStmtKind::Start => { - if assume_in_transaction { - errs.push(RuleViolation::new( - RuleViolationKind::TransactionNesting, - raw_stmt.into(), - Some(vec![ - ViolationMessage::Note( - "There is an existing transaction already in progress, managed by your migration tool.".into() - ), - assume_in_transaction_help.clone(), - ]) - )); - } else if in_explicit_transaction { - errs.push(RuleViolation::new( - RuleViolationKind::TransactionNesting, - raw_stmt.into(), - None, - )); - } - in_explicit_transaction = true; - } - TransactionStmtKind::Commit | TransactionStmtKind::Rollback => { - if assume_in_transaction { - errs.push(RuleViolation::new( - RuleViolationKind::TransactionNesting, - raw_stmt.into(), - Some(vec![ - ViolationMessage::Note( - "Attempting to end the transaction that is managed by your migration tool.".into() - ), - assume_in_transaction_help.clone(), - ]) - )); - } else if !in_explicit_transaction { - errs.push(RuleViolation::new( - RuleViolationKind::TransactionNesting, - raw_stmt.into(), - Some(vec![ - ViolationMessage::Note( - "There is no transaction to COMMIT or ROLLBACK.".into() - ), - ViolationMessage::Help( - "BEGIN a transaction at an earlier point in the migration or remove this statement.".into() - ), - ]) - )); - } - in_explicit_transaction = false; - } - _ => continue, - }, - _ => continue, - } - } - errs -} - -#[cfg(test)] -mod test_rules { - use crate::{ - check_sql_with_rule, - violations::{RuleViolation, RuleViolationKind}, - }; - use insta::assert_debug_snapshot; - - fn lint_sql(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::TransactionNesting, None, false).unwrap() - } - fn lint_sql_assuming_in_transaction(sql: &str) -> Vec { - check_sql_with_rule(sql, &RuleViolationKind::TransactionNesting, None, true).unwrap() - } - - #[test] - fn no_nesting() { - let ok_sql = r" -BEGIN; -SELECT 1; -COMMIT; - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } - - #[test] - fn no_nesting_repeated() { - let ok_sql = r" -BEGIN; -SELECT 1; -COMMIT; --- This probably shouldn't be done in a migration. However, Squawk may be linting several --- migrations that are concatentated, so don't raise a warning here. -BEGIN; -SELECT 2; -COMMIT; - "; - assert_eq!(lint_sql(ok_sql), vec![]); - } - - #[test] - fn no_nesting_with_assume_in_transaction() { - let ok_sql = r" -SELECT 1; - "; - assert_eq!(lint_sql_assuming_in_transaction(ok_sql), vec![]); - } - - #[test] - fn begin_repeated() { - let bad_sql = r" -BEGIN; -BEGIN; -SELECT 1; -COMMIT; - "; - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - #[test] - fn begin_with_assume_in_transaction() { - let bad_sql = r" -BEGIN; -SELECT 1; - "; - assert_debug_snapshot!(lint_sql_assuming_in_transaction(bad_sql)); - } - - #[test] - fn commit_repeated() { - let bad_sql = r" -BEGIN; -SELECT 1; -COMMIT; -COMMIT; - "; - assert_debug_snapshot!(lint_sql(bad_sql)); - } - - #[test] - fn commit_with_assume_in_transaction() { - let bad_sql = r" -SELECT 1; -COMMIT; - "; - assert_debug_snapshot!(lint_sql_assuming_in_transaction(bad_sql)); - } - - #[test] - fn rollback_with_assume_in_transaction() { - let bad_sql = r" -SELECT 1; --- Not sure why rollback would be used in a migration, but test for completeness -ROLLBACK; - "; - assert_debug_snapshot!(lint_sql_assuming_in_transaction(bad_sql)); - } -} diff --git a/crates/linter/src/rules/utils.rs b/crates/linter/src/rules/utils.rs deleted file mode 100644 index 2df9c940..00000000 --- a/crates/linter/src/rules/utils.rs +++ /dev/null @@ -1,57 +0,0 @@ -use squawk_parser::ast::{ - AlterTableCmds, AlterTableDef, AlterTableType, ColumnDef, RawStmt, Stmt, TableElt, - TransactionStmtKind, -}; -use std::collections::HashSet; - -pub fn tables_created_in_transaction( - tree: &[RawStmt], - assume_in_transaction: bool, -) -> HashSet { - let mut created_table_names = HashSet::new(); - let mut inside_transaction = assume_in_transaction; - for raw_stmt in tree { - match &raw_stmt.stmt { - Stmt::TransactionStmt(stmt) => match stmt.kind { - TransactionStmtKind::Begin | TransactionStmtKind::Start => { - inside_transaction = true; - } - TransactionStmtKind::Commit => inside_transaction = false, - _ => continue, - }, - Stmt::CreateStmt(stmt) if inside_transaction => { - let stmt = &stmt.relation; - let table_name = &stmt.relname; - created_table_names.insert(table_name.clone()); - } - _ => continue, - } - } - created_table_names -} - -pub fn columns_create_or_modified(stmt: &Stmt) -> Vec<&ColumnDef> { - let mut columns = vec![]; - match stmt { - Stmt::CreateStmt(stmt) => { - for column_def in &stmt.table_elts { - if let TableElt::ColumnDef(column_def) = column_def { - columns.push(column_def); - } - } - } - Stmt::AlterTableStmt(stmt) => { - for AlterTableCmds::AlterTableCmd(cmd) in &stmt.cmds { - if cmd.subtype == AlterTableType::AddColumn - || cmd.subtype == AlterTableType::AlterColumnType - { - if let Some(AlterTableDef::ColumnDef(column_def)) = &cmd.def { - columns.push(column_def); - } - } - } - } - _ => {} - } - columns -} diff --git a/crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_debug_snap.snap b/crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_debug_snap.snap deleted file mode 100644 index ad4cfe31..00000000 --- a/crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_debug_snap.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: linter/src/lib.rs -expression: rule_names - ---- -[ - "adding-field-with-default", - "adding-foreign-key-constraint", - "adding-not-nullable-field", - "adding-required-field", - "adding-serial-primary-key-field", - "ban-alter-domain-with-add-constraint", - "ban-char-field", - "ban-concurrent-index-creation-in-transaction", - "ban-create-domain-with-constraint", - "ban-drop-column", - "ban-drop-database", - "ban-drop-not-null", - "ban-drop-table", - "changing-column-type", - "constraint-missing-not-valid", - "disallowed-unique-constraint", - "prefer-big-int", - "prefer-bigint-over-int", - "prefer-bigint-over-smallint", - "prefer-identity", - "prefer-robust-stmts", - "prefer-text-field", - "prefer-timestamptz", - "renaming-column", - "renaming-table", - "require-concurrent-index-creation", - "require-concurrent-index-deletion", - "transaction-nesting", -] diff --git a/crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_display_snap.snap b/crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_display_snap.snap deleted file mode 100644 index 555d224f..00000000 --- a/crates/linter/src/snapshots/squawk_linter__test_rules__rule_names_display_snap.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: linter/src/lib.rs -expression: "rule_names.join(\"\\n\")" - ---- -adding-field-with-default -adding-foreign-key-constraint -adding-not-nullable-field -adding-required-field -adding-serial-primary-key-field -ban-alter-domain-with-add-constraint -ban-char-field -ban-concurrent-index-creation-in-transaction -ban-create-domain-with-constraint -ban-drop-column -ban-drop-database -ban-drop-not-null -ban-drop-table -changing-column-type -constraint-missing-not-valid -disallowed-unique-constraint -prefer-big-int -prefer-bigint-over-int -prefer-bigint-over-smallint -prefer-identity -prefer-robust-stmts -prefer-text-field -prefer-timestamptz -renaming-column -renaming-table -require-concurrent-index-creation -require-concurrent-index-deletion -transaction-nesting diff --git a/crates/linter/src/snapshots/squawk_linter__versions__test_pg_version__parse.snap b/crates/linter/src/snapshots/squawk_linter__versions__test_pg_version__parse.snap deleted file mode 100644 index 7be9446e..00000000 --- a/crates/linter/src/snapshots/squawk_linter__versions__test_pg_version__parse.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: linter/src/versions.rs -expression: "Version::from_str(\"test\").unwrap_err()" ---- -InvalidNumber( - InvalidNumber { - version: "test", - e: ParseIntError { - kind: InvalidDigit, - }, - }, -) diff --git a/crates/linter/src/versions.rs b/crates/linter/src/versions.rs deleted file mode 100644 index 2e3b1c35..00000000 --- a/crates/linter/src/versions.rs +++ /dev/null @@ -1,141 +0,0 @@ -use std::{num::ParseIntError, str::FromStr}; - -use serde::{de::Error, Deserialize, Deserializer}; - -#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)] -pub struct Version { - pub major: i32, - pub minor: Option, - pub patch: Option, -} - -impl Version { - #[must_use] - pub fn new(major: i32, minor: Option, patch: Option) -> Self { - Self { - major, - minor, - patch, - } - } -} - -// Allow us to deserialize our version from a string in .squawk.toml. -// from https://stackoverflow.com/a/46755370/ -impl<'de> Deserialize<'de> for Version { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s: &str = Deserialize::deserialize(deserializer)?; - Version::from_str(s).map_err(D::Error::custom) - } -} - -#[derive(Debug, PartialEq)] -pub struct InvalidNumber { - pub version: String, - pub e: ParseIntError, -} - -#[derive(Debug, PartialEq)] -pub struct EmptyVersion { - pub version: String, -} - -#[derive(Debug, PartialEq)] -pub enum ParseVersionError { - EmptyVersion(EmptyVersion), - InvalidNumber(InvalidNumber), -} - -impl std::fmt::Display for ParseVersionError { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match *self { - Self::EmptyVersion(ref err) => { - write!(f, "Empty version number provided: {:?}", err.version) - } - Self::InvalidNumber(ref err) => { - write!( - f, - "Invalid number in version: {:?}. Parse error: {}", - err.version, err.e - ) - } - } - } -} - -fn parse_int(s: &str) -> Result { - Ok(s.parse().map_err(|e| { - ParseVersionError::InvalidNumber(InvalidNumber { - version: s.to_string(), - e, - }) - }))? -} - -impl FromStr for Version { - type Err = ParseVersionError; - - fn from_str(s: &str) -> Result { - let version_pieces: Vec<&str> = s.split('.').collect(); - - if version_pieces.is_empty() { - return Err(ParseVersionError::EmptyVersion(EmptyVersion { - version: s.to_string(), - })); - } - let major = parse_int(version_pieces[0])?; - - let minor: Option = if version_pieces.len() > 1 { - Some(parse_int(version_pieces[1])?) - } else { - None - }; - let patch: Option = if version_pieces.len() > 2 { - Some(parse_int(version_pieces[2])?) - } else { - None - }; - - Ok(Version { - major, - minor, - patch, - }) - } -} - -#[cfg(test)] -mod test_pg_version { - #![allow(clippy::neg_cmp_op_on_partial_ord)] - use insta::assert_debug_snapshot; - - use super::*; - #[test] - fn eq() { - assert_eq!(Version::new(10, None, None), Version::new(10, None, None)); - } - #[test] - fn gt() { - assert!(Version::new(10, Some(1), None) > Version::new(10, None, None)); - assert!(Version::new(10, None, Some(1)) > Version::new(10, None, None)); - assert!(Version::new(10, None, Some(1)) > Version::new(9, None, None)); - - assert!(!(Version::new(10, None, None) > Version::new(10, None, None))); - } - #[test] - fn parse() { - assert_eq!( - Version::from_str("10.1"), - Ok(Version::new(10, Some(1), None)) - ); - assert_eq!(Version::from_str("10"), Ok(Version::new(10, None, None))); - assert_eq!( - Version::from_str("10.2.1"), - Ok(Version::new(10, Some(2), Some(1))) - ); - assert_debug_snapshot!(Version::from_str("test").unwrap_err()); - } -} diff --git a/crates/linter/src/violations.rs b/crates/linter/src/violations.rs deleted file mode 100644 index d20f499e..00000000 --- a/crates/linter/src/violations.rs +++ /dev/null @@ -1,138 +0,0 @@ -use std::str::FromStr; - -use crate::RULES; -use serde::{Deserialize, Serialize}; -pub use squawk_parser::ast::Span; - -#[derive(Debug, PartialEq, Clone, Serialize, Hash, Eq, Deserialize)] -pub enum RuleViolationKind { - #[serde(rename = "require-concurrent-index-creation")] - RequireConcurrentIndexCreation, - #[serde(rename = "require-concurrent-index-deletion")] - RequireConcurrentIndexDeletion, - #[serde(rename = "constraint-missing-not-valid")] - ConstraintMissingNotValid, - #[serde(rename = "adding-field-with-default")] - AddingFieldWithDefault, - #[serde(rename = "adding-foreign-key-constraint")] - AddingForeignKeyConstraint, - #[serde(rename = "changing-column-type")] - ChangingColumnType, - #[serde(rename = "adding-not-nullable-field")] - AddingNotNullableField, - #[serde(rename = "adding-serial-primary-key-field")] - AddingSerialPrimaryKeyField, - #[serde(rename = "renaming-column")] - RenamingColumn, - #[serde(rename = "renaming-table")] - RenamingTable, - #[serde(rename = "disallowed-unique-constraint")] - DisallowedUniqueConstraint, - #[serde(rename = "ban-drop-database")] - BanDropDatabase, - // when we can't parse a Postgres statement, we report this error. - #[serde(rename = "invalid-statement")] - InvalidStatement, - #[serde(rename = "prefer-big-int")] - PreferBigInt, - #[serde(rename = "prefer-bigint-over-int")] - PreferBigintOverInt, - #[serde(rename = "prefer-bigint-over-smallint")] - PreferBigintOverSmallint, - #[serde(rename = "prefer-identity")] - PreferIdentity, - #[serde(rename = "prefer-robust-stmts")] - PreferRobustStmts, - #[serde(rename = "prefer-text-field")] - PreferTextField, - #[serde(rename = "prefer-timestamptz")] - PreferTimestampTz, - #[serde(rename = "ban-char-field")] - BanCharField, - #[serde(rename = "ban-drop-column")] - BanDropColumn, - #[serde(rename = "ban-drop-table")] - BanDropTable, - #[serde(rename = "ban-drop-not-null")] - BanDropNotNull, - #[serde(rename = "transaction-nesting")] - TransactionNesting, - #[serde(rename = "adding-required-field")] - AddingRequiredField, - #[serde(rename = "ban-concurrent-index-creation-in-transaction")] - BanConcurrentIndexCreationInTransaction, - #[serde(rename = "ban-create-domain-with-constraint")] - BanCreateDomainWithConstraint, - #[serde(rename = "ban-alter-domain-with-add-constraint")] - BanAlterDomainWithAddConstraint, - // generator::new-rule-above -} - -impl std::fmt::Display for RuleViolationKind { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - serde_plain::to_string(self).map_err(|_| std::fmt::Error)? - ) - } -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct UnknownRuleName { - val: String, -} - -impl std::fmt::Display for UnknownRuleName { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "invalid rule name {}", self.val) - } -} - -impl std::str::FromStr for RuleViolationKind { - type Err = UnknownRuleName; - fn from_str(s: &str) -> Result { - serde_plain::from_str(s).map_err(|_| UnknownRuleName { val: s.to_string() }) - } -} - -impl std::convert::TryFrom<&str> for RuleViolationKind { - type Error = UnknownRuleName; - fn try_from(s: &str) -> Result { - RuleViolationKind::from_str(s) - } -} - -#[derive(Debug, PartialEq, Serialize, Clone)] -pub enum ViolationMessage { - Note(String), - Help(String), -} - -#[derive(Debug, PartialEq)] -pub struct RuleViolation { - pub kind: RuleViolationKind, - pub span: Span, - pub messages: Vec, -} - -impl RuleViolation { - #[must_use] - pub fn new( - kind: RuleViolationKind, - span: Span, - messages: Option>, - ) -> Self { - let messages = messages.unwrap_or_else(|| { - RULES - .iter() - .find(|r| r.name == kind) - .map_or_else(Vec::new, |x| x.messages.clone()) - }); - Self { - kind, - span, - messages, - } - } -} diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml deleted file mode 100644 index bbae9c7c..00000000 --- a/crates/parser/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "squawk-parser" -version = "0.0.0" -authors = ["Steve Dignam "] -edition = "2018" -license = "GPL-3.0" -description = "Postgres SQL parser used in squawk" -repository = "https://github.com/sbdchd/squawk" -readme = "README.md" -keywords = ["postgres", "sql", "parser"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde_json.workspace = true -serde.workspace = true -serde_repr.workspace = true -libpg_query-sys.workspace = true - -[dev-dependencies] -insta.workspace = true diff --git a/crates/parser/README.md b/crates/parser/README.md deleted file mode 100644 index 22d15869..00000000 --- a/crates/parser/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# squawk-parser - -Postgresl SQL parser that wraps -[libpg_query-sys](https://github.com/tdbgamer/libpg_query-sys) in a safe -interface and parses the json from -[libpg_query](https://github.com/lfittl/libpg_query) into easier to work with -structures. - -Used by `squawk-linter` for writing lint rules. diff --git a/crates/parser/src/ast.rs b/crates/parser/src/ast.rs deleted file mode 100644 index 70aa995d..00000000 --- a/crates/parser/src/ast.rs +++ /dev/null @@ -1,1007 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_json::Value; - -/// Source: -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub enum TransactionStmtKind { - #[serde(rename = "TRANS_STMT_BEGIN")] - 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, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct TransactionStmt { - pub kind: TransactionStmtKind, -} -#[derive(Debug, PartialEq)] -pub struct Span { - pub start: i32, - pub len: Option, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct RawStmt { - pub stmt: Stmt, - #[serde(default)] - pub stmt_location: i32, - /// None when the statement doesn't have a closing semicolon - pub stmt_len: Option, -} - -impl std::convert::From<&RawStmt> for Span { - fn from(stmt: &RawStmt) -> Self { - Self { - start: stmt.stmt_location, - len: stmt.stmt_len, - } - } -} - -impl std::convert::From<&ColumnDef> for Span { - fn from(stmt: &ColumnDef) -> Self { - Self { - start: stmt.location, - // Use current line - len: None, - } - } -} - -impl RawStmt { - #[must_use] - pub fn span(&self) -> Span { - Span { - start: self.stmt_location, - len: self.stmt_len, - } - } -} - -/// 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, -} - -impl Default for SetOperation { - fn default() -> Self { - Self::None - } -} - -#[derive(Debug, Deserialize, Serialize)] -pub enum SelectChild { - SelectStmt(SelectStmt), -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct SelectStmt { - // - // These fields are used only in "leaf" SelectStmts. - // - /// NULL, list of DISTINCT ON exprs, or lcons(NIL,NIL) for all (SELECT - /// DISTINCT) - #[serde(rename = "distinctClause")] - pub distinct_clause: Option, - // target for SELECT INTO - #[serde(rename = "intoClause")] - pub into_clause: Option, - /// the target list (of `ResTarget`) - #[serde(rename = "targetList")] - pub target_list: Option>, - /// the FROM clause - #[serde(rename = "fromClause")] - pub from_clause: Option, - /// WHERE qualification - #[serde(rename = "whereClause")] - pub where_clause: Option, - /// GROUP BY clauses - #[serde(rename = "groupClause")] - pub group_clause: Option, - /// HAVING conditional-expression - #[serde(rename = "havingClause")] - pub having_clause: Option, - /// WINDOW `window_name` AS (...), ... - #[serde(rename = "windowClause")] - pub window_clause: Option, - - // - // In a "leaf" node representing a VALUES list, the above fields are all - // null, and instead this field is set. Note that the elements of the - // sublists are just expressions, without ResTarget decoration. Also note - // that a list element can be DEFAULT (represented as a SetToDefault - // node), regardless of the context of the VALUES list. It's up to parse - // analysis to reject that where not valid. - // - /// untransformed list of expression lists - #[serde(rename = "valuesLists")] - values_lists: Option, - - // - // These fields are used in both "leaf" SelectStmts and upper-level - // SelectStmts. - // - /// sort clause (a list of `SortBy`'s) - #[serde(rename = "sortClause")] - sort_clause: Option, - /// # of result tuples to skip - #[serde(rename = "limitOffset")] - limit_offset: Option, - /// # of result tuples to return - #[serde(rename = "limitCount")] - limit_count: Option, - /// FOR UPDATE (list of `LockingClause`'s) - #[serde(rename = "lockingClause")] - locking_clause: Option, - /// WITH clause - #[serde(rename = "withClause")] - with_clause: Option, - - // - // These fields are used only in upper-level SelectStmts. - // - /// type of set op - #[serde(default)] - pub op: SetOperation, - /// ALL specified? - #[serde(default)] - pub all: bool, - /// left child - pub larg: Option>, - /// right child - pub rarg: Option>, -} - -/// Sort ordering options for ORDER BY and CREATE INDEX -/// -/// Source: -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub enum SortByDir { - #[serde(rename = "SORTBY_DEFAULT")] - Default, - #[serde(rename = "SORTBY_ASC")] - Asc, - #[serde(rename = "SORTBY_DESC")] - Desc, - #[serde(rename = "SORTBY_USING")] - Using, -} - -impl Default for SortByDir { - fn default() -> Self { - Self::Default - } -} - -/// 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, -} - -impl Default for SortByNulls { - fn default() -> Self { - Self::Default - } -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct IndexElem { - /// name of attribute to index, or NULL - name: Option, - /// expression to index, or NULL - expr: Option, - /// name for index column; NULL = default - indexcolname: Option, - /// name of collation; NIL = default - collation: Option, - /// name of desired opclass; NIL = default - #[serde(default)] - opclass: Vec, - /// ASC/DESC/default - #[serde(default)] - ordering: SortByDir, - /// FIRST/LAST/default - #[serde(default)] - nulls_ordering: SortByNulls, -} - -#[derive(Debug, Deserialize, Serialize)] -pub enum IndexParams { - IndexElem(IndexElem), -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct RangeVar { - /// the catalog (database) name, or NULL - pub catalogname: Option, - /// the schema name, or NULL - pub schemaname: Option, - /// the relation/sequence name - pub relname: String, - /// expand rel by inheritance? recursively act on children? - #[serde(default)] - pub inh: bool, - /// see RELPERSISTENCE_* in `pg_class.h` - pub relpersistence: String, - /// table alias & optional column aliases - pub alias: Option, - /// token location, or -1 if unknown - pub location: i32, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct IndexStmt { - /// name of access method (eg. btree) - #[serde(rename = "accessMethod")] - pub access_method: String, - /// name of new index, or NULL for default - #[serde(default)] - pub idxname: Option, - #[serde(rename = "indexParams")] - pub index_params: Vec, - /// relation to build index on - pub relation: RangeVar, - #[serde(default)] - pub concurrent: bool, - /// is index unique - #[serde(default)] - pub unique: bool, - /// is index a primary key? - #[serde(default)] - pub primary: bool, - /// is it for a pkey/unique constraint? - #[serde(default)] - pub isconstraint: bool, - /// is the constraint DEFERRABLE? - #[serde(default)] - pub deferrable: bool, - /// is the constraint INITIALLY DEFERRED? - #[serde(default)] - pub initdeferred: bool, - /// true when transformIndexStmt is finished - #[serde(default)] - pub transformed: bool, - /// should this be a concurrent index build? - /// just do nothing if index already exists? - #[serde(default)] - pub if_not_exists: bool, - /// tablespace, or NULL for default - #[serde(rename = "tableSpace")] - pub table_space: Option, -} - -/// 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. -/// -/// 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, - #[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, - #[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, - #[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, -} - -// List *options; /* WITH clause options: a list of DefElem */ -// Node *whereClause; /* qualification (partial-index predicate) */ -// List *excludeOpNames; /* exclusion operator names, or NIL if none */ -// char *idxcomment; /* comment to apply to index, or NULL */ -// Oid indexOid; /* OID of an existing index, if any */ -// Oid oldNode; /* relfilenode of existing storage, if any */ -#[derive(Debug, Deserialize, Serialize)] -pub enum AlterTableCmds { - AlterTableCmd(AlterTableCmd), -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct AlterTableStmt { - pub cmds: Vec, - pub relation: RangeVar, - pub objtype: ObjectType, - #[serde(default)] - pub missing_ok: bool, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct CreateDomainStmt { - #[serde(rename = "domainname")] - pub domain_name: Vec, - #[serde(rename = "typeName")] - pub typename: Value, - #[serde(default)] - pub constraints: Vec, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct AlterDomainStmt { - pub behavior: DropBehavior, - pub name: Option, - pub subtype: String, - #[serde(rename = "typeName")] - pub typename: Value, - pub def: Option, -} - -/// Source: -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub enum DropBehavior { - #[serde(rename = "DROP_RESTRICT")] - Restrict, - #[serde(rename = "DROP_CASCADE")] - DropCascade, -} -impl Default for DropBehavior { - fn default() -> Self { - Self::Restrict - } -} - -/// Source: -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub enum AlterTableType { - #[serde(rename = "AT_AddColumn")] - AddColumn, - #[serde(rename = "AT_AddColumnRecurse")] - AddColumnRecurse, - #[serde(rename = "AT_AddColumnToView")] - AddColumnToView, - #[serde(rename = "AT_ColumnDefault")] - ColumnDefault, - #[serde(rename = "AT_CookedColumnDefault")] - CookedColumnDefault, - #[serde(rename = "AT_DropNotNull")] - DropNotNull, - #[serde(rename = "AT_SetNotNull")] - SetNotNull, - #[serde(rename = "AT_DropExpression")] - DropExpression, - #[serde(rename = "AT_CheckNotNull")] - CheckNotNull, - #[serde(rename = "AT_SetStatistics")] - SetStatistics, - #[serde(rename = "AT_SetOptions")] - SetOptions, - #[serde(rename = "AT_ResetOptions")] - ResetOptions, - #[serde(rename = "AT_SetStorage")] - SetStorage, - #[serde(rename = "AT_DropColumn")] - DropColumn, - #[serde(rename = "AT_DropColumnRecurse")] - DropColumnRecurse, - #[serde(rename = "AT_AddIndex")] - AddIndex, - #[serde(rename = "AT_ReAddIndex")] - ReAddIndex, - #[serde(rename = "AT_AddConstraint")] - AddConstraint, - #[serde(rename = "AT_AddConstraintRecurse")] - AddConstraintRecurse, - #[serde(rename = "AT_ReAddConstraint")] - ReAddConstraint, - #[serde(rename = "AT_ReAddDomainConstraint")] - ReAddDomainConstraint, - #[serde(rename = "AT_AlterConstraint")] - AlterConstraint, - #[serde(rename = "AT_ValidateConstraint")] - ValidateConstraint, - #[serde(rename = "AT_ValidateConstraintRecurse")] - ValidateConstraintRecurse, - #[serde(rename = "AT_AddIndexConstraint")] - AddIndexConstraint, - #[serde(rename = "AT_DropConstraint")] - DropConstraint, - #[serde(rename = "AT_DropConstraintRecurse")] - DropConstraintRecurse, - #[serde(rename = "AT_ReAddComment")] - ReAddComment, - #[serde(rename = "AT_AlterColumnType")] - AlterColumnType, - #[serde(rename = "AT_AlterColumnGenericOptions")] - AlterColumnGenericOptions, - #[serde(rename = "AT_ChangeOwner")] - ChangeOwner, - #[serde(rename = "AT_ClusterOn")] - ClusterOn, - #[serde(rename = "AT_DropCluster")] - DropCluster, - #[serde(rename = "AT_SetLogged")] - SetLogged, - #[serde(rename = "AT_SetUnLogged")] - SetUnLogged, - #[serde(rename = "AT_DropOids")] - DropOids, - #[serde(rename = "AT_SetTableSpace")] - SetTableSpace, - #[serde(rename = "AT_SetRelOptions")] - SetRelOptions, - #[serde(rename = "AT_ResetRelOptions")] - ResetRelOptions, - #[serde(rename = "AT_ReplaceRelOptions")] - ReplaceRelOptions, - #[serde(rename = "AT_EnableTrig")] - EnableTrig, - #[serde(rename = "AT_EnableAlwaysTrig")] - EnableAlwaysTrig, - #[serde(rename = "AT_EnableReplicaTrig")] - EnableReplicaTrig, - #[serde(rename = "AT_DisableTrig")] - DisableTrig, - #[serde(rename = "AT_EnableTrigAll")] - EnableTrigAll, - #[serde(rename = "AT_DisableTrigAll")] - DisableTrigAll, - #[serde(rename = "AT_EnableTrigUser")] - EnableTrigUser, - #[serde(rename = "AT_DisableTrigUser")] - DisableTrigUser, - #[serde(rename = "AT_EnableRule")] - EnableRule, - #[serde(rename = "AT_EnableAlwaysRule")] - EnableAlwaysRule, - #[serde(rename = "AT_EnableReplicaRule")] - EnableReplicaRule, - #[serde(rename = "AT_DisableRule")] - DisableRule, - #[serde(rename = "AT_AddInherit")] - AddInherit, - #[serde(rename = "AT_DropInherit")] - DropInherit, - #[serde(rename = "AT_AddOf")] - AddOf, - #[serde(rename = "AT_DropOf")] - DropOf, - #[serde(rename = "AT_ReplicaIdentity")] - ReplicaIdentity, - #[serde(rename = "AT_EnableRowSecurity")] - EnableRowSecurity, - #[serde(rename = "AT_DisableRowSecurity")] - DisableRowSecurity, - #[serde(rename = "AT_ForceRowSecurity")] - ForceRowSecurity, - #[serde(rename = "AT_NoForceRowSecurity")] - NoForceRowSecurity, - #[serde(rename = "AT_GenericOptions")] - GenericOptions, - #[serde(rename = "AT_AttachPartition")] - AttachPartition, - #[serde(rename = "AT_DetachPartition")] - DetachPartition, - #[serde(rename = "AT_AddIdentity")] - AddIdentity, - #[serde(rename = "AT_SetIdentity")] - SetIdentity, - #[serde(rename = "AT_DropIdentity")] - DropIdentity, -} - -#[derive(Debug, Deserialize, Serialize)] -pub enum ColumnDefConstraint { - Constraint(Constraint), -} - -#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct PGString { - pub sval: String, -} - -#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct QualifiedName { - #[serde(rename = "String")] - pub string: PGString, -} - -/// -/// `TypeName` - specifies a type in definitions -/// -/// For `TypeName` structures generated internally, it is often easier to -/// specify the type by OID than by name. If `names` is NIL then the -/// actual type OID is given by `type_oid`, otherwise `type_oid` is unused. -/// Similarly, if `typmods` is NIL then the actual typmod is expected to -/// be prespecified in typemod, otherwise typemod is unused. -/// -/// If `pct_type` is true, then `names` is actually a field name and we look up -/// the type of that field. Otherwise (the normal case), `names` is a type -/// name possibly qualified with schema and database name. -/// -#[derive(Debug, Deserialize, Serialize)] -pub struct TypeName { - /// qualified name (list of Value strings) - #[serde(default)] - pub names: Vec, - /// type identified by OID - #[serde(rename = "typeOid")] - pub type_oid: Option, - /// is a set? - #[serde(default)] - pub setof: bool, - /// %TYPE specified? - #[serde(default)] - pub pct_type: bool, - /// type modifier expression(s) - #[serde(default)] - pub typmods: Vec, - /// prespecified type modifier - pub typemod: i32, - #[serde(rename = "arrayBounds", default)] - pub array_bounds: Vec, - /// token location, or -1 if unknown - pub location: i32, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct ColumnDef { - // int inhcount; /* number of times column is inherited */ - // bool is_not_null; /* NOT NULL constraint specified? */ - // bool is_from_type; /* column definition came from table type */ - // bool is_from_parent; /* column def came from partition parent */ - // char storage; /* attstorage setting, or 0 for default */ - /// default value (untransformed parse tree) - // raw_default: Value, - // Node *cooked_default; /* default value (transformed expr tree) */ - // char identity; /* attidentity setting */ - // RangeVar *identitySequence; /* to store identity sequence name for ALTER - // * TABLE ... ADD COLUMN */ - // CollateClause *collClause; /* untransformed COLLATE spec, if any */ - // Oid collOid; /* collation OID (InvalidOid if not set) */ - // List *fdwoptions; /* per-column FDW options */ - pub colname: Option, - #[serde(rename = "typeName")] - pub type_name: TypeName, - #[serde(default)] - pub constraints: Vec, - /// column has local (non-inherited) def'n - #[serde(default)] - pub is_local: bool, - pub location: i32, -} - -#[derive(Debug, Deserialize, Serialize)] -pub enum AlterTableDef { - TypeCast(Value), - FuncCall(Value), - Constraint(Constraint), - ColumnDef(ColumnDef), - #[serde(rename = "A_Const")] - Constant(Value), - ReplicaIdentityStmt(Value), - SQLValueFunction(Value), - List(Value), - PartitionCmd(Value), -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct AlterTableCmd { - /// Type of table alteration to apply - pub subtype: AlterTableType, - /// column, constraint, or trigger to act on, or tablespace - pub name: Option, - /// definition of new column, index, constraint, or parent table - pub def: Option, - #[serde(default)] - pub behavior: DropBehavior, - // RoleSpec *newowner; - /// skip error if missing? - #[serde(default)] - pub missing_ok: bool, -} - -/// 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, - #[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, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct Constraint { - #[serde(default)] - pub conname: Option, - pub contype: ConstrType, - - /* Fields used for most/all constraint types: */ - // char *conname; /* Constraint name, or NULL if unnamed */ - // bool deferrable; /* DEFERRABLE? */ - // bool initdeferred; /* INITIALLY DEFERRED? */ - /// token location, or -1 if unknown - #[serde(default)] - pub location: Option, - - /* Fields used for constraints with expressions (CHECK and DEFAULT): */ - // bool is_no_inherit; /* is constraint non-inheritable? */ - /// expr, as untransformed parse tree - pub raw_expr: Option, - // char *cooked_expr; /* expr, as nodeToString representation */ - // char generated_when; - - // Fields used for unique constraints (UNIQUE and PRIMARY KEY): */ - /// String nodes naming referenced column(s) - pub keys: Option, - - /* Fields used for EXCLUSION constraints: */ - // List *exclusions; /* list of (IndexElem, operator name) pairs */ - - /* Fields used for index constraints (UNIQUE, PRIMARY KEY, EXCLUSION): */ - // List *options; /* options from WITH clause */ - /// existing index to use; otherwise NULL - pub indexname: Option, - // char *indexspace; /* index tablespace; NULL for default */ - /* These could be, but currently are not, used for UNIQUE/PKEY: */ - // char *access_method; /* index access method; NULL for default */ - // Node *where_clause; /* partial index predicate */ - - /* Fields used for FOREIGN KEY constraints: */ - // RangeVar *pktable; /* Primary key table */ - // List *fk_attrs; /* Attributes of foreign key */ - // List *pk_attrs; /* Corresponding attrs in PK table */ - // char fk_matchtype; /* FULL, PARTIAL, SIMPLE */ - // char fk_upd_action; /* ON UPDATE action */ - // char fk_del_action; /* ON DELETE action */ - // List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */ - // Oid old_pktable_oid; /* pg_constraint.confrelid of my former - /// skip validation of existing rows? - #[serde(default)] - pub skip_validation: bool, - /// mark the new constraint as valid? - #[serde(default)] - pub initially_valid: bool, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct TableLikeClause { - pub relation: RangeVar, - pub options: i32, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct RenameStmt { - // Node *object; /* in case it's some other object */ - pub newname: String, - pub behavior: DropBehavior, - // in case it's a table - pub relation: Option, - #[serde(rename = "relationType")] - pub relation_type: ObjectType, - #[serde(rename = "renameType")] - pub rename_type: ObjectType, - /// name of contained object (column, rule, trigger, etc) - pub subname: Option, - // bool missing_ok; /* skip error if missing? */ -} - -#[derive(Debug, Deserialize, Serialize)] -pub enum TableElt { - ColumnDef(ColumnDef), - Constraint(Constraint), - TableLikeClause(TableLikeClause), -} - -/// What to do at commit time for temporary relations -#[derive(Serialize, Deserialize, PartialEq, Debug)] -pub enum OnCommitAction { - #[serde(rename = "ONCOMMIT_NOOP")] - Noop, - #[serde(rename = "ONCOMMIT_PRESERVE_ROWS")] - PreserveRows, - #[serde(rename = "ONCOMMIT_DELETE_ROWS")] - DeleteRows, - #[serde(rename = "ONCOMMIT_DROP")] - Drop, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct CreateStmt { - /// relation to create - pub relation: RangeVar, - /// column definitions (list of `ColumnDef`) - #[serde(rename = "tableElts", default)] - pub table_elts: Vec, - /// relations to inherit from (list of inhRelation) - #[serde(rename = "inhRelations")] - #[serde(default)] - pub inh_relations: Vec, - /// FOR VALUES clause - pub partbound: Option, - /// PARTITION BY clause - pub partspec: Option, - /// OF typename - #[serde(rename = "ofTypename")] - pub of_typename: Option, - /// constraints (list of Constraint nodes) - #[serde(default)] - pub constraints: Vec, - /// options from WITH clause - #[serde(default)] - pub options: Vec, - /// what do we do at COMMIT? - pub oncommit: OnCommitAction, - /// table space to use, or NULL - pub tablespacename: Option, - /// just do nothing if it already exists? - #[serde(default)] - pub if_not_exists: bool, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct DropStmt { - pub behavior: DropBehavior, - #[serde(default)] - pub concurrent: bool, - #[serde(default)] - pub missing_ok: bool, - #[serde(rename = "removeType")] - pub remove_type: ObjectType, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct StmtRoot { - pub stmts: Vec, -} - -/// case for each node type found in Postgres' parsenodes.h -/// -#[allow(clippy::large_enum_variant)] -#[derive(Debug, Deserialize, Serialize)] -pub enum Stmt { - TransactionStmt(TransactionStmt), - SelectStmt(SelectStmt), - IndexStmt(IndexStmt), - AlterTableStmt(AlterTableStmt), - RenameStmt(RenameStmt), - CreateStmt(CreateStmt), - InsertStmt(Value), - UpdateStmt(Value), - DeleteStmt(Value), - CreateSchemaStmt(Value), - AlterDomainStmt(AlterDomainStmt), - GrantStmt(Value), - GrantRoleStmt(Value), - AlterDefaultPrivilegesStmt(Value), - CopyStmt(Value), - VariableSetStmt(Value), - VariableShowStmt(Value), - CreateTableSpaceStmt(Value), - DropTableSpaceStmt(Value), - CreateExtensionStmt(Value), - AlterExtensionStmt(Value), - DropStmt(DropStmt), - AlterObjectSchemaStmt(Value), - AlterExtensionContentsStmt(Value), - CreateFdwStmt(Value), - AlterFdwStmt(Value), - CreateForeignServerStmt(Value), - AlterForeignServerStmt(Value), - CreateForeignTableStmt(Value), - CreateUserMappingStmt(Value), - AlterUserMappingStmt(Value), - DropUserMappingStmt(Value), - ImportForeignSchemaStmt(Value), - CreatePolicyStmt(Value), - AlterPolicyStmt(Value), - CreateAmStmt(Value), - CreateTrigStmt(Value), - CreateEventTrigStmt(Value), - AlterEventTrigStmt(Value), - CreateFunctionStmt(Value), - CallStmt(Value), - AlterFunctionStmt(Value), - CreatePLangStmt(Value), - CreateRoleStmt(Value), - AlterRoleStmt(Value), - AlterRoleSetStmt(Value), - DropRoleStmt(Value), - CreateSeqStmt(Value), - AlterSeqStmt(Value), - DefineStmt(Value), - CreateDomainStmt(CreateDomainStmt), - CreateOpClassStmt(Value), - CreateOpFamilyStmt(Value), - AlterOpFamilyStmt(Value), - TruncateStmt(Value), - CommentStmt(Value), - SecLabelStmt(Value), - DeclareCursorStmt(Value), - ClosePortalStmt(Value), - FetchStmt(Value), - CreateStatsStmt(Value), - ExplainStmt(Value), - AlterOwnerStmt(Value), - DoStmt(Value), - AlterObjectDependsStmt(Value), - AlterOperatorStmt(Value), - RuleStmt(Value), - NotifyStmt(Value), - ListenStmt(Value), - UnlistenStmt(Value), - CompositeTypeStmt(Value), - CreateEnumStmt(Value), - CreateRangeStmt(Value), - AlterEnumStmt(Value), - ViewStmt(Value), - LoadStmt(Value), - CreatedbStmt(Value), - AlterDatabaseRefreshCollStmt(Value), - AlterDatabaseStmt(Value), - AlterDatabaseSetStmt(Value), - DropdbStmt(Value), - AlterSystemStmt(Value), - ClusterStmt(Value), - VacuumStmt(Value), - CreateTableAsStmt(Value), - RefreshMatViewStmt(Value), - CheckPointStmt(Value), - DiscardStmt(Value), - LockStmt(Value), - ConstraintsSetStmt(Value), - ReindexStmt(Value), - CreateConversionStmt(Value), - CreateCastStmt(Value), - CreateTransformStmt(Value), - PrepareStmt(Value), - ExecuteStmt(Value), - DeallocateStmt(Value), - DropOwnedStmt(Value), - ReassignOwnedStmt(Value), - AlterTSDictionaryStmt(Value), - AlterTSConfigurationStmt(Value), - CreatePublicationStmt(Value), - AlterPublicationStmt(Value), - CreateSubscriptionStmt(Value), - AlterSubscriptionStmt(Value), - DropSubscriptionStmt(Value), -} diff --git a/crates/parser/src/error.rs b/crates/parser/src/error.rs deleted file mode 100644 index 49ab87a7..00000000 --- a/crates/parser/src/error.rs +++ /dev/null @@ -1,52 +0,0 @@ -#[derive(Debug, PartialEq)] -pub enum PgQueryError { - ParsingCString, - JsonParse(String), - QueryToCString, - // The only useful field on PgQueryError is `message`. - // The other `lineo` and `filename` fields are just references to the Postgres parser code. - // - // https://cs.github.com/pganalyze/libpg_query/blob/4b30b03cb3944f01d4807ee89532549ccf115a44/pg_query.h?q=PgQueryError#L6-L13 - PgParseError(Option), -} - -impl std::fmt::Display for PgQueryError { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match *self { - Self::ParsingCString => write!( - f, - "Could not convert Postgres response from CString to String" - ), - Self::JsonParse(ref err) => write!( - f, - "Squawk schema failed to parse Postgres response. This indicates a bug with Squawk. Please report this error to https://github.com/sbdchd/squawk. Schema error: {err}" - ), - Self::QueryToCString => write!(f, "Could not encode query into CString"), - Self::PgParseError(ref err) => { - if let Some(err) = err { - write!(f, "Postgres failed to parse query: {err}") - } else { - write!(f, "Postgres failed to parse query.") - } - }, - } - } -} - -impl std::convert::From for PgQueryError { - fn from(_: std::ffi::NulError) -> Self { - Self::QueryToCString - } -} - -impl std::convert::From for PgQueryError { - fn from(e: serde_json::error::Error) -> Self { - Self::JsonParse(e.to_string()) - } -} - -impl std::convert::From for PgQueryError { - fn from(_: std::str::Utf8Error) -> Self { - Self::ParsingCString - } -} diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs deleted file mode 100644 index 77f7e1a4..00000000 --- a/crates/parser/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[allow(clippy::module_name_repetitions)] -#[allow(clippy::struct_excessive_bools)] -pub mod ast; -#[allow(clippy::module_name_repetitions)] -pub mod error; -#[allow(clippy::module_name_repetitions)] -#[allow(clippy::shadow_unrelated)] -#[allow(clippy::doc_markdown)] -#[allow(clippy::missing_errors_doc)] -pub mod parse; diff --git a/crates/parser/src/parse.rs b/crates/parser/src/parse.rs deleted file mode 100644 index fc620c5a..00000000 --- a/crates/parser/src/parse.rs +++ /dev/null @@ -1,1379 +0,0 @@ -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}; -use std::os::raw::c_char; - -fn parse_str_or_none(str_ptr: *mut c_char) -> Option { - if str_ptr.is_null() { - None - } else { - unsafe { Some(CStr::from_ptr(str_ptr).to_string_lossy().into()) } - } -} - -fn parse_sql_query_base<'a, T>(query: &'a str) -> Result -where - T: Deserialize<'a>, -{ - let c_str = CString::new(query)?; - let pg_parse_result = unsafe { pg_query_parse(c_str.as_ptr()) }; - - if !pg_parse_result.error.is_null() { - unsafe { - let err = *pg_parse_result.error; - return Err(PgQueryError::PgParseError(parse_str_or_none(err.message))); - } - } - - // not sure if this is ever null, but might as well check - if pg_parse_result.parse_tree.is_null() { - return Err(PgQueryError::ParsingCString); - } - - let parse_tree = unsafe { CStr::from_ptr(pg_parse_result.parse_tree) }.to_str()?; - let output = - serde_json::from_str(parse_tree).map_err(|e| PgQueryError::JsonParse(e.to_string())); - - unsafe { - pg_query_free_parse_result(pg_parse_result); - }; - - output -} - -pub fn parse_sql_query_json(query: &str) -> Result { - 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)] -mod tests { - use super::*; - - use insta::assert_debug_snapshot; - - #[test] - fn parse_sql_query_json_works() { - 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 span_with_indent() { - // NOTE: the span information for these starts at 0 even though the SQL - // is offset. - let sql = r" SELECT 1;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - #[test] - fn span_with_new_line_and_indent() { - let sql = r" - SELECT 1;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn adding_index_non_concurrently() { - let sql = r#" - -- instead of - CREATE INDEX "field_name_idx" ON "table_name" ("field_name"); - -- use CONCURRENTLY - CREATE INDEX CONCURRENTLY "field_name_idx" ON "table_name" ("field_name"); - "#; - - let res = parse_sql_query(sql); - - assert_debug_snapshot!(res); - } - - #[test] - fn create_index_without_index_name() { - let sql = "CREATE INDEX ON FOO(BAR);"; - let res = parse_sql_query(sql); - assert!(res.is_ok()); - assert_debug_snapshot!(res); - } - - #[test] - fn error_paths() { - let sql = r"lsakdjf;asdlfkjasd;lfj"; - let res = parse_sql_query(sql).unwrap_err(); - assert_debug_snapshot!(res); - } - - #[test] - fn migration() { - let sql = r#" -BEGIN; -CREATE INDEX "table_name_field_name_idx" ON "table_name" ("field_name"); -CREATE INDEX "table_name_field_name_idx" ON "table_name" ("field_name" varchar_pattern_ops); -COMMIT; -"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn select_string_literal() { - let sql = r"SELECT 'some string';"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn select_one() { - let sql = r"SELECT 1;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - #[test] - fn parse_sql_create_index_concurrently() { - let sql = r#"CREATE INDEX CONCURRENTLY "table_name_idx" ON "table_name" ("table_field");"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_insert_stmt() { - let sql = r"INSERT INTO table_name VALUES (1, 2, 3);"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_update_stmt() { - let sql = r"UPDATE table_name SET foo = 'bar' WHERE buzz > 10;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_create_table() { - let sql = r#" -BEGIN; -CREATE TABLE "core_foo" ( - "id" serial NOT NULL PRIMARY KEY, - "created" timestamp with time zone NOT NULL, - "modified" timestamp with time zone NOT NULL, - "mongo_id" varchar(255) NOT NULL UNIQUE, - "description" text NOT NULL, - "metadata" jsonb NOT NULL, - "kind" varchar(255) NOT NULL, - "age" integer NOT NULL, - "tenant_id" integer NULL -); -CREATE INDEX "age_index" ON "core_foo" ("age"); -COMMIT; -"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_create_table_using_like() { - let sql = - r"CREATE TABLE core_bar (LIKE core_foo INCLUDING DEFAULTS INCLUDING CONSTRAINTS);"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_sql_create_index() { - let sql = r#"CREATE INDEX "table_name_idx" ON "table_name" ("table_field");"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - #[test] - fn parse_sql_create_unique_index_safe() { - let sql = r#" -ALTER TABLE "legacy_questiongrouppg" - ADD CONSTRAINT "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq" UNIQUE - USING INDEX "legacy_questiongrouppg_mongo_id_1f8f47d9_uniq_idx"; -"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - #[test] - fn parse_delete_stmt() { - let sql = r#"DELETE FROM "table_name";"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_delete_stmt_2() { - let sql = r#"DELETE FROM "table_name" WHERE account_age > 10;"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_set_operations_stmt() { - let sql = r#"SELECT * from "table_name" UNION SELECT * from "table_foo";"#; - let res = parse_sql_query(sql).unwrap(); - assert_debug_snapshot!(res); - - let sql = r#"SELECT * from "table_name" UNION ALL SELECT * from "table_foo";"#; - let res = parse_sql_query(sql).unwrap(); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_set_operations_stmt_2() { - let sql = r#"SELECT * from "table_name" UNION ALL SELECT * from "table_foo";"#; - let res = parse_sql_query(sql).unwrap(); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_create_schema_stmt() { - let sql = r"CREATE SCHEMA schema_name;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_replica_identity_stmt() { - let sql = "ALTER TABLE aa REPLICA IDENTITY FULL;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_alter_table_set_list() { - let sql = "ALTER TABLE table_name SET (autovacuum_vacuum_scale_factor = 0.0);"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_alter_collation_stmt() { - let sql = "ALTER COLLATION name RENAME TO new_name;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_alter_domain_stmt() { - let sql = "ALTER DOMAIN zipcode SET NOT NULL;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_grant_stmt() { - let sql = "GRANT INSERT ON films TO PUBLIC;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_grant_role() { - let sql = "GRANT admins TO joe;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_default_privileges_stmt() { - let sql = "ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON TABLES TO PUBLIC;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_copy_stmt() { - let sql = "COPY country FROM '/usr1/proj/bray/sql/country_data';"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_variable_set_stmt() { - let sql = "set session my.vars.id = '1';"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_variable_show_stmt() { - let sql = "SHOW name"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_create_table_space_stmt() { - let sql = "CREATE TABLESPACE dbspace LOCATION '/data/dbs';"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parsing_drop_table_space_stmt() { - let sql = "DROP TABLESPACE dbspace;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_table_space_stmt() { - let sql = "ALTER TABLESPACE index_space RENAME TO fast_raid;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_extension() { - let sql = "CREATE EXTENSION hstore;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_table_extension() { - let sql = "ALTER EXTENSION hstore UPDATE TO '2.0';"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_extension() { - let sql = "DROP EXTENSION hstore;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_extension_contents_stmt() { - let sql = "ALTER EXTENSION hstore SET SCHEMA utils;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - - let sql = "ALTER EXTENSION hstore ADD FUNCTION populate_record(anyelement, hstore);"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_foreign_data_wrapper() { - let sql = "CREATE FOREIGN DATA WRAPPER dummy;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_foreign_data_wrapper() { - let sql = "ALTER FOREIGN DATA WRAPPER dbi OPTIONS (ADD foo '1', DROP 'bar');"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_foreign_server_stmt() { - let sql = "CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_foreign_server_stmt() { - let sql = "ALTER SERVER foo OPTIONS (host 'foo', dbname 'foodb');"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_foriegn_table_stmt() { - let sql = r" -CREATE FOREIGN TABLE films ( - code char(5) NOT NULL, - title varchar(40) NOT NULL, - did integer NOT NULL, - date_prod date, - kind varchar(10), - len interval hour to minute -) -SERVER film_server; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_user_mapping_stmt() { - let sql = "CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_user_mapping_stmt() { - let sql = "ALTER USER MAPPING FOR bob SERVER foo OPTIONS (SET password 'public');"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_user_mapping_stmt() { - let sql = "DROP USER MAPPING IF EXISTS FOR bob SERVER foo;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn import_foreign_schema_stmt() { - let sql = r" -IMPORT FOREIGN SCHEMA foreign_films - FROM SERVER film_server INTO films; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_policy_stmt() { - let sql = "CREATE POLICY name ON table_name FOR ALL;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_policy_stmt() { - let sql = "ALTER POLICY name ON table_name RENAME TO new_name;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - - let sql = "ALTER POLICY name ON table_name TO PUBLIC WITH CHECK (account_age > 10);"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_access_method_stmt() { - let sql = "CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_trigger_stmt() { - let sql = r" -CREATE TRIGGER check_update - BEFORE UPDATE ON accounts - FOR EACH ROW - EXECUTE PROCEDURE check_account_update(); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_event_trigger_stmt() { - let sql = r" -CREATE EVENT TRIGGER abort_ddl ON ddl_command_start - EXECUTE PROCEDURE abort_any_command(); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_event_trigger_stmt() { - let sql = r" -ALTER EVENT TRIGGER name DISABLE; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - /// Postgres >=11 feature not supported in libpg_query - #[test] - fn create_procedure_stmt() { - let sql = r" -CREATE PROCEDURE insert_data(a integer, b integer) -LANGUAGE SQL -AS $$ -INSERT INTO tbl VALUES (a); -INSERT INTO tbl VALUES (b); -$$; - -CALL insert_data(1, 2); -"; - let res = parse_sql_query(sql).unwrap(); - assert_debug_snapshot!(res); - } - - #[test] - fn create_function_stmt() { - let sql = r" -CREATE FUNCTION populate() RETURNS integer AS $$ -DECLARE - -- declarations -BEGIN - PERFORM my_function(); -END; -$$ LANGUAGE plpgsql; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_plang_stmt() { - let sql = r" -CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql - HANDLER plpgsql_call_handler - VALIDATOR plpgsql_validator; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_role_stmt() { - let sql = r" -CREATE ROLE miriam - WITH LOGIN PASSWORD 'jw8s0F4' - VALID UNTIL '2005-01-01'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_role_stmt() { - let sql = r" -ALTER ROLE miriam CREATEROLE CREATEDB; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_role_set_stmt() { - let sql = r" -ALTER ROLE worker_bee SET maintenance_work_mem = 100000; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_role_set_stmt() { - let sql = r" -DROP ROLE jonathan; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_sequence_stmt() { - let sql = r" -CREATE SEQUENCE serial START 101; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_sequence_stmt() { - let sql = r" -ALTER SEQUENCE serial RESTART WITH 105; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn define_stmt() { - let sql = r" -CREATE AGGREGATE sum (complex) -( - sfunc = complex_add, - stype = complex, - initcond = '(0,0)' -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - - let sql = r" -CREATE OPERATOR === ( - LEFTARG = box, - RIGHTARG = box, - PROCEDURE = area_equal_procedure, - COMMUTATOR = ===, - NEGATOR = !==, - RESTRICT = area_restriction_procedure, - JOIN = area_join_procedure, - HASHES, MERGES -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - - let sql = r" -CREATE TYPE box ( - INTERNALLENGTH = 16, - INPUT = my_box_in_function, - OUTPUT = my_box_out_function, - ELEMENT = float4 -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_domain_stmt() { - let sql = r" -CREATE DOMAIN us_postal_code AS TEXT -CHECK( - VALUE ~ '^\d{5}$' -OR VALUE ~ '^\d{5}-\d{4}$' -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_op_class_stmt() { - let sql = r" -CREATE OPERATOR CLASS gist__int_ops - DEFAULT FOR TYPE _int4 USING gist AS - OPERATOR 3 &&, - OPERATOR 6 = (anyarray, anyarray), - OPERATOR 7 @>, - OPERATOR 8 <@, - OPERATOR 20 @@ (_int4, query_int), - FUNCTION 1 g_int_consistent (internal, _int4, int, oid, internal), - FUNCTION 2 g_int_union (internal, internal), - FUNCTION 3 g_int_compress (internal), - FUNCTION 4 g_int_decompress (internal), - FUNCTION 5 g_int_penalty (internal, internal, internal), - FUNCTION 6 g_int_picksplit (internal, internal), - FUNCTION 7 g_int_same (_int4, _int4, internal); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_op_class_stmt() { - let sql = r" -ALTER OPERATOR CLASS name USING index_method RENAME TO new_name; -ALTER OPERATOR CLASS name USING index_method - OWNER TO CURRENT_USER; -ALTER OPERATOR CLASS name USING index_method - SET SCHEMA new_schema; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_op_family_stmt() { - let sql = r" -ALTER OPERATOR FAMILY integer_ops USING btree ADD - - -- int4 vs int2 - OPERATOR 1 < (int4, int2) , - OPERATOR 2 <= (int4, int2) , - OPERATOR 3 = (int4, int2) , - OPERATOR 4 >= (int4, int2) , - OPERATOR 5 > (int4, int2) , - FUNCTION 1 btint42cmp(int4, int2) , - - -- int2 vs int4 - OPERATOR 1 < (int2, int4) , - OPERATOR 2 <= (int2, int4) , - OPERATOR 3 = (int2, int4) , - OPERATOR 4 >= (int2, int4) , - OPERATOR 5 > (int2, int4) , - FUNCTION 1 btint24cmp(int2, int4) ; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn truncate_stmt() { - let sql = r" -TRUNCATE bigtable, fattable, bar RESTART IDENTITY; -TRUNCATE foo CASCADE; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn comment_on_stmt() { - let sql = r" -COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn security_label_stmt() { - let sql = r" -SECURITY LABEL FOR selinux ON TABLE mytable IS 'system_u:object_r:sepgsql_table_t:s0'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn declare_cursor_stmt() { - let sql = r" -DECLARE - curs2 CURSOR FOR SELECT * FROM tenk1; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn close_portal_stmt() { - let sql = r" -CLOSE curs1; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn fetch_stmt() { - let sql = r" -FETCH FORWARD 5 FROM foo; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_stats_stmt() { - let sql = r" -CREATE STATISTICS s1 (dependencies) ON a, b FROM t1; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn explain_stmt() { - let sql = r" -EXPLAIN ANALYZE SELECT * FROM t1 WHERE (a = 1) AND (b = 0); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_function_stmt() { - let sql = r" -ALTER FUNCTION sqrt(integer) RENAME TO square_root; -ALTER FUNCTION sqrt(integer) OWNER TO joe; -ALTER FUNCTION sqrt(integer) SET SCHEMA maths; -ALTER FUNCTION check_password(text) SET search_path = admin, pg_temp; -ALTER FUNCTION check_password(text) RESET search_path; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn do_stmt() { - let sql = r" -DO $$DECLARE r record; -BEGIN - FOR r IN SELECT table_schema, table_name FROM information_schema.tables - WHERE table_type = 'VIEW' AND table_schema = 'public' - LOOP - EXECUTE 'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser'; - END LOOP; -END$$; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_object_depends_stmt() { - let sql = r" -ALTER TRIGGER name ON table_name - DEPENDS ON EXTENSION extension_name; -ALTER FUNCTION sqrt(integer) - DEPENDS ON EXTENSION extension_name; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_operator_stmt() { - let sql = r" -ALTER OPERATOR @@ (text, text) OWNER TO joe; -ALTER OPERATOR @@ (text, text) SET SCHEMA bar; -ALTER OPERATOR && (_int4, _int4) SET (RESTRICT = _int_contsel, JOIN = _int_contjoinsel); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn rule_stmt() { - let sql = r#" -CREATE RULE "_RETURN" AS - ON SELECT TO t1 - DO INSTEAD - SELECT * FROM t2; - -CREATE RULE notify_me AS ON UPDATE TO mytable DO ALSO NOTIFY mytable; -"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn notify_stmt() { - let sql = r" -NOTIFY virtual; -NOTIFY virtual, 'This is the payload'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn listen_stmt() { - let sql = r" -LISTEN virtual; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn unlisten_stmt() { - let sql = r" -UNLISTEN virtual; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn composite_type_stmt() { - let sql = r" -CREATE TYPE complex AS ( - r double precision, - i double precision -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_enum_stmt() { - let sql = r" -CREATE TYPE happiness AS ENUM ('happy', 'very happy', 'ecstatic'); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_range_stmt() { - let sql = r" -CREATE TYPE floatrange AS RANGE ( - subtype = float8, - subtype_diff = float8mi -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_enum_stmt() { - let sql = r" -ALTER TYPE colors ADD VALUE 'orange' AFTER 'red'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_view_stmt() { - let sql = r" -CREATE VIEW vista AS SELECT 'Hello World'; -CREATE VIEW comedies AS - SELECT * - FROM films - WHERE kind = 'Comedy'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn load_stmt() { - let sql = r" -LOAD 'filename'; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_database_stmt() { - let sql = r" -CREATE DATABASE lusiadas; -CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace; -CREATE DATABASE music ENCODING 'LATIN1' TEMPLATE template0; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_database_stmt() { - let sql = r" -ALTER DATABASE name RENAME TO new_name; -ALTER DATABASE name OWNER TO new_owner; -ALTER DATABASE name SET TABLESPACE new_tablespace; -ALTER DATABASE name RESET configuration_parameter; -ALTER DATABASE name RESET ALL; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_database_collation() { - let sql = r" -ALTER DATABASE pipelines REFRESH COLLATION VERSION; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_database_stmt() { - let sql = r" -DROP DATABASE name; -DROP DATABASE IF EXISTS name; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_system_stmt() { - let sql = r" -ALTER SYSTEM SET wal_level = hot_standby; -ALTER SYSTEM RESET wal_level; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn cluster_stmt() { - let sql = r" -CLUSTER employees USING employees_ind; -CLUSTER employees; -CLUSTER; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn vacuum_stmt() { - let sql = r" -VACUUM (VERBOSE, ANALYZE) foo; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_table_as_stmt() { - let sql = r" -CREATE TABLE films2 AS - TABLE films; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn refresh_material_view_stmt() { - let sql = r" -REFRESH MATERIALIZED VIEW order_summary; -REFRESH MATERIALIZED VIEW annual_statistics_basis WITH NO DATA; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn checkpoint() { - let sql = r" -CHECKPOINT; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn discard_stmt() { - let sql = r" -DISCARD PLANS; -DISCARD SEQUENCES; -DISCARD TEMP; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn lock_stmt() { - let sql = r" -LOCK TABLE films IN SHARE MODE; -LOCK TABLE films IN SHARE ROW EXCLUSIVE MODE; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn set_constraints() { - let sql = r" -SET CONSTRAINTS ALL DEFERRED; -SET CONSTRAINTS ALL IMMEDIATE; -SET CONSTRAINTS foo IMMEDIATE; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn reindex_stmt() { - let sql = r" -REINDEX INDEX my_index; -REINDEX TABLE table_name; -REINDEX DATABASE table_name; -REINDEX SYSTEM table_name; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_conversion_stmt() { - let sql = r" -CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_cast_stmt() { - let sql = r" -CREATE CAST (bigint AS int4) WITH FUNCTION int4(bigint) AS ASSIGNMENT; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn regression_update_table() { - let sql = r#" - ALTER TABLE "table_name" ALTER COLUMN "column_name" SET DEFAULT false; - "#; - let res = parse_sql_query(sql); - assert!(res.is_ok()); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_column_default_with_function() { - let sql = r#" - ALTER TABLE "table_name" ALTER COLUMN "column_name" SET DEFAULT CURRENT_TIMESTAMP; - "#; - let res = parse_sql_query(sql); - assert!(res.is_ok()); - assert_debug_snapshot!(res); - } - - #[test] - fn create_transform_stmt() { - let sql = r" -CREATE TRANSFORM FOR hstore LANGUAGE plpythonu ( - FROM SQL WITH FUNCTION hstore_to_plpython(internal), - TO SQL WITH FUNCTION plpython_to_hstore(internal) -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn prepare_stmt() { - let sql = r" -PREPARE fooplan (int, text, bool, numeric) AS - INSERT INTO foo VALUES($1, $2, $3, $4); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn execute_stmt() { - let sql = r" -EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn deallocate_stmt() { - let sql = r" -DEALLOCATE PREPARE ALL; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_owned_stmt() { - let sql = r" -DROP OWNED BY foo CASCADE; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn reassign_owned_stmt() { - let sql = r" -REASSIGN OWNED BY old_role TO new_role; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_ts_dictionary_stmt() { - let sql = r" -ALTER TEXT SEARCH DICTIONARY my_dict ( StopWords = newrussian ); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_ts_configuration_stmt() { - let sql = r" -ALTER TEXT SEARCH CONFIGURATION astro_en - ADD MAPPING FOR asciiword WITH astrosyn, english_ispell, english_stem; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_publication_stmt() { - let sql = r" -CREATE PUBLICATION mypublication FOR TABLE users, departments; -CREATE PUBLICATION insert_only FOR TABLE mydata - WITH (publish = 'insert'); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_publication() { - let sql = r" -ALTER PUBLICATION noinsert SET (publish = 'update, delete'); -ALTER PUBLICATION mypublication ADD TABLE users, departments; -ALTER PUBLICATION name RENAME TO new_name -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - #[test] - fn parse_func_call() { - let sql = r" -ALTER TABLE foobar ALTER COLUMN value SET DEFAULT TO_JSON(false); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn json_index_operator() { - let sql = r#" -CREATE INDEX CONCURRENTLY IF NOT EXISTS "idx_a_foo_bar" ON "a" ((foo->>'bar')); -"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn create_subscription_stmt() { - let sql = r" -CREATE SUBSCRIPTION mysub - CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb' - PUBLICATION mypublication, insert_only; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn alter_subscription_stmt() { - let sql = r" -ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only; -ALTER SUBSCRIPTION mysub DISABLE; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_subscription_stmt() { - let sql = r" -DROP SUBSCRIPTION mysub; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_inh() { - let sql = r" -ALTER TABLE ONLY public.tasks - DROP CONSTRAINT tasks_fk, - ADD CONSTRAINT tasks_fk - FOREIGN KEY (job_id) REFERENCES public.jobs(external_id) - ON DELETE CASCADE NOT VALID; - -ALTER TABLE public.tasks VALIDATE CONSTRAINT tasks_fk; -"; - let res = parse_sql_query(sql); - assert!(res.is_ok()); - assert_debug_snapshot!(res); - } - #[test] - fn parse_alter_constraint_regression() { - let sql = r#" -ALTER TABLE "table" ALTER CONSTRAINT "constraint" DEFERRABLE INITIALLY IMMEDIATE; - -ALTER TABLE "table" ALTER CONSTRAINT "constraint" NOT DEFERRABLE; -"#; - let res = parse_sql_query(sql); - assert!(res.is_ok()); - 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 parse_create_table_regression() { - let sql = r" -CREATE TABLE example ( - a integer, - b integer, - c integer, - PRIMARY KEY (a, c) -); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_create_table_partition() { - let sql = r" -CREATE TABLE measurement_y2006m02 PARTITION OF measurement - FOR VALUES FROM ('2006-02-01') TO ('2006-03-01'); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_attach_table_partition() { - let sql = r" -ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02 - FOR VALUES FROM ('2008-02-01') TO ('2008-03-01' ); -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn parse_detach_table_partition() { - let sql = r" -ALTER TABLE measurement - DETACH PARTITION measurement_y2006m02; -"; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } - - #[test] - fn drop_index() { - let sql = r#" -DROP INDEX "email_idx"; -DROP INDEX IF EXISTS "email_idx"; -DROP INDEX CONCURRENTLY "email_idx"; -DROP INDEX CONCURRENTLY "email_idx"; -DROP INDEX CONCURRENTLY "email_idx" RESTRICT; - -DROP INDEX "email_idx", "name_idx"; -DROP INDEX "email_idx", "name_idx" CASCADE; -DROP INDEX "email_idx", "name_idx" RESTRICT; - -DROP INDEX IF EXISTS "email_idx", "name_idx"; -DROP INDEX IF EXISTS "email_idx", "name_idx" CASCADE; -DROP INDEX IF EXISTS "email_idx", "name_idx" RESTRICT; - -DROP INDEX CONCURRENTLY IF EXISTS "email_idx", "name_idx"; -DROP INDEX CONCURRENTLY IF EXISTS "email_idx", "name_idx" CASCADE; -DROP INDEX CONCURRENTLY IF EXISTS "email_idx", "name_idx" RESTRICT; -"#; - let res = parse_sql_query(sql); - assert_debug_snapshot!(res); - } -} diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap deleted file mode 100644 index 83dd1dff..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__adding_index_non_concurrently.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 52, - }, - 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, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 151, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap deleted file mode 100644 index 78a9b44a..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_column_default_with_function.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 21, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 90, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_collation.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_collation.snap deleted file mode 100644 index a0a7e319..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_collation.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterDatabaseRefreshCollStmt( - Object({ - "dbname": String( - "pipelines", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 51, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap deleted file mode 100644 index 0f9ae192..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_database_stmt.snap +++ /dev/null @@ -1,131 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - "rolename": String( - "new_owner", - ), - "roletype": String( - "ROLESPEC_CSTRING", - ), - }), - "object": Object({ - "String": Object({ - "sval": 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({ - "sval": String( - "new_tablespace", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "tablespace", - ), - "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 { - stmt: AlterDatabaseSetStmt( - Object({ - "dbname": String( - "name", - ), - "setstmt": Object({ - "kind": String( - "VAR_RESET_ALL", - ), - }), - }), - ), - stmt_location: 182, - stmt_len: Some( - 30, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap deleted file mode 100644 index 635f854a..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_default_privileges_stmt.snap +++ /dev/null @@ -1,81 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterDefaultPrivilegesStmt( - Object({ - "action": Object({ - "behavior": String( - "DROP_RESTRICT", - ), - "grantees": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 70, - ), - "roletype": String( - "ROLESPEC_PUBLIC", - ), - }), - }), - ]), - "is_grant": Bool( - true, - ), - "objtype": String( - "OBJECT_TABLE", - ), - "privileges": Array([ - Object({ - "AccessPriv": Object({ - "priv_name": String( - "select", - ), - }), - }), - ]), - "targtype": String( - "ACL_TARGET_DEFAULTS", - ), - }), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "myschema", - ), - }), - }), - ]), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "schemas", - ), - "location": Number( - 25, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 76, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap deleted file mode 100644 index 00ab7998..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_enum_stmt.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterEnumStmt( - Object({ - "newVal": String( - "orange", - ), - "newValIsAfter": Bool( - true, - ), - "newValNeighbor": String( - "red", - ), - "typeName": Array([ - Object({ - "String": Object({ - "sval": String( - "colors", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap deleted file mode 100644 index 7641d1cf..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_event_trigger_stmt.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterEventTrigStmt( - Object({ - "tgenabled": String( - "D", - ), - "trigname": String( - "name", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap deleted file mode 100644 index 6ea0d355..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt-2.snap +++ /dev/null @@ -1,130 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "anyelement", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 64, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "hstore", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 52, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "anyelement", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 64, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "hstore", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "populate_record", - ), - }), - }), - ]), - }), - }), - "objtype": String( - "OBJECT_FUNCTION", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 71, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap deleted file mode 100644 index ea96c4ad..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_extension_contents_stmt.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterObjectSchemaStmt( - Object({ - "newschema": String( - "utils", - ), - "object": Object({ - "String": Object({ - "sval": String( - "hstore", - ), - }), - }), - "objectType": String( - "OBJECT_EXTENSION", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap deleted file mode 100644 index 478bd871..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_data_wrapper.snap +++ /dev/null @@ -1,63 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterFdwStmt( - Object({ - "fdwname": String( - "dbi", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "1", - ), - }), - }), - "defaction": String( - "DEFELEM_ADD", - ), - "defname": String( - "foo", - ), - "location": Number( - 44, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "bar", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "drop", - ), - "location": Number( - 53, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 64, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap deleted file mode 100644 index 59c1e820..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_foreign_server_stmt.snap +++ /dev/null @@ -1,63 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterForeignServerStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "foo", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "host", - ), - "location": Number( - 26, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "foodb", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "dbname", - ), - "location": Number( - 38, - ), - }), - }), - ]), - "servername": String( - "foo", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 53, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap deleted file mode 100644 index bb84019a..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_function_stmt.snap +++ /dev/null @@ -1,430 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 73, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "sqrt", - ), - }), - }), - ]), - }), - }), - "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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 116, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "sqrt", - ), - }), - }), - ]), - }), - }), - "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, - ), - "sval": Object({ - "sval": String( - "admin", - ), - }), - }), - }), - Object({ - "A_Const": Object({ - "location": Number( - 204, - ), - "sval": Object({ - "sval": String( - "pg_temp", - ), - }), - }), - }), - ]), - "kind": String( - "VAR_SET_VALUE", - ), - "name": String( - "search_path", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "set", - ), - "location": Number( - 179, - ), - }), - }), - ]), - "func": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 173, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 173, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": 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, - ), - }), - }), - ]), - "func": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 243, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 243, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "check_password", - ), - }), - }), - ]), - }), - "objtype": String( - "OBJECT_FUNCTION", - ), - }), - ), - stmt_location: 212, - stmt_len: Some( - 54, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap deleted file mode 100644 index b9f9186b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_object_depends_stmt.snap +++ /dev/null @@ -1,145 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterObjectDependsStmt( - Object({ - "extname": Object({ - "sval": String( - "extension_name", - ), - }), - "object": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "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({ - "sval": String( - "extension_name", - ), - }), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 96, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 96, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "sqrt", - ), - }), - }), - ]), - }), - }), - "objectType": String( - "OBJECT_FUNCTION", - ), - }), - ), - stmt_location: 75, - stmt_len: Some( - 70, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap deleted file mode 100644 index 7d5d9d0b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_class_stmt.snap +++ /dev/null @@ -1,101 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "index_method", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "name", - ), - }), - }), - ]), - }), - }), - "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({ - "sval": String( - "index_method", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "name", - ), - }), - }), - ]), - }), - }), - "objectType": String( - "OBJECT_OPCLASS", - ), - }), - ), - stmt_location: 137, - stmt_len: Some( - 71, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap deleted file mode 100644 index 4614892a..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_op_family_stmt.snap +++ /dev/null @@ -1,864 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 92, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "<", - ), - }), - }), - ]), - }), - "number": Number( - 1, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 117, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 123, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "<=", - ), - }), - }), - ]), - }), - "number": Number( - 2, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 147, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 153, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "=", - ), - }), - }), - ]), - }), - "number": Number( - 3, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 178, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 184, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - ">=", - ), - }), - }), - ]), - }), - "number": Number( - 4, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 208, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 214, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - ">", - ), - }), - }), - ]), - }), - "number": Number( - 5, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 246, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 252, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 246, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 252, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "btint42cmp", - ), - }), - }), - ]), - }), - "number": Number( - 1, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 295, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 301, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "<", - ), - }), - }), - ]), - }), - "number": Number( - 1, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 326, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 332, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "<=", - ), - }), - }), - ]), - }), - "number": Number( - 2, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 356, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 362, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "=", - ), - }), - }), - ]), - }), - "number": Number( - 3, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 387, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 393, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - ">=", - ), - }), - }), - ]), - }), - "number": Number( - 4, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 417, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 423, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - ">", - ), - }), - }), - ]), - }), - "number": Number( - 5, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 455, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 461, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 455, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int2", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 461, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "btint24cmp", - ), - }), - }), - ]), - }), - "number": Number( - 1, - ), - }), - }), - ]), - "opfamilyname": Array([ - Object({ - "String": Object({ - "sval": String( - "integer_ops", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 467, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap deleted file mode 100644 index a79d7b47..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_operator_stmt.snap +++ /dev/null @@ -1,281 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterOwnerStmt( - Object({ - "newowner": Object({ - "location": Number( - 41, - ), - "rolename": String( - "joe", - ), - "roletype": String( - "ROLESPEC_CSTRING", - ), - }), - "object": Object({ - "ObjectWithArgs": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 20, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 26, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "@@", - ), - }), - }), - ]), - }), - }), - "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({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 71, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "@@", - ), - }), - }), - ]), - }), - }), - "objectType": String( - "OBJECT_OPERATOR", - ), - }), - ), - stmt_location: 45, - stmt_len: Some( - 46, - ), - }, - RawStmt { - stmt: AlterOperatorStmt( - Object({ - "opername": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 112, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 119, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "&&", - ), - }), - }), - ]), - }), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 142, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": 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({ - "sval": 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/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap deleted file mode 100644 index 8d583213..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt-2.snap +++ /dev/null @@ -1,94 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterPolicyStmt( - Object({ - "policy_name": String( - "name", - ), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 35, - ), - "roletype": String( - "ROLESPEC_PUBLIC", - ), - }), - }), - ]), - "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({ - "sval": String( - "account_age", - ), - }), - }), - ]), - "location": Number( - 54, - ), - }), - }), - "location": Number( - 66, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - ">", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 10, - ), - }), - "location": Number( - 68, - ), - }), - }), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 71, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap deleted file mode 100644 index d406047d..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_policy_stmt.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap deleted file mode 100644 index f3c148bb..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_publication.snap +++ /dev/null @@ -1,127 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterPublicationStmt( - Object({ - "action": String( - "AP_AddObjects", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "update, delete", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "publish", - ), - "location": Number( - 33, - ), - }), - }), - ]), - "pubname": String( - "noinsert", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 60, - ), - }, - RawStmt { - stmt: AlterPublicationStmt( - Object({ - "action": String( - "AP_AddObjects", - ), - "pubname": String( - "mypublication", - ), - "pubobjects": Array([ - Object({ - "PublicationObjSpec": Object({ - "pubobjtype": String( - "PUBLICATIONOBJ_TABLE", - ), - "pubtable": Object({ - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 104, - ), - "relname": String( - "users", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - }), - Object({ - "PublicationObjSpec": Object({ - "location": Number( - 111, - ), - "pubobjtype": String( - "PUBLICATIONOBJ_TABLE", - ), - "pubtable": Object({ - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 111, - ), - "relname": String( - "departments", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - }), - ]), - }), - ), - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap deleted file mode 100644 index bfeac455..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_set_stmt.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "ival": Object({ - "ival": Number( - 100000, - ), - }), - "location": Number( - 50, - ), - }), - }), - ]), - "kind": String( - "VAR_SET_VALUE", - ), - "name": String( - "maintenance_work_mem", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 56, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap deleted file mode 100644 index 95204d47..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_role_stmt.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterRoleStmt( - Object({ - "action": Number( - 1, - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Boolean": Object({ - "boolval": Bool( - true, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "createrole", - ), - "location": Number( - 19, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "Boolean": Object({ - "boolval": Bool( - true, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "createdb", - ), - "location": Number( - 30, - ), - }), - }), - ]), - "role": Object({ - "location": Number( - 12, - ), - "rolename": String( - "miriam", - ), - "roletype": String( - "ROLESPEC_CSTRING", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 38, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap deleted file mode 100644 index 6cf89bfd..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_sequence_stmt.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterSeqStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 105, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "restart", - ), - "location": Number( - 23, - ), - }), - }), - ]), - "sequence": Object({ - "inh": Bool( - true, - ), - "location": Number( - 16, - ), - "relname": String( - "serial", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap deleted file mode 100644 index 52b2c90a..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_subscription_stmt.snap +++ /dev/null @@ -1,71 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterSubscriptionStmt( - Object({ - "kind": String( - "ALTER_SUBSCRIPTION_SET_PUBLICATION", - ), - "publication": Array([ - Object({ - "String": Object({ - "sval": String( - "insert_only", - ), - }), - }), - ]), - "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({ - "Boolean": Object({ - "boolval": Bool( - false, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "enabled", - ), - "location": Number( - 55, - ), - }), - }), - ]), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 54, - stmt_len: Some( - 33, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap deleted file mode 100644 index 6ffbda6d..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_system_stmt.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterSystemStmt( - Object({ - "setstmt": Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 30, - ), - "sval": Object({ - "sval": String( - "hot_standby", - ), - }), - }), - }), - ]), - "kind": String( - "VAR_SET_VALUE", - ), - "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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap deleted file mode 100644 index 4c2bb449..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_extension.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterExtensionStmt( - Object({ - "extname": String( - "hstore", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "2.0", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "new_version", - ), - "location": Number( - 30, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 38, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap deleted file mode 100644 index 04e90c5b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_table_space_stmt.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap deleted file mode 100644 index 515037c2..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_configuration_stmt.snap +++ /dev/null @@ -1,80 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterTSConfigurationStmt( - Object({ - "cfgname": Array([ - Object({ - "String": Object({ - "sval": String( - "astro_en", - ), - }), - }), - ]), - "dicts": Array([ - Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "astrosyn", - ), - }), - }), - ]), - }), - }), - Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "english_ispell", - ), - }), - }), - ]), - }), - }), - Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "english_stem", - ), - }), - }), - ]), - }), - }), - ]), - "kind": String( - "ALTER_TSCONFIG_ADD_MAPPING", - ), - "tokentype": Array([ - Object({ - "String": Object({ - "sval": String( - "asciiword", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 115, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap deleted file mode 100644 index b15cc32f..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_ts_dictionary_stmt.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterTSDictionaryStmt( - Object({ - "dictname": Array([ - Object({ - "String": Object({ - "sval": String( - "my_dict", - ), - }), - }), - ]), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 52, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "newrussian", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "stopwords", - ), - "location": Number( - 40, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 64, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap deleted file mode 100644 index 1ee382e7..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__alter_user_mapping_stmt.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterUserMappingStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "public", - ), - }), - }), - "defaction": String( - "DEFELEM_SET", - ), - "defname": String( - "password", - ), - "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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap deleted file mode 100644 index f5dd31f3..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__checkpoint.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CheckPointStmt( - Object({}), - ), - stmt_location: 0, - stmt_len: Some( - 11, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap deleted file mode 100644 index 01d978ab..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__close_portal_stmt.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: ClosePortalStmt( - Object({ - "portalname": String( - "curs1", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 12, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap deleted file mode 100644 index 8063e20d..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__cluster_stmt.snap +++ /dev/null @@ -1,68 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: ClusterStmt( - Object({ - "indexname": String( - "employees_ind", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 9, - ), - "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 { - stmt: ClusterStmt( - Object({}), - ), - stmt_location: 58, - stmt_len: Some( - 8, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap deleted file mode 100644 index 978461ae..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__comment_on_stmt.snap +++ /dev/null @@ -1,98 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 36, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "my_aggregate", - ), - }), - }), - ]), - }), - }), - "objtype": String( - "OBJECT_AGGREGATE", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 83, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap deleted file mode 100644 index 01c05cdc..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__composite_type_stmt.snap +++ /dev/null @@ -1,105 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CompositeTypeStmt( - Object({ - "coldeflist": Array([ - Object({ - "ColumnDef": Object({ - "colname": String( - "r", - ), - "is_local": Bool( - true, - ), - "location": Number( - 30, - ), - "typeName": Object({ - "location": Number( - 38, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - }), - Object({ - "ColumnDef": Object({ - "colname": String( - "i", - ), - "is_local": Bool( - true, - ), - "location": Number( - 60, - ), - "typeName": Object({ - "location": Number( - 68, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - }), - ]), - "typevar": Object({ - "location": Number( - 13, - ), - "relname": String( - "complex", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 86, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap deleted file mode 100644 index 8d2bbdeb..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_access_method_stmt.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateAmStmt( - Object({ - "amname": String( - "heptree", - ), - "amtype": String( - "i", - ), - "handler_name": Array([ - Object({ - "String": Object({ - "sval": String( - "heptree_handler", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 63, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap deleted file mode 100644 index 8de20166..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_cast_stmt.snap +++ /dev/null @@ -1,134 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateCastStmt( - Object({ - "context": String( - "COERCION_ASSIGNMENT", - ), - "func": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 49, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 49, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - }), - "sourcetype": Object({ - "location": Number( - 14, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "targettype": Object({ - "location": Number( - 24, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 70, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap deleted file mode 100644 index c9c5f99f..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_conversion_stmt.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateConversionStmt( - Object({ - "conversion_name": Array([ - Object({ - "String": Object({ - "sval": String( - "myconv", - ), - }), - }), - ]), - "for_encoding_name": String( - "UTF8", - ), - "func_name": Array([ - Object({ - "String": Object({ - "sval": String( - "myfunc", - ), - }), - }), - ]), - "to_encoding_name": String( - "LATIN1", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 60, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap deleted file mode 100644 index 0b837603..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_database_stmt.snap +++ /dev/null @@ -1,131 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "salesapp", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "owner", - ), - "location": Number( - 49, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "salesspace", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "tablespace", - ), - "location": Number( - 64, - ), - }), - }), - ]), - }), - ), - stmt_location: 26, - stmt_len: Some( - 59, - ), - }, - RawStmt { - stmt: CreatedbStmt( - Object({ - "dbname": String( - "music", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "LATIN1", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "encoding", - ), - "location": Number( - 109, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "template0", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "template", - ), - "location": Number( - 127, - ), - }), - }), - ]), - }), - ), - stmt_location: 86, - stmt_len: Some( - 59, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap deleted file mode 100644 index bd69cad7..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_domain_stmt.snap +++ /dev/null @@ -1,164 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res - ---- -Ok( - [ - RawStmt { - stmt: CreateDomainStmt( - CreateDomainStmt { - domain_name: [ - QualifiedName { - string: PGString { - sval: "us_postal_code", - }, - }, - ], - typename: Object({ - "location": Number( - 33, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - constraints: [ - 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({ - "sval": String( - "value", - ), - }), - }), - ]), - "location": Number( - 48, - ), - }), - }), - "location": Number( - 54, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - "~", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 56, - ), - "sval": Object({ - "sval": String( - "^\\d{5}$", - ), - }), - }), - }), - }), - }), - Object({ - "A_Expr": Object({ - "kind": String( - "AEXPR_OP", - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "sval": String( - "value", - ), - }), - }), - ]), - "location": Number( - 69, - ), - }), - }), - "location": Number( - 75, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - "~", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 77, - ), - "sval": Object({ - "sval": String( - "^\\d{5}-\\d{4}$", - ), - }), - }), - }), - }), - }), - ]), - "boolop": String( - "OR_EXPR", - ), - "location": Number( - 66, - ), - }), - }), - }), - }), - ], - }, - ), - stmt_location: 0, - stmt_len: Some( - 94, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap deleted file mode 100644 index 5d7b4537..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_enum_stmt.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateEnumStmt( - Object({ - "typeName": Array([ - Object({ - "String": Object({ - "sval": String( - "happiness", - ), - }), - }), - ]), - "vals": Array([ - Object({ - "String": Object({ - "sval": String( - "happy", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "very happy", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "ecstatic", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 66, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap deleted file mode 100644 index 54c76027..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_event_trigger_stmt.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateEventTrigStmt( - Object({ - "eventname": String( - "ddl_command_start", - ), - "funcname": Array([ - Object({ - "String": Object({ - "sval": String( - "abort_any_command", - ), - }), - }), - ]), - "trigname": String( - "abort_ddl", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 93, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap deleted file mode 100644 index 1a238fdb..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_extension.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateExtensionStmt( - Object({ - "extname": String( - "hstore", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap deleted file mode 100644 index de765e5c..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_data_wrapper.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateFdwStmt( - Object({ - "fdwname": String( - "dummy", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap deleted file mode 100644 index 676649f1..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foreign_server_stmt.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateForeignServerStmt( - Object({ - "fdwname": String( - "postgres_fdw", - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "foo", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "host", - ), - "location": Number( - 66, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "foodb", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "dbname", - ), - "location": Number( - 78, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "5432", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "port", - ), - "location": Number( - 94, - ), - }), - }), - ]), - "servername": String( - "myserver", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 106, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap deleted file mode 100644 index 3d26b418..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_foriegn_table_stmt.snap +++ /dev/null @@ -1,349 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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( - 46, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "bpchar", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 5, - ), - }), - "location": Number( - 51, - ), - }), - }), - ]), - }), - }), - }), - 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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "varchar", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 40, - ), - }), - "location": Number( - 88, - ), - }), - }), - ]), - }), - }), - }), - 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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "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({ - "sval": String( - "date", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - }), - Object({ - "ColumnDef": Object({ - "colname": String( - "kind", - ), - "is_local": Bool( - true, - ), - "location": Number( - 162, - ), - "typeName": Object({ - "location": Number( - 174, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "varchar", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 10, - ), - }), - "location": Number( - 182, - ), - }), - }), - ]), - }), - }), - }), - Object({ - "ColumnDef": Object({ - "colname": String( - "len", - ), - "is_local": Bool( - true, - ), - "location": Number( - 191, - ), - "typeName": Object({ - "location": Number( - 203, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "interval", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - "typmods": Array([ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 3072, - ), - }), - "location": Number( - 212, - ), - }), - }), - ]), - }), - }), - }), - ]), - }), - "servername": String( - "film_server", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 247, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap deleted file mode 100644 index 8019cbaa..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_function_stmt.snap +++ /dev/null @@ -1,99 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateFunctionStmt( - Object({ - "funcname": Array([ - Object({ - "String": Object({ - "sval": String( - "populate", - ), - }), - }), - ]), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "\nDECLARE\n -- declarations\nBEGIN\n PERFORM my_function();\nEND;\n", - ), - }), - }), - ]), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "as", - ), - "location": Number( - 44, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "plpgsql", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "language", - ), - "location": Number( - 119, - ), - }), - }), - ]), - "returnType": Object({ - "location": Number( - 36, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 135, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap deleted file mode 100644 index 239231e0..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_index_without_index_name.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "foo", - inh: true, - relpersistence: "p", - alias: None, - location: 16, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap deleted file mode 100644 index 2a2128fd..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_op_class_stmt.snap +++ /dev/null @@ -1,1157 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateOpClassStmt( - Object({ - "amname": String( - "gist", - ), - "datatype": Object({ - "location": Number( - 58, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "isDefault": Bool( - true, - ), - "items": Array([ - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "&&", - ), - }), - }), - ]), - }), - "number": Number( - 3, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 149, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "anyarray", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 159, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "anyarray", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "=", - ), - }), - }), - ]), - }), - "number": Number( - 6, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "@>", - ), - }), - }), - ]), - }), - "number": Number( - 7, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "<@", - ), - }), - }), - ]), - }), - "number": Number( - 8, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 1, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 278, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 285, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "query_int", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "@@", - ), - }), - }), - ]), - }), - "number": Number( - 20, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 347, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 357, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 364, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 369, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "oid", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 374, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 347, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 357, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 364, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 369, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "oid", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 374, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_consistent", - ), - }), - }), - ]), - }), - "number": Number( - 1, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 430, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 440, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 430, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 440, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_union", - ), - }), - }), - ]), - }), - "number": Number( - 2, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 499, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 499, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_compress", - ), - }), - }), - ]), - }), - "number": Number( - 3, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 560, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 560, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_decompress", - ), - }), - }), - ]), - }), - "number": Number( - 4, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 618, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 628, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 638, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 618, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 628, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 638, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_penalty", - ), - }), - }), - ]), - }), - "number": Number( - 5, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 698, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 708, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 698, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 708, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_picksplit", - ), - }), - }), - ]), - }), - "number": Number( - 6, - ), - }), - }), - Object({ - "CreateOpClassItem": Object({ - "itemtype": Number( - 2, - ), - "name": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 763, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 770, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 777, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 763, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 770, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "_int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 777, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "g_int_same", - ), - }), - }), - ]), - }), - "number": Number( - 7, - ), - }), - }), - ]), - "opclassname": Array([ - Object({ - "String": Object({ - "sval": String( - "gist__int_ops", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 786, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap deleted file mode 100644 index 552c795a..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_plang_stmt.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreatePLangStmt( - Object({ - "plhandler": Array([ - Object({ - "String": Object({ - "sval": String( - "plpgsql_call_handler", - ), - }), - }), - ]), - "plname": String( - "plpgsql", - ), - "pltrusted": Bool( - true, - ), - "plvalidator": Array([ - Object({ - "String": Object({ - "sval": String( - "plpgsql_validator", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 108, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap deleted file mode 100644 index c1eee656..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_policy_stmt.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreatePolicyStmt( - Object({ - "cmd_name": String( - "all", - ), - "permissive": Bool( - true, - ), - "policy_name": String( - "name", - ), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - -1, - ), - "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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap deleted file mode 100644 index c5fcd17e..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_procedure_stmt.snap +++ /dev/null @@ -1,199 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -[ - RawStmt { - stmt: CreateFunctionStmt( - Object({ - "funcname": Array([ - Object({ - "String": Object({ - "sval": String( - "insert_data", - ), - }), - }), - ]), - "is_procedure": Bool( - true, - ), - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "sql", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "language", - ), - "location": Number( - 52, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "\nINSERT INTO tbl VALUES (a);\nINSERT INTO tbl VALUES (b);\n", - ), - }), - }), - ]), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "as", - ), - "location": Number( - 65, - ), - }), - }), - ]), - "parameters": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 32, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - "name": String( - "a", - ), - }), - }), - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 43, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - "name": String( - "b", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 129, - ), - }, - RawStmt { - stmt: CallStmt( - Object({ - "funccall": Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 149, - ), - }), - }), - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 2, - ), - }), - "location": Number( - 152, - ), - }), - }), - ]), - "funcformat": String( - "COERCE_EXPLICIT_CALL", - ), - "funcname": Array([ - Object({ - "String": Object({ - "sval": String( - "insert_data", - ), - }), - }), - ]), - "location": Number( - 137, - ), - }), - }), - ), - stmt_location: 130, - stmt_len: Some( - 24, - ), - }, -] diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap deleted file mode 100644 index ae68493b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_publication_stmt.snap +++ /dev/null @@ -1,132 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreatePublicationStmt( - Object({ - "pubname": String( - "mypublication", - ), - "pubobjects": Array([ - Object({ - "PublicationObjSpec": Object({ - "pubobjtype": String( - "PUBLICATIONOBJ_TABLE", - ), - "pubtable": Object({ - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 44, - ), - "relname": String( - "users", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - }), - Object({ - "PublicationObjSpec": Object({ - "location": Number( - 51, - ), - "pubobjtype": String( - "PUBLICATIONOBJ_TABLE", - ), - "pubtable": Object({ - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 51, - ), - "relname": String( - "departments", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 62, - ), - }, - RawStmt { - stmt: CreatePublicationStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "insert", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "publish", - ), - "location": Number( - 122, - ), - }), - }), - ]), - "pubname": String( - "insert_only", - ), - "pubobjects": Array([ - Object({ - "PublicationObjSpec": Object({ - "pubobjtype": String( - "PUBLICATIONOBJ_TABLE", - ), - "pubtable": Object({ - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 105, - ), - "relname": String( - "mydata", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - }), - ]), - }), - ), - stmt_location: 63, - stmt_len: Some( - 78, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap deleted file mode 100644 index cd89a18c..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_range_stmt.snap +++ /dev/null @@ -1,93 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateRangeStmt( - Object({ - "params": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 49, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "float8", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "float8mi", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "subtype_diff", - ), - "location": Number( - 61, - ), - }), - }), - ]), - "typeName": Array([ - Object({ - "String": Object({ - "sval": String( - "floatrange", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 86, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap deleted file mode 100644 index a4ceb845..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_role_stmt.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateRoleStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Boolean": Object({ - "boolval": Bool( - true, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "canlogin", - ), - "location": Number( - 30, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "jw8s0F4", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "password", - ), - "location": Number( - 36, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "2005-01-01", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "validUntil", - ), - "location": Number( - 60, - ), - }), - }), - ]), - "role": String( - "miriam", - ), - "stmt_type": String( - "ROLESTMT_ROLE", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 84, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap deleted file mode 100644 index 3a164052..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_sequence_stmt.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateSeqStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 101, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "start", - ), - "location": Number( - 24, - ), - }), - }), - ]), - "sequence": Object({ - "inh": Bool( - true, - ), - "location": Number( - 17, - ), - "relname": String( - "serial", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap deleted file mode 100644 index f0153726..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_stats_stmt.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateStatsStmt( - Object({ - "defnames": Array([ - Object({ - "String": Object({ - "sval": String( - "s1", - ), - }), - }), - ]), - "exprs": Array([ - Object({ - "StatsElem": Object({ - "name": String( - "a", - ), - }), - }), - Object({ - "StatsElem": Object({ - "name": String( - "b", - ), - }), - }), - ]), - "relations": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 50, - ), - "relname": String( - "t1", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - "stat_types": Array([ - Object({ - "String": Object({ - "sval": String( - "dependencies", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 52, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap deleted file mode 100644 index 38267cbb..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_subscription_stmt.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateSubscriptionStmt( - Object({ - "conninfo": String( - "host=192.168.1.50 port=5432 user=foo dbname=foodb", - ), - "publication": Array([ - Object({ - "String": Object({ - "sval": String( - "mypublication", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "insert_only", - ), - }), - }), - ]), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 145, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap deleted file mode 100644 index b5a0c1c1..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_table_as_stmt.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateTableAsStmt( - Object({ - "into": Object({ - "onCommit": String( - "ONCOMMIT_NOOP", - ), - "rel": Object({ - "inh": Bool( - true, - ), - "location": Number( - 14, - ), - "relname": String( - "films2", - ), - "relpersistence": String( - "p", - ), - }), - }), - "objtype": String( - "OBJECT_TABLE", - ), - "query": Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 32, - ), - "relname": String( - "films", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - "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, - ), - }), - }), - }), - }), - ]), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 37, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap deleted file mode 100644 index 6a77570f..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_transform_stmt.snap +++ /dev/null @@ -1,154 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateTransformStmt( - Object({ - "fromsql": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 96, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 96, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "hstore_to_plpython", - ), - }), - }), - ]), - }), - "lang": String( - "plpythonu", - ), - "tosql": Object({ - "objargs": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 151, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "objfuncargs": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 151, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "internal", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - "objname": Array([ - Object({ - "String": Object({ - "sval": String( - "plpython_to_hstore", - ), - }), - }), - ]), - }), - "type_name": Object({ - "location": Number( - 22, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "hstore", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 162, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap deleted file mode 100644 index 3eae7b94..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_trigger_stmt.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateTrigStmt( - Object({ - "events": Number( - 16, - ), - "funcname": Array([ - Object({ - "String": Object({ - "sval": String( - "check_account_update", - ), - }), - }), - ]), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 50, - ), - "relname": String( - "accounts", - ), - "relpersistence": String( - "p", - ), - }), - "row": Bool( - true, - ), - "timing": Number( - 2, - ), - "trigname": String( - "check_update", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 120, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap deleted file mode 100644 index 1dc06d60..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_user_mapping_stmt.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateUserMappingStmt( - Object({ - "options": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "bob", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "user", - ), - "location": Number( - 48, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "secret", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "password", - ), - "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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap deleted file mode 100644 index e4335c42..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__create_view_stmt.snap +++ /dev/null @@ -1,189 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - "sval": Object({ - "sval": String( - "Hello World", - ), - }), - }), - }), - }), - }), - ]), - }), - }), - "view": Object({ - "inh": Bool( - true, - ), - "location": Number( - 13, - ), - "relname": String( - "vista", - ), - "relpersistence": String( - "p", - ), - }), - "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", - ), - }), - }), - ]), - "limitOption": String( - "LIMIT_OPTION_DEFAULT", - ), - "op": String( - "SETOP_NONE", - ), - "targetList": Array([ - Object({ - "ResTarget": Object({ - "location": Number( - 79, - ), - "val": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "A_Star": Object({}), - }), - ]), - "location": Number( - 79, - ), - }), - }), - }), - }), - ]), - "whereClause": Object({ - "A_Expr": Object({ - "kind": String( - "AEXPR_OP", - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "sval": String( - "kind", - ), - }), - }), - ]), - "location": Number( - 106, - ), - }), - }), - "location": Number( - 111, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - "=", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 113, - ), - "sval": Object({ - "sval": String( - "Comedy", - ), - }), - }), - }), - }), - }), - }), - }), - "view": Object({ - "inh": Bool( - true, - ), - "location": Number( - 56, - ), - "relname": String( - "comedies", - ), - "relpersistence": String( - "p", - ), - }), - "withCheckOption": String( - "NO_CHECK_OPTION", - ), - }), - ), - stmt_location: 43, - stmt_len: Some( - 78, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap deleted file mode 100644 index c6fdec6f..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__deallocate_stmt.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DeallocateStmt( - Object({}), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap deleted file mode 100644 index 884df132..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__declare_cursor_stmt.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DeclareCursorStmt( - Object({ - "options": Number( - 256, - ), - "portalname": String( - "curs2", - ), - "query": Object({ - "SelectStmt": Object({ - "fromClause": Array([ - Object({ - "RangeVar": Object({ - "inh": Bool( - true, - ), - "location": Number( - 44, - ), - "relname": String( - "tenk1", - ), - "relpersistence": String( - "p", - ), - }), - }), - ]), - "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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap deleted file mode 100644 index d452e2c6..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-2.snap +++ /dev/null @@ -1,270 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DefineStmt( - Object({ - "definition": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 37, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "box", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "box", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "area_equal_procedure", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "procedure", - ), - "location": Number( - 66, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "===", - ), - }), - }), - ]), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "commutator", - ), - "location": Number( - 104, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "!==", - ), - }), - }), - ]), - }), - }), - "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({ - "sval": String( - "area_restriction_procedure", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "area_join_procedure", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "join", - ), - "location": Number( - 188, - ), - }), - }), - Object({ - "DefElem": Object({ - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "hashes", - ), - "location": Number( - 220, - ), - }), - }), - Object({ - "DefElem": Object({ - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "merges", - ), - "location": Number( - 228, - ), - }), - }), - ]), - "defnames": Array([ - Object({ - "String": Object({ - "sval": String( - "===", - ), - }), - }), - ]), - "kind": String( - "OBJECT_OPERATOR", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 236, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap deleted file mode 100644 index e386f618..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt-3.snap +++ /dev/null @@ -1,148 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DefineStmt( - Object({ - "definition": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Integer": Object({ - "ival": Number( - 16, - ), - }), - }), - "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({ - "sval": String( - "my_box_in_function", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "my_box_out_function", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "float4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "element", - ), - "location": Number( - 114, - ), - }), - }), - ]), - "defnames": Array([ - Object({ - "String": Object({ - "sval": String( - "box", - ), - }), - }), - ]), - "kind": String( - "OBJECT_TYPE", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 132, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap deleted file mode 100644 index e4e1945e..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__define_stmt.snap +++ /dev/null @@ -1,151 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DefineStmt( - Object({ - "args": Array([ - Object({ - "List": Object({ - "items": Array([ - Object({ - "FunctionParameter": Object({ - "argType": Object({ - "location": Number( - 23, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "complex", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - "mode": String( - "FUNC_PARAM_DEFAULT", - ), - }), - }), - ]), - }), - }), - Object({ - "Integer": Object({}), - }), - ]), - "definition": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "TypeName": Object({ - "location": Number( - 46, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "complex_add", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "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({ - "sval": String( - "complex", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "stype", - ), - "location": Number( - 63, - ), - }), - }), - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": String( - "(0,0)", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "initcond", - ), - "location": Number( - 84, - ), - }), - }), - ]), - "defnames": Array([ - Object({ - "String": Object({ - "sval": String( - "sum", - ), - }), - }), - ]), - "kind": String( - "OBJECT_AGGREGATE", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 104, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap deleted file mode 100644 index a2237f2b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__discard_stmt.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap deleted file mode 100644 index 145c640b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__do_stmt.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DoStmt( - Object({ - "args": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "String": Object({ - "sval": 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": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "as", - ), - "location": Number( - 4, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 318, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap deleted file mode 100644 index 101432ef..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_database_stmt.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap deleted file mode 100644 index cc614c47..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_extension.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DropStmt( - DropStmt { - behavior: Restrict, - concurrent: false, - missing_ok: false, - remove_type: Extension, - }, - ), - stmt_location: 0, - stmt_len: Some( - 21, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap deleted file mode 100644 index 90576a96..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_index.snap +++ /dev/null @@ -1,204 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap deleted file mode 100644 index 858a1ec0..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_owned_stmt.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap deleted file mode 100644 index f46949ec..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_role_set_stmt.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap deleted file mode 100644 index 63680ca1..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_subscription_stmt.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DropSubscriptionStmt( - Object({ - "behavior": String( - "DROP_RESTRICT", - ), - "subname": String( - "mysub", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 24, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap deleted file mode 100644 index 60aab2c7..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__drop_user_mapping_stmt.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DropUserMappingStmt( - Object({ - "missing_ok": Bool( - true, - ), - "servername": String( - "foo", - ), - "user": Object({ - "location": Number( - 32, - ), - "rolename": String( - "bob", - ), - "roletype": String( - "ROLESPEC_CSTRING", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 46, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__error_paths.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__error_paths.snap deleted file mode 100644 index 67aafd35..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__error_paths.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -PgParseError( - Some( - "syntax error at or near \"lsakdjf\"", - ), -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap deleted file mode 100644 index 00b6bd9c..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__execute_stmt.snap +++ /dev/null @@ -1,71 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: ExecuteStmt( - Object({ - "name": String( - "fooplan", - ), - "params": Array([ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 17, - ), - }), - }), - Object({ - "A_Const": Object({ - "location": Number( - 20, - ), - "sval": Object({ - "sval": String( - "Hunter Valley", - ), - }), - }), - }), - Object({ - "A_Const": Object({ - "location": Number( - 37, - ), - "sval": Object({ - "sval": String( - "t", - ), - }), - }), - }), - Object({ - "A_Const": Object({ - "fval": Object({ - "fval": String( - "200.00", - ), - }), - "location": Number( - 42, - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap deleted file mode 100644 index e240f067..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__explain_stmt.snap +++ /dev/null @@ -1,184 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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", - ), - }), - }), - ]), - "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": String( - "AEXPR_OP", - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "sval": String( - "a", - ), - }), - }), - ]), - "location": Number( - 41, - ), - }), - }), - "location": Number( - 43, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - "=", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 45, - ), - }), - }), - }), - }), - Object({ - "A_Expr": Object({ - "kind": String( - "AEXPR_OP", - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "sval": String( - "b", - ), - }), - }), - ]), - "location": Number( - 53, - ), - }), - }), - "location": Number( - 55, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - "=", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "ival": Object({}), - "location": Number( - 57, - ), - }), - }), - }), - }), - ]), - "boolop": String( - "AND_EXPR", - ), - "location": Number( - 48, - ), - }), - }), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 59, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap deleted file mode 100644 index 4343c556..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__fetch_stmt.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: FetchStmt( - Object({ - "direction": String( - "FETCH_FORWARD", - ), - "howMany": Number( - 5, - ), - "portalname": String( - "foo", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 25, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap deleted file mode 100644 index 8e3198aa..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__import_foreign_schema_stmt.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap deleted file mode 100644 index f702d519..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__json_index_operator.snap +++ /dev/null @@ -1,101 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "foo", - ), - }), - }), - ]), - "location": Number( - 66, - ), - }), - }), - "location": Number( - 69, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - "->>", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "location": Number( - 72, - ), - "sval": Object({ - "sval": String( - "bar", - ), - }), - }), - }), - }), - }), - ), - indexcolname: None, - collation: None, - opclass: [], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "a", - inh: true, - relpersistence: "p", - alias: None, - location: 60, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap deleted file mode 100644 index a23cc032..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__listen_stmt.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: ListenStmt( - Object({ - "conditionname": String( - "virtual", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 15, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap deleted file mode 100644 index f12115a7..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__load_stmt.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: LoadStmt( - Object({ - "filename": String( - "filename", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 16, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap deleted file mode 100644 index 24fb6075..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__lock_stmt.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__migration.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__migration.snap deleted file mode 100644 index 57dfde78..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__migration.snap +++ /dev/null @@ -1,132 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 52, - }, - 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({ - "sval": String( - "varchar_pattern_ops", - ), - }), - }), - ], - ordering: Default, - nulls_ordering: Default, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 125, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap deleted file mode 100644 index e213a483..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__notify_stmt.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap deleted file mode 100644 index 09255912..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_collation_stmt.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap deleted file mode 100644 index 2bbec460..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_constraint_regression.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "table", - inh: true, - relpersistence: "p", - alias: None, - location: 13, - }, - objtype: 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 { - catalogname: None, - schemaname: None, - relname: "table", - inh: true, - relpersistence: "p", - alias: None, - location: 96, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 82, - stmt_len: Some( - 66, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap deleted file mode 100644 index 426705ea..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_domain_stmt.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res - ---- -Ok( - [ - RawStmt { - stmt: AlterDomainStmt( - AlterDomainStmt { - behavior: Restrict, - name: None, - subtype: "O", - typename: Array([ - Object({ - "String": Object({ - "sval": String( - "zipcode", - ), - }), - }), - ]), - def: None, - }, - ), - stmt_location: 0, - stmt_len: Some( - 33, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap deleted file mode 100644 index c9f7d74b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_alter_table_set_list.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: SetRelOptions, - name: None, - def: Some( - List( - Object({ - "items": Array([ - Object({ - "DefElem": Object({ - "arg": Object({ - "Float": Object({ - "fval": String( - "0.0", - ), - }), - }), - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "autovacuum_vacuum_scale_factor", - ), - "location": Number( - 28, - ), - }), - }), - ]), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 12, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 65, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_attach_table_partition.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_attach_table_partition.snap deleted file mode 100644 index c98f39e9..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_attach_table_partition.snap +++ /dev/null @@ -1,96 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res - ---- -Ok( - [ - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: AttachPartition, - name: None, - def: Some( - PartitionCmd( - Object({ - "bound": Object({ - "location": Number( - 78, - ), - "lowerdatums": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 84, - ), - "sval": Object({ - "sval": String( - "2008-02-01", - ), - }), - }), - }), - ]), - "strategy": String( - "r", - ), - "upperdatums": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 102, - ), - "sval": Object({ - "sval": String( - "2008-03-01", - ), - }), - }), - }), - ]), - }), - "name": Object({ - "inh": Bool( - true, - ), - "location": Number( - 42, - ), - "relname": String( - "measurement_y2008m02", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "measurement", - inh: true, - relpersistence: "p", - alias: None, - location: 13, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 116, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap deleted file mode 100644 index c1840229..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_schema_stmt.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateSchemaStmt( - Object({ - "schemaname": String( - "schema_name", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 25, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap deleted file mode 100644 index fc2227ba..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_partition.snap +++ /dev/null @@ -1,91 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "location": Number( - 75, - ), - "lowerdatums": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 81, - ), - "sval": Object({ - "sval": String( - "2006-02-01", - ), - }), - }), - }), - ]), - "strategy": String( - "r", - ), - "upperdatums": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 99, - ), - "sval": Object({ - "sval": 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap deleted file mode 100644 index 48fcd685..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_create_table_regression.snap +++ /dev/null @@ -1,162 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "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: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "int4", - }, - }, - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 45, - }, - constraints: [], - is_local: true, - location: 43, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "c", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "int4", - }, - }, - ], - 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({ - "sval": String( - "a", - ), - }), - }), - Object({ - "String": Object({ - "sval": 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap deleted file mode 100644 index 853e318d..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt-2.snap +++ /dev/null @@ -1,79 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "account_age", - ), - }), - }), - ]), - "location": Number( - 31, - ), - }), - }), - "location": Number( - 43, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - ">", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 10, - ), - }), - "location": Number( - 45, - ), - }), - }), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 47, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap deleted file mode 100644 index 44d8bb0f..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt_2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt_2.snap deleted file mode 100644 index 853e318d..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_delete_stmt_2.snap +++ /dev/null @@ -1,79 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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({ - "sval": String( - "account_age", - ), - }), - }), - ]), - "location": Number( - 31, - ), - }), - }), - "location": Number( - 43, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - ">", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 10, - ), - }), - "location": Number( - 45, - ), - }), - }), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 47, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_detach_table_partition.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_detach_table_partition.snap deleted file mode 100644 index a1c60404..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_detach_table_partition.snap +++ /dev/null @@ -1,60 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res - ---- -Ok( - [ - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: DetachPartition, - name: None, - def: Some( - PartitionCmd( - Object({ - "name": Object({ - "inh": Bool( - true, - ), - "location": Number( - 46, - ), - "relname": String( - "measurement_y2006m02", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "measurement", - inh: true, - relpersistence: "p", - alias: None, - location: 13, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 66, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap deleted file mode 100644 index 53893e46..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_func_call.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ColumnDefault, - name: Some( - "value", - ), - def: Some( - FuncCall( - Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "boolval": Object({}), - "location": Number( - 59, - ), - }), - }), - ]), - "funcformat": String( - "COERCE_EXPLICIT_CALL", - ), - "funcname": Array([ - Object({ - "String": Object({ - "sval": String( - "to_json", - ), - }), - }), - ]), - "location": Number( - 51, - ), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "foobar", - inh: true, - relpersistence: "p", - alias: None, - location: 13, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 65, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap deleted file mode 100644 index 8a625df2..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_generated_column.snap +++ /dev/null @@ -1,128 +0,0 @@ ---- -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: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "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({ - "sval": 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, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 93, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap deleted file mode 100644 index c11cbbfd..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_inh.snap +++ /dev/null @@ -1,106 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: Some( - "public", - ), - relname: "tasks", - inh: false, - relpersistence: "p", - alias: None, - location: 18, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 193, - ), - }, - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ValidateConstraint, - name: Some( - "tasks_fk", - ), - def: None, - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: Some( - "public", - ), - relname: "tasks", - inh: true, - relpersistence: "p", - alias: None, - location: 208, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 194, - stmt_len: Some( - 55, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap deleted file mode 100644 index 05f74a78..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_replica_identity_stmt.snap +++ /dev/null @@ -1,48 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "aa", - inh: true, - relpersistence: "p", - alias: None, - location: 12, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 36, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap deleted file mode 100644 index ef83a524..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt-2.snap +++ /dev/null @@ -1,158 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -[ - 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 { - 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 { - 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, - ), - }, -] diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap deleted file mode 100644 index 8d840bcc..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt.snap +++ /dev/null @@ -1,158 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -[ - 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 { - 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 { - 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, - ), - }, -] diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt_2.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt_2.snap deleted file mode 100644 index ef83a524..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_set_operations_stmt_2.snap +++ /dev/null @@ -1,158 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -[ - 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 { - 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 { - 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, - ), - }, -] diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap deleted file mode 100644 index 475ca534..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index.snap +++ /dev/null @@ -1,55 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 33, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap deleted file mode 100644 index 1ff1348e..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_index_concurrently.snap +++ /dev/null @@ -1,55 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 46, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap deleted file mode 100644 index 75b1d2d8..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_create_unique_index_safe.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - catalogname: None, - schemaname: None, - relname: "legacy_questiongrouppg", - inh: true, - relpersistence: "p", - alias: None, - location: 13, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 181, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap deleted file mode 100644 index 60b4810c..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json.snap +++ /dev/null @@ -1,139 +0,0 @@ ---- -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({ - "sval": 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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "bool", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - }), - "subtype": String( - "AT_AddColumn", - ), - }), - }), - ]), - "objtype": String( - "OBJECT_TABLE", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 12, - ), - "relname": String( - "table_c", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - "stmt_len": Number( - 92, - ), - }), - ]), - "version": Number( - 160001, - ), - }), -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json_works.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json_works.snap deleted file mode 100644 index 60b4810c..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parse_sql_query_json_works.snap +++ /dev/null @@ -1,139 +0,0 @@ ---- -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({ - "sval": 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({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "bool", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - }), - "subtype": String( - "AT_AddColumn", - ), - }), - }), - ]), - "objtype": String( - "OBJECT_TABLE", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 12, - ), - "relname": String( - "table_c", - ), - "relpersistence": String( - "p", - ), - }), - }), - }), - "stmt_len": Number( - 92, - ), - }), - ]), - "version": Number( - 160001, - ), - }), -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap deleted file mode 100644 index 271f9f53..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_copy_stmt.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CopyStmt( - Object({ - "filename": String( - "/usr1/proj/bray/sql/country_data", - ), - "is_from": Bool( - true, - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 5, - ), - "relname": String( - "country", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 52, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap deleted file mode 100644 index b8149f63..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table.snap +++ /dev/null @@ -1,560 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - }, - table_elts: [ - ColumnDef( - ColumnDef { - colname: Some( - "id", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "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, - }, - ), - Constraint( - Constraint { - conname: None, - contype: Primary, - location: Some( - 57, - ), - 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: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "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, - }, - ), - ], - is_local: true, - location: 73, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "modified", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "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, - }, - ), - ], - is_local: true, - location: 121, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "mongo_id", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "varchar", - }, - }, - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 255, - ), - }), - "location": Number( - 189, - ), - }), - }), - ], - 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, - }, - ), - 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: [ - QualifiedName { - string: PGString { - sval: "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, - }, - ), - ], - is_local: true, - location: 214, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "metadata", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "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, - }, - ), - ], - is_local: true, - location: 246, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "kind", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "varchar", - }, - }, - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [ - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 255, - ), - }), - "location": Number( - 291, - ), - }), - }), - ], - 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, - }, - ), - ColumnDef( - ColumnDef { - colname: Some( - "age", - ), - type_name: TypeName { - names: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "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( - 323, - ), - 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: [ - QualifiedName { - string: PGString { - sval: "pg_catalog", - }, - }, - QualifiedName { - string: PGString { - sval: "int4", - }, - }, - ], - type_oid: None, - setof: false, - pct_type: false, - typmods: [], - typemod: -1, - array_bounds: [], - location: 348, - }, - 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: 336, - }, - ), - ], - 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, - }, - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap deleted file mode 100644 index 8f1313f2..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_space_stmt.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateTableSpaceStmt( - Object({ - "location": String( - "/data/dbs", - ), - "tablespacename": String( - "dbspace", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 46, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_using_like.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_using_like.snap deleted file mode 100644 index b2a72315..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_create_table_using_like.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: CreateStmt( - CreateStmt { - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "core_bar", - inh: true, - relpersistence: "p", - alias: None, - location: 13, - }, - table_elts: [ - TableLikeClause( - TableLikeClause { - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "core_foo", - inh: true, - relpersistence: "p", - alias: None, - location: 28, - }, - options: 12, - }, - ), - ], - 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( - 78, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap deleted file mode 100644 index 9a7e6e6d..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_drop_table_space_stmt.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: DropTableSpaceStmt( - Object({ - "tablespacename": String( - "dbspace", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap deleted file mode 100644 index a65327ff..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_role.snap +++ /dev/null @@ -1,48 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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": String( - "ROLESPEC_CSTRING", - ), - }), - }), - ]), - "is_grant": Bool( - true, - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 19, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap deleted file mode 100644 index 5c9a4255..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_grant_stmt.snap +++ /dev/null @@ -1,69 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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", - ), - }), - }), - ]), - "objtype": String( - "OBJECT_TABLE", - ), - "privileges": Array([ - Object({ - "AccessPriv": Object({ - "priv_name": String( - "insert", - ), - }), - }), - ]), - "targtype": String( - "ACL_TARGET_OBJECT", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 31, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap deleted file mode 100644 index cf9e39a0..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_insert_stmt.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: InsertStmt( - Object({ - "override": String( - "OVERRIDING_NOT_SET", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "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({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 31, - ), - }), - }), - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 2, - ), - }), - "location": Number( - 34, - ), - }), - }), - Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 3, - ), - }), - "location": Number( - 37, - ), - }), - }), - ]), - }), - }), - ]), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap deleted file mode 100644 index a00d09a7..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_update_stmt.snap +++ /dev/null @@ -1,103 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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( - 22, - ), - "name": String( - "foo", - ), - "val": Object({ - "A_Const": Object({ - "location": Number( - 28, - ), - "sval": Object({ - "sval": String( - "bar", - ), - }), - }), - }), - }), - }), - ]), - "whereClause": Object({ - "A_Expr": Object({ - "kind": String( - "AEXPR_OP", - ), - "lexpr": Object({ - "ColumnRef": Object({ - "fields": Array([ - Object({ - "String": Object({ - "sval": String( - "buzz", - ), - }), - }), - ]), - "location": Number( - 40, - ), - }), - }), - "location": Number( - 45, - ), - "name": Array([ - Object({ - "String": Object({ - "sval": String( - ">", - ), - }), - }), - ]), - "rexpr": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 10, - ), - }), - "location": Number( - 47, - ), - }), - }), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 49, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap deleted file mode 100644 index 93a3dfc2..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_set_stmt.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: VariableSetStmt( - Object({ - "args": Array([ - Object({ - "A_Const": Object({ - "location": Number( - 25, - ), - "sval": Object({ - "sval": String( - "1", - ), - }), - }), - }), - ]), - "kind": String( - "VAR_SET_VALUE", - ), - "name": String( - "my.vars.id", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 28, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap deleted file mode 100644 index 4f70b669..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__parsing_variable_show_stmt.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: VariableShowStmt( - Object({ - "name": String( - "name", - ), - }), - ), - stmt_location: 0, - stmt_len: None, - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap deleted file mode 100644 index aef9da06..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__prepare_stmt.snap +++ /dev/null @@ -1,192 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: PrepareStmt( - Object({ - "argtypes": Array([ - Object({ - "TypeName": Object({ - "location": Number( - 18, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "int4", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 23, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "text", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 29, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "bool", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - Object({ - "TypeName": Object({ - "location": Number( - 35, - ), - "names": Array([ - Object({ - "String": Object({ - "sval": String( - "pg_catalog", - ), - }), - }), - Object({ - "String": Object({ - "sval": String( - "numeric", - ), - }), - }), - ]), - "typemod": Number( - -1, - ), - }), - }), - ]), - "name": String( - "fooplan", - ), - "query": Object({ - "InsertStmt": Object({ - "override": String( - "OVERRIDING_NOT_SET", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "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( - 82, - ), - "number": Number( - 3, - ), - }), - }), - Object({ - "ParamRef": Object({ - "location": Number( - 86, - ), - "number": Number( - 4, - ), - }), - }), - ]), - }), - }), - ]), - }), - }), - }), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 89, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap deleted file mode 100644 index 49fd7ee5..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__reassign_owned_stmt.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: ReassignOwnedStmt( - Object({ - "newrole": Object({ - "location": Number( - 31, - ), - "rolename": String( - "new_role", - ), - "roletype": String( - "ROLESPEC_CSTRING", - ), - }), - "roles": Array([ - Object({ - "RoleSpec": Object({ - "location": Number( - 19, - ), - "rolename": String( - "old_role", - ), - "roletype": String( - "ROLESPEC_CSTRING", - ), - }), - }), - ]), - }), - ), - stmt_location: 0, - stmt_len: Some( - 39, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap deleted file mode 100644 index b547d0bb..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__refresh_material_view_stmt.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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 { - stmt: RefreshMatViewStmt( - Object({ - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 68, - ), - "relname": String( - "annual_statistics_basis", - ), - "relpersistence": String( - "p", - ), - }), - "skipData": Bool( - true, - ), - }), - ), - stmt_location: 41, - stmt_len: Some( - 63, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap deleted file mode 100644 index 59c79b28..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__regression_update_table.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: AlterTableStmt( - AlterTableStmt { - cmds: [ - AlterTableCmd( - AlterTableCmd { - subtype: ColumnDefault, - name: Some( - "column_name", - ), - def: Some( - Constant( - Object({ - "boolval": Object({}), - "location": Number( - 73, - ), - }), - ), - ), - behavior: Restrict, - missing_ok: false, - }, - ), - ], - relation: RangeVar { - catalogname: None, - schemaname: None, - relname: "table_name", - inh: true, - relpersistence: "p", - alias: None, - location: 21, - }, - objtype: Table, - missing_ok: false, - }, - ), - stmt_location: 0, - stmt_len: Some( - 78, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap deleted file mode 100644 index 41321ce3..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__reindex_stmt.snap +++ /dev/null @@ -1,94 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: ReindexStmt( - Object({ - "kind": String( - "REINDEX_OBJECT_INDEX", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 15, - ), - "relname": String( - "my_index", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - stmt_location: 0, - stmt_len: Some( - 23, - ), - }, - RawStmt { - stmt: ReindexStmt( - Object({ - "kind": String( - "REINDEX_OBJECT_TABLE", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 39, - ), - "relname": String( - "table_name", - ), - "relpersistence": String( - "p", - ), - }), - }), - ), - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap deleted file mode 100644 index f442ba2c..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__rule_stmt.snap +++ /dev/null @@ -1,131 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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", - ), - }), - }), - ]), - "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": String( - "CMD_SELECT", - ), - "instead": Bool( - true, - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 43, - ), - "relname": String( - "t1", - ), - "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", - ), - }), - }), - ]), - "event": String( - "CMD_UPDATE", - ), - "relation": Object({ - "inh": Bool( - true, - ), - "location": Number( - 126, - ), - "relname": String( - "mytable", - ), - "relpersistence": String( - "p", - ), - }), - "rulename": String( - "notify_me", - ), - }), - ), - stmt_location: 86, - stmt_len: Some( - 70, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap deleted file mode 100644 index b9874c29..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__security_label_stmt.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: SecLabelStmt( - Object({ - "label": String( - "system_u:object_r:sepgsql_table_t:s0", - ), - "object": Object({ - "List": Object({ - "items": Array([ - Object({ - "String": Object({ - "sval": String( - "mytable", - ), - }), - }), - ]), - }), - }), - "objtype": String( - "OBJECT_TABLE", - ), - "provider": String( - "selinux", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 86, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap deleted file mode 100644 index b586356f..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__select_one.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 7, - ), - "val": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 7, - ), - }), - }), - }), - }), - ], - ), - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap deleted file mode 100644 index 82755de8..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__select_string_literal.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - "sval": Object({ - "sval": 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap deleted file mode 100644 index d2e42b24..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__set_constraints.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap deleted file mode 100644 index 4bf5ef3b..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_indent.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 10, - ), - "val": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 10, - ), - }), - }), - }), - }), - ], - ), - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap deleted file mode 100644 index cd665cc5..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__span_with_new_line_and_indent.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: SelectStmt( - SelectStmt { - distinct_clause: None, - into_clause: None, - target_list: Some( - [ - Object({ - "ResTarget": Object({ - "location": Number( - 12, - ), - "val": Object({ - "A_Const": Object({ - "ival": Object({ - "ival": Number( - 1, - ), - }), - "location": Number( - 12, - ), - }), - }), - }), - }), - ], - ), - 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/crates/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap deleted file mode 100644 index 3a732ec0..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__truncate_stmt.snap +++ /dev/null @@ -1,105 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - 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( - 30, - ), - "relname": String( - "bar", - ), - "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, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap deleted file mode 100644 index 5466da79..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__unlisten_stmt.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: UnlistenStmt( - Object({ - "conditionname": String( - "virtual", - ), - }), - ), - stmt_location: 0, - stmt_len: Some( - 17, - ), - }, - ], -) diff --git a/crates/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap b/crates/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap deleted file mode 100644 index 5ef53d51..00000000 --- a/crates/parser/src/snapshots/squawk_parser__parse__tests__vacuum_stmt.snap +++ /dev/null @@ -1,69 +0,0 @@ ---- -source: parser/src/parse.rs -expression: res ---- -Ok( - [ - RawStmt { - stmt: VacuumStmt( - Object({ - "is_vacuumcmd": Bool( - true, - ), - "options": Array([ - Object({ - "DefElem": Object({ - "defaction": String( - "DEFELEM_UNSPEC", - ), - "defname": String( - "verbose", - ), - "location": Number( - 9, - ), - }), - }), - Object({ - "DefElem": Object({ - "defaction": String( - "DEFELEM_UNSPEC", - ), - "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, - ), - }, - ], -)