ibm_db 5.6.1-arm64-darwin-24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/CHANGES +299 -0
 - data/LICENSE +55 -0
 - data/MANIFEST +14 -0
 - data/ParameterizedQueries README +39 -0
 - data/README +210 -0
 - data/ext/Makefile +270 -0
 - data/ext/Makefile.nt32 +181 -0
 - data/ext/Makefile.nt32.191 +212 -0
 - data/ext/extconf.rb +320 -0
 - data/ext/gil_release_version.h +3 -0
 - data/ext/ibm_db.bundle +0 -0
 - data/ext/ibm_db.c +11865 -0
 - data/ext/ibm_db.o +0 -0
 - data/ext/mkmf.log +98 -0
 - data/ext/ruby_ibm_db.h +241 -0
 - data/ext/ruby_ibm_db_cli.c +867 -0
 - data/ext/ruby_ibm_db_cli.h +508 -0
 - data/ext/ruby_ibm_db_cli.o +0 -0
 - data/ext/unicode_support_version.h +3 -0
 - data/init.rb +42 -0
 - data/lib/IBM_DB.rb +27 -0
 - data/lib/active_record/connection_adapters/ibm_db_adapter.rb +4407 -0
 - data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1965 -0
 - data/lib/active_record/connection_adapters/ibmdb_adapter.rb +5 -0
 - data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
 - data/lib/ibm_db.bundle +0 -0
 - data/test/active_record/connection_adapters/fake_adapter.rb +52 -0
 - data/test/activejob/destroy_association_async_test.rb +305 -0
 - data/test/activejob/destroy_async_job_not_present_test.rb +31 -0
 - data/test/activejob/helper.rb +15 -0
 - data/test/assets/example.log +1 -0
 - data/test/assets/flowers.jpg +0 -0
 - data/test/assets/schema_dump_5_1.yml +345 -0
 - data/test/assets/test.txt +1 -0
 - data/test/cases/adapter_prevent_writes_test.rb +334 -0
 - data/test/cases/adapter_test.rb +565 -0
 - data/test/cases/adapters/mysql2/active_schema_test.rb +203 -0
 - data/test/cases/adapters/mysql2/auto_increment_test.rb +34 -0
 - data/test/cases/adapters/mysql2/bind_parameter_test.rb +52 -0
 - data/test/cases/adapters/mysql2/boolean_test.rb +102 -0
 - data/test/cases/adapters/mysql2/case_sensitivity_test.rb +65 -0
 - data/test/cases/adapters/mysql2/charset_collation_test.rb +57 -0
 - data/test/cases/adapters/mysql2/connection_test.rb +208 -0
 - data/test/cases/adapters/mysql2/count_deleted_rows_with_lock_test.rb +28 -0
 - data/test/cases/adapters/mysql2/datetime_precision_quoting_test.rb +49 -0
 - data/test/cases/adapters/mysql2/enum_test.rb +47 -0
 - data/test/cases/adapters/mysql2/explain_test.rb +23 -0
 - data/test/cases/adapters/mysql2/json_test.rb +24 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_prevent_writes_test.rb +208 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_test.rb +238 -0
 - data/test/cases/adapters/mysql2/nested_deadlock_test.rb +75 -0
 - data/test/cases/adapters/mysql2/optimizer_hints_test.rb +69 -0
 - data/test/cases/adapters/mysql2/reserved_word_test.rb +152 -0
 - data/test/cases/adapters/mysql2/schema_migrations_test.rb +64 -0
 - data/test/cases/adapters/mysql2/schema_test.rb +128 -0
 - data/test/cases/adapters/mysql2/set_test.rb +32 -0
 - data/test/cases/adapters/mysql2/sp_test.rb +38 -0
 - data/test/cases/adapters/mysql2/sql_types_test.rb +16 -0
 - data/test/cases/adapters/mysql2/table_options_test.rb +125 -0
 - data/test/cases/adapters/mysql2/transaction_test.rb +151 -0
 - data/test/cases/adapters/mysql2/unsigned_type_test.rb +68 -0
 - data/test/cases/adapters/mysql2/virtual_column_test.rb +66 -0
 - data/test/cases/adapters/postgresql/active_schema_test.rb +113 -0
 - data/test/cases/adapters/postgresql/array_test.rb +394 -0
 - data/test/cases/adapters/postgresql/bit_string_test.rb +84 -0
 - data/test/cases/adapters/postgresql/bytea_test.rb +135 -0
 - data/test/cases/adapters/postgresql/case_insensitive_test.rb +27 -0
 - data/test/cases/adapters/postgresql/change_schema_test.rb +40 -0
 - data/test/cases/adapters/postgresql/cidr_test.rb +27 -0
 - data/test/cases/adapters/postgresql/citext_test.rb +78 -0
 - data/test/cases/adapters/postgresql/collation_test.rb +55 -0
 - data/test/cases/adapters/postgresql/composite_test.rb +134 -0
 - data/test/cases/adapters/postgresql/connection_test.rb +245 -0
 - data/test/cases/adapters/postgresql/create_unlogged_tables_test.rb +74 -0
 - data/test/cases/adapters/postgresql/datatype_test.rb +89 -0
 - data/test/cases/adapters/postgresql/date_test.rb +42 -0
 - data/test/cases/adapters/postgresql/domain_test.rb +49 -0
 - data/test/cases/adapters/postgresql/enum_test.rb +93 -0
 - data/test/cases/adapters/postgresql/explain_test.rb +22 -0
 - data/test/cases/adapters/postgresql/extension_migration_test.rb +64 -0
 - data/test/cases/adapters/postgresql/foreign_table_test.rb +109 -0
 - data/test/cases/adapters/postgresql/full_text_test.rb +46 -0
 - data/test/cases/adapters/postgresql/geometric_test.rb +372 -0
 - data/test/cases/adapters/postgresql/hstore_test.rb +390 -0
 - data/test/cases/adapters/postgresql/infinity_test.rb +108 -0
 - data/test/cases/adapters/postgresql/integer_test.rb +27 -0
 - data/test/cases/adapters/postgresql/interval_test.rb +99 -0
 - data/test/cases/adapters/postgresql/json_test.rb +52 -0
 - data/test/cases/adapters/postgresql/ltree_test.rb +51 -0
 - data/test/cases/adapters/postgresql/money_test.rb +127 -0
 - data/test/cases/adapters/postgresql/network_test.rb +102 -0
 - data/test/cases/adapters/postgresql/numbers_test.rb +51 -0
 - data/test/cases/adapters/postgresql/optimizer_hints_test.rb +71 -0
 - data/test/cases/adapters/postgresql/partitions_test.rb +22 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_prevent_writes_test.rb +205 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +447 -0
 - data/test/cases/adapters/postgresql/prepared_statements_disabled_test.rb +27 -0
 - data/test/cases/adapters/postgresql/prepared_statements_test.rb +22 -0
 - data/test/cases/adapters/postgresql/quoting_test.rb +50 -0
 - data/test/cases/adapters/postgresql/range_test.rb +457 -0
 - data/test/cases/adapters/postgresql/referential_integrity_test.rb +112 -0
 - data/test/cases/adapters/postgresql/rename_table_test.rb +35 -0
 - data/test/cases/adapters/postgresql/schema_authorization_test.rb +110 -0
 - data/test/cases/adapters/postgresql/schema_test.rb +713 -0
 - data/test/cases/adapters/postgresql/serial_test.rb +156 -0
 - data/test/cases/adapters/postgresql/statement_pool_test.rb +61 -0
 - data/test/cases/adapters/postgresql/timestamp_test.rb +92 -0
 - data/test/cases/adapters/postgresql/transaction_nested_test.rb +114 -0
 - data/test/cases/adapters/postgresql/transaction_test.rb +189 -0
 - data/test/cases/adapters/postgresql/type_lookup_test.rb +35 -0
 - data/test/cases/adapters/postgresql/utils_test.rb +64 -0
 - data/test/cases/adapters/postgresql/uuid_test.rb +411 -0
 - data/test/cases/adapters/postgresql/xml_test.rb +50 -0
 - data/test/cases/adapters/sqlite3/collation_test.rb +64 -0
 - data/test/cases/adapters/sqlite3/copy_table_test.rb +101 -0
 - data/test/cases/adapters/sqlite3/explain_test.rb +23 -0
 - data/test/cases/adapters/sqlite3/json_test.rb +29 -0
 - data/test/cases/adapters/sqlite3/quoting_test.rb +79 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_prevent_writes_test.rb +186 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +628 -0
 - data/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb +24 -0
 - data/test/cases/adapters/sqlite3/statement_pool_test.rb +21 -0
 - data/test/cases/adapters/sqlite3/transaction_test.rb +123 -0
 - data/test/cases/aggregations_test.rb +170 -0
 - data/test/cases/annotate_test.rb +46 -0
 - data/test/cases/ar_schema_test.rb +213 -0
 - data/test/cases/arel/attributes/attribute_test.rb +1145 -0
 - data/test/cases/arel/attributes/math_test.rb +83 -0
 - data/test/cases/arel/attributes_test.rb +27 -0
 - data/test/cases/arel/collectors/bind_test.rb +40 -0
 - data/test/cases/arel/collectors/composite_test.rb +47 -0
 - data/test/cases/arel/collectors/sql_string_test.rb +41 -0
 - data/test/cases/arel/collectors/substitute_bind_collector_test.rb +48 -0
 - data/test/cases/arel/crud_test.rb +65 -0
 - data/test/cases/arel/delete_manager_test.rb +53 -0
 - data/test/cases/arel/factory_methods_test.rb +46 -0
 - data/test/cases/arel/helper.rb +45 -0
 - data/test/cases/arel/insert_manager_test.rb +241 -0
 - data/test/cases/arel/nodes/and_test.rb +30 -0
 - data/test/cases/arel/nodes/as_test.rb +36 -0
 - data/test/cases/arel/nodes/ascending_test.rb +46 -0
 - data/test/cases/arel/nodes/bin_test.rb +35 -0
 - data/test/cases/arel/nodes/binary_test.rb +29 -0
 - data/test/cases/arel/nodes/bind_param_test.rb +22 -0
 - data/test/cases/arel/nodes/case_test.rb +96 -0
 - data/test/cases/arel/nodes/casted_test.rb +18 -0
 - data/test/cases/arel/nodes/comment_test.rb +22 -0
 - data/test/cases/arel/nodes/count_test.rb +35 -0
 - data/test/cases/arel/nodes/delete_statement_test.rb +36 -0
 - data/test/cases/arel/nodes/descending_test.rb +46 -0
 - data/test/cases/arel/nodes/distinct_test.rb +21 -0
 - data/test/cases/arel/nodes/equality_test.rb +62 -0
 - data/test/cases/arel/nodes/extract_test.rb +43 -0
 - data/test/cases/arel/nodes/false_test.rb +21 -0
 - data/test/cases/arel/nodes/grouping_test.rb +26 -0
 - data/test/cases/arel/nodes/infix_operation_test.rb +42 -0
 - data/test/cases/arel/nodes/insert_statement_test.rb +44 -0
 - data/test/cases/arel/nodes/named_function_test.rb +48 -0
 - data/test/cases/arel/nodes/node_test.rb +22 -0
 - data/test/cases/arel/nodes/not_test.rb +31 -0
 - data/test/cases/arel/nodes/or_test.rb +36 -0
 - data/test/cases/arel/nodes/over_test.rb +69 -0
 - data/test/cases/arel/nodes/select_core_test.rb +79 -0
 - data/test/cases/arel/nodes/select_statement_test.rb +51 -0
 - data/test/cases/arel/nodes/sql_literal_test.rb +75 -0
 - data/test/cases/arel/nodes/sum_test.rb +35 -0
 - data/test/cases/arel/nodes/table_alias_test.rb +29 -0
 - data/test/cases/arel/nodes/true_test.rb +21 -0
 - data/test/cases/arel/nodes/unary_operation_test.rb +41 -0
 - data/test/cases/arel/nodes/update_statement_test.rb +60 -0
 - data/test/cases/arel/nodes/window_test.rb +81 -0
 - data/test/cases/arel/nodes_test.rb +34 -0
 - data/test/cases/arel/select_manager_test.rb +1238 -0
 - data/test/cases/arel/support/fake_record.rb +135 -0
 - data/test/cases/arel/table_test.rb +216 -0
 - data/test/cases/arel/update_manager_test.rb +126 -0
 - data/test/cases/arel/visitors/dispatch_contamination_test.rb +78 -0
 - data/test/cases/arel/visitors/dot_test.rb +90 -0
 - data/test/cases/arel/visitors/mysql_test.rb +157 -0
 - data/test/cases/arel/visitors/postgres_test.rb +366 -0
 - data/test/cases/arel/visitors/sqlite_test.rb +75 -0
 - data/test/cases/arel/visitors/to_sql_test.rb +750 -0
 - data/test/cases/associations/association_scope_test.rb +16 -0
 - data/test/cases/associations/belongs_to_associations_test.rb +1493 -0
 - data/test/cases/associations/bidirectional_destroy_dependencies_test.rb +43 -0
 - data/test/cases/associations/callbacks_test.rb +208 -0
 - data/test/cases/associations/cascaded_eager_loading_test.rb +245 -0
 - data/test/cases/associations/eager_load_includes_full_sti_class_test.rb +156 -0
 - data/test/cases/associations/eager_load_nested_include_test.rb +127 -0
 - data/test/cases/associations/eager_singularization_test.rb +148 -0
 - data/test/cases/associations/eager_test.rb +1658 -0
 - data/test/cases/associations/extension_test.rb +93 -0
 - data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +1025 -0
 - data/test/cases/associations/has_many_associations_test.rb +3074 -0
 - data/test/cases/associations/has_many_through_associations_test.rb +1580 -0
 - data/test/cases/associations/has_one_associations_test.rb +872 -0
 - data/test/cases/associations/has_one_through_associations_test.rb +429 -0
 - data/test/cases/associations/inner_join_association_test.rb +215 -0
 - data/test/cases/associations/inverse_associations_test.rb +941 -0
 - data/test/cases/associations/join_model_test.rb +787 -0
 - data/test/cases/associations/left_outer_join_association_test.rb +123 -0
 - data/test/cases/associations/nested_through_associations_test.rb +636 -0
 - data/test/cases/associations/required_test.rb +127 -0
 - data/test/cases/associations_test.rb +516 -0
 - data/test/cases/attribute_decorators_test.rb +126 -0
 - data/test/cases/attribute_methods/read_test.rb +60 -0
 - data/test/cases/attribute_methods_test.rb +1124 -0
 - data/test/cases/attribute_set_test.rb +270 -0
 - data/test/cases/attribute_test.rb +246 -0
 - data/test/cases/attributes_test.rb +371 -0
 - data/test/cases/autosave_association_test.rb +1953 -0
 - data/test/cases/base_prevent_writes_test.rb +229 -0
 - data/test/cases/base_test.rb +1770 -0
 - data/test/cases/batches_test.rb +695 -0
 - data/test/cases/binary_test.rb +39 -0
 - data/test/cases/bind_parameter_test.rb +283 -0
 - data/test/cases/boolean_test.rb +52 -0
 - data/test/cases/cache_key_test.rb +131 -0
 - data/test/cases/calculations_test.rb +1361 -0
 - data/test/cases/callbacks_test.rb +503 -0
 - data/test/cases/clone_test.rb +45 -0
 - data/test/cases/coders/json_test.rb +17 -0
 - data/test/cases/coders/yaml_column_test.rb +66 -0
 - data/test/cases/collection_cache_key_test.rb +272 -0
 - data/test/cases/column_alias_test.rb +19 -0
 - data/test/cases/column_definition_test.rb +34 -0
 - data/test/cases/comment_test.rb +204 -0
 - data/test/cases/connection_adapters/adapter_leasing_test.rb +60 -0
 - data/test/cases/connection_adapters/connection_handler_test.rb +467 -0
 - data/test/cases/connection_adapters/connection_handlers_multi_db_test.rb +400 -0
 - data/test/cases/connection_adapters/connection_handlers_multi_pool_config_test.rb +103 -0
 - data/test/cases/connection_adapters/connection_handlers_sharding_db_test.rb +499 -0
 - data/test/cases/connection_adapters/connection_specification_test.rb +12 -0
 - data/test/cases/connection_adapters/connection_swapping_nested_test.rb +457 -0
 - data/test/cases/connection_adapters/legacy_connection_handlers_multi_db_test.rb +486 -0
 - data/test/cases/connection_adapters/legacy_connection_handlers_sharding_db_test.rb +586 -0
 - data/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +436 -0
 - data/test/cases/connection_adapters/mysql_type_lookup_test.rb +81 -0
 - data/test/cases/connection_adapters/quoting_test.rb +13 -0
 - data/test/cases/connection_adapters/schema_cache_test.rb +294 -0
 - data/test/cases/connection_adapters/type_lookup_test.rb +119 -0
 - data/test/cases/connection_management_test.rb +114 -0
 - data/test/cases/connection_pool_test.rb +754 -0
 - data/test/cases/connection_specification/resolver_test.rb +131 -0
 - data/test/cases/core_test.rb +136 -0
 - data/test/cases/counter_cache_test.rb +368 -0
 - data/test/cases/custom_locking_test.rb +19 -0
 - data/test/cases/database_configurations/hash_config_test.rb +74 -0
 - data/test/cases/database_configurations/resolver_test.rb +150 -0
 - data/test/cases/database_configurations_test.rb +145 -0
 - data/test/cases/database_selector_test.rb +296 -0
 - data/test/cases/database_statements_test.rb +36 -0
 - data/test/cases/date_test.rb +36 -0
 - data/test/cases/date_time_precision_test.rb +129 -0
 - data/test/cases/date_time_test.rb +76 -0
 - data/test/cases/defaults_test.rb +254 -0
 - data/test/cases/delegated_type_test.rb +57 -0
 - data/test/cases/dirty_test.rb +959 -0
 - data/test/cases/disconnected_test.rb +30 -0
 - data/test/cases/dup_test.rb +184 -0
 - data/test/cases/enum_test.rb +823 -0
 - data/test/cases/errors_test.rb +16 -0
 - data/test/cases/explain_subscriber_test.rb +66 -0
 - data/test/cases/explain_test.rb +79 -0
 - data/test/cases/filter_attributes_test.rb +153 -0
 - data/test/cases/finder_respond_to_test.rb +60 -0
 - data/test/cases/finder_test.rb +1676 -0
 - data/test/cases/fixture_set/file_test.rb +152 -0
 - data/test/cases/fixtures_test.rb +1645 -0
 - data/test/cases/forbidden_attributes_protection_test.rb +130 -0
 - data/test/cases/habtm_destroy_order_test.rb +61 -0
 - data/test/cases/helper.rb +233 -0
 - data/test/cases/hot_compatibility_test.rb +143 -0
 - data/test/cases/i18n_test.rb +46 -0
 - data/test/cases/inheritance_test.rb +671 -0
 - data/test/cases/insert_all_test.rb +489 -0
 - data/test/cases/instrumentation_test.rb +101 -0
 - data/test/cases/integration_test.rb +243 -0
 - data/test/cases/invalid_connection_test.rb +26 -0
 - data/test/cases/invertible_migration_test.rb +527 -0
 - data/test/cases/json_attribute_test.rb +35 -0
 - data/test/cases/json_serialization_test.rb +310 -0
 - data/test/cases/json_shared_test_cases.rb +290 -0
 - data/test/cases/locking_test.rb +787 -0
 - data/test/cases/log_subscriber_test.rb +267 -0
 - data/test/cases/marshal_serialization_test.rb +39 -0
 - data/test/cases/migration/change_schema_test.rb +504 -0
 - data/test/cases/migration/change_table_test.rb +364 -0
 - data/test/cases/migration/check_constraint_test.rb +162 -0
 - data/test/cases/migration/column_attributes_test.rb +186 -0
 - data/test/cases/migration/column_positioning_test.rb +68 -0
 - data/test/cases/migration/columns_test.rb +326 -0
 - data/test/cases/migration/command_recorder_test.rb +437 -0
 - data/test/cases/migration/compatibility_test.rb +673 -0
 - data/test/cases/migration/create_join_table_test.rb +167 -0
 - data/test/cases/migration/foreign_key_test.rb +581 -0
 - data/test/cases/migration/helper.rb +40 -0
 - data/test/cases/migration/index_test.rb +267 -0
 - data/test/cases/migration/logger_test.rb +39 -0
 - data/test/cases/migration/pending_migrations_test.rb +106 -0
 - data/test/cases/migration/references_foreign_key_test.rb +235 -0
 - data/test/cases/migration/references_index_test.rb +120 -0
 - data/test/cases/migration/references_statements_test.rb +137 -0
 - data/test/cases/migration/rename_table_test.rb +116 -0
 - data/test/cases/migration_test.rb +1525 -0
 - data/test/cases/migrator_test.rb +527 -0
 - data/test/cases/mixin_test.rb +64 -0
 - data/test/cases/modules_test.rb +174 -0
 - data/test/cases/multi_db_migrator_test.rb +223 -0
 - data/test/cases/multiparameter_attributes_test.rb +399 -0
 - data/test/cases/multiple_db_test.rb +116 -0
 - data/test/cases/nested_attributes_test.rb +1119 -0
 - data/test/cases/nested_attributes_with_callbacks_test.rb +146 -0
 - data/test/cases/null_relation_test.rb +84 -0
 - data/test/cases/numeric_data_test.rb +93 -0
 - data/test/cases/persistence_test.rb +1093 -0
 - data/test/cases/pooled_connections_test.rb +73 -0
 - data/test/cases/prepared_statement_status_test.rb +48 -0
 - data/test/cases/primary_keys_test.rb +482 -0
 - data/test/cases/query_cache_test.rb +915 -0
 - data/test/cases/quoting_test.rb +303 -0
 - data/test/cases/readonly_test.rb +120 -0
 - data/test/cases/reaper_test.rb +199 -0
 - data/test/cases/reflection_test.rb +520 -0
 - data/test/cases/relation/delegation_test.rb +76 -0
 - data/test/cases/relation/delete_all_test.rb +117 -0
 - data/test/cases/relation/merging_test.rb +434 -0
 - data/test/cases/relation/mutation_test.rb +145 -0
 - data/test/cases/relation/or_test.rb +192 -0
 - data/test/cases/relation/predicate_builder_test.rb +31 -0
 - data/test/cases/relation/record_fetch_warning_test.rb +42 -0
 - data/test/cases/relation/select_test.rb +67 -0
 - data/test/cases/relation/update_all_test.rb +317 -0
 - data/test/cases/relation/where_chain_test.rb +141 -0
 - data/test/cases/relation/where_clause_test.rb +257 -0
 - data/test/cases/relation/where_test.rb +429 -0
 - data/test/cases/relation_test.rb +482 -0
 - data/test/cases/relations_test.rb +2251 -0
 - data/test/cases/reload_models_test.rb +26 -0
 - data/test/cases/reserved_word_test.rb +141 -0
 - data/test/cases/result_test.rb +141 -0
 - data/test/cases/sanitize_test.rb +192 -0
 - data/test/cases/schema_dumper_test.rb +550 -0
 - data/test/cases/schema_loading_test.rb +53 -0
 - data/test/cases/scoping/default_scoping_test.rb +569 -0
 - data/test/cases/scoping/named_scoping_test.rb +649 -0
 - data/test/cases/scoping/relation_scoping_test.rb +522 -0
 - data/test/cases/secure_token_test.rb +47 -0
 - data/test/cases/serialization_test.rb +106 -0
 - data/test/cases/serialized_attribute_test.rb +455 -0
 - data/test/cases/signed_id_test.rb +168 -0
 - data/test/cases/statement_cache_test.rb +153 -0
 - data/test/cases/statement_invalid_test.rb +42 -0
 - data/test/cases/store_test.rb +320 -0
 - data/test/cases/strict_loading_test.rb +473 -0
 - data/test/cases/suppressor_test.rb +77 -0
 - data/test/cases/tasks/database_tasks_test.rb +1526 -0
 - data/test/cases/tasks/mysql_rake_test.rb +417 -0
 - data/test/cases/tasks/postgresql_rake_test.rb +534 -0
 - data/test/cases/tasks/sqlite_rake_test.rb +267 -0
 - data/test/cases/test_case.rb +142 -0
 - data/test/cases/test_databases_test.rb +79 -0
 - data/test/cases/test_fixtures_test.rb +96 -0
 - data/test/cases/time_precision_test.rb +125 -0
 - data/test/cases/timestamp_test.rb +504 -0
 - data/test/cases/touch_later_test.rb +123 -0
 - data/test/cases/transaction_callbacks_test.rb +772 -0
 - data/test/cases/transaction_isolation_test.rb +106 -0
 - data/test/cases/transactions_test.rb +1285 -0
 - data/test/cases/type/adapter_specific_registry_test.rb +145 -0
 - data/test/cases/type/date_time_test.rb +16 -0
 - data/test/cases/type/integer_test.rb +29 -0
 - data/test/cases/type/string_test.rb +24 -0
 - data/test/cases/type/time_test.rb +28 -0
 - data/test/cases/type/type_map_test.rb +178 -0
 - data/test/cases/type/unsigned_integer_test.rb +19 -0
 - data/test/cases/type_test.rb +41 -0
 - data/test/cases/types_test.rb +26 -0
 - data/test/cases/unconnected_test.rb +46 -0
 - data/test/cases/unsafe_raw_sql_test.rb +274 -0
 - data/test/cases/validations/absence_validation_test.rb +75 -0
 - data/test/cases/validations/association_validation_test.rb +99 -0
 - data/test/cases/validations/i18n_generate_message_validation_test.rb +102 -0
 - data/test/cases/validations/i18n_validation_test.rb +87 -0
 - data/test/cases/validations/length_validation_test.rb +80 -0
 - data/test/cases/validations/numericality_validation_test.rb +181 -0
 - data/test/cases/validations/presence_validation_test.rb +105 -0
 - data/test/cases/validations/uniqueness_validation_test.rb +618 -0
 - data/test/cases/validations_repair_helper.rb +21 -0
 - data/test/cases/validations_test.rb +229 -0
 - data/test/cases/view_test.rb +222 -0
 - data/test/cases/yaml_serialization_test.rb +166 -0
 - data/test/config.example.yml +97 -0
 - data/test/config.rb +7 -0
 - data/test/config.yml +220 -0
 - data/test/connections/native_ibm_db/connection.rb +44 -0
 - data/test/fixtures/accounts.yml +29 -0
 - data/test/fixtures/admin/accounts.yml +2 -0
 - data/test/fixtures/admin/randomly_named_a9.yml +7 -0
 - data/test/fixtures/admin/randomly_named_b0.yml +7 -0
 - data/test/fixtures/admin/users.yml +10 -0
 - data/test/fixtures/all/admin +1 -0
 - data/test/fixtures/all/developers.yml +0 -0
 - data/test/fixtures/all/namespaced/accounts.yml +2 -0
 - data/test/fixtures/all/people.yml +0 -0
 - data/test/fixtures/all/tasks.yml +0 -0
 - data/test/fixtures/author_addresses.yml +11 -0
 - data/test/fixtures/author_favorites.yml +4 -0
 - data/test/fixtures/authors.yml +17 -0
 - data/test/fixtures/bad_posts.yml +9 -0
 - data/test/fixtures/binaries.yml +137 -0
 - data/test/fixtures/books.yml +38 -0
 - data/test/fixtures/bulbs.yml +5 -0
 - data/test/fixtures/cars.yml +9 -0
 - data/test/fixtures/categories/special_categories.yml +9 -0
 - data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
 - data/test/fixtures/categories.yml +19 -0
 - data/test/fixtures/categories_ordered.yml +7 -0
 - data/test/fixtures/categories_posts.yml +34 -0
 - data/test/fixtures/categorizations.yml +23 -0
 - data/test/fixtures/citations.yml +5 -0
 - data/test/fixtures/clubs.yml +8 -0
 - data/test/fixtures/collections.yml +3 -0
 - data/test/fixtures/colleges.yml +3 -0
 - data/test/fixtures/comments.yml +72 -0
 - data/test/fixtures/companies.yml +72 -0
 - data/test/fixtures/computers.yml +12 -0
 - data/test/fixtures/content.yml +3 -0
 - data/test/fixtures/content_positions.yml +3 -0
 - data/test/fixtures/courses.yml +8 -0
 - data/test/fixtures/customers.yml +35 -0
 - data/test/fixtures/dashboards.yml +6 -0
 - data/test/fixtures/dead_parrots.yml +5 -0
 - data/test/fixtures/developers.yml +22 -0
 - data/test/fixtures/developers_projects.yml +17 -0
 - data/test/fixtures/dog_lovers.yml +7 -0
 - data/test/fixtures/dogs.yml +4 -0
 - data/test/fixtures/doubloons.yml +3 -0
 - data/test/fixtures/edges.yml +5 -0
 - data/test/fixtures/entrants.yml +14 -0
 - data/test/fixtures/essays.yml +16 -0
 - data/test/fixtures/faces.yml +11 -0
 - data/test/fixtures/fk_test_has_fk.yml +3 -0
 - data/test/fixtures/fk_test_has_pk.yml +2 -0
 - data/test/fixtures/friendships.yml +4 -0
 - data/test/fixtures/funny_jokes.yml +10 -0
 - data/test/fixtures/humans.yml +5 -0
 - data/test/fixtures/interests.yml +33 -0
 - data/test/fixtures/items.yml +3 -0
 - data/test/fixtures/jobs.yml +7 -0
 - data/test/fixtures/legacy_things.yml +3 -0
 - data/test/fixtures/live_parrots.yml +4 -0
 - data/test/fixtures/mateys.yml +4 -0
 - data/test/fixtures/member_details.yml +8 -0
 - data/test/fixtures/member_types.yml +6 -0
 - data/test/fixtures/members.yml +11 -0
 - data/test/fixtures/memberships.yml +41 -0
 - data/test/fixtures/men.yml +5 -0
 - data/test/fixtures/minimalistics.yml +5 -0
 - data/test/fixtures/minivans.yml +5 -0
 - data/test/fixtures/mixed_case_monkeys.yml +6 -0
 - data/test/fixtures/mixins.yml +29 -0
 - data/test/fixtures/movies.yml +7 -0
 - data/test/fixtures/naked/yml/accounts.yml +1 -0
 - data/test/fixtures/naked/yml/companies.yml +1 -0
 - data/test/fixtures/naked/yml/courses.yml +1 -0
 - data/test/fixtures/naked/yml/courses_with_invalid_key.yml +3 -0
 - data/test/fixtures/naked/yml/parrots.yml +3 -0
 - data/test/fixtures/naked/yml/trees.yml +3 -0
 - data/test/fixtures/nodes.yml +29 -0
 - data/test/fixtures/organizations.yml +5 -0
 - data/test/fixtures/other_books.yml +26 -0
 - data/test/fixtures/other_comments.yml +6 -0
 - data/test/fixtures/other_dogs.yml +2 -0
 - data/test/fixtures/other_posts.yml +8 -0
 - data/test/fixtures/other_topics.yml +42 -0
 - data/test/fixtures/owners.yml +9 -0
 - data/test/fixtures/parrots.yml +33 -0
 - data/test/fixtures/parrots_pirates.yml +7 -0
 - data/test/fixtures/people.yml +24 -0
 - data/test/fixtures/peoples_treasures.yml +3 -0
 - data/test/fixtures/pets.yml +19 -0
 - data/test/fixtures/pirates.yml +15 -0
 - data/test/fixtures/posts.yml +88 -0
 - data/test/fixtures/price_estimates.yml +16 -0
 - data/test/fixtures/products.yml +4 -0
 - data/test/fixtures/projects.yml +7 -0
 - data/test/fixtures/randomly_named_a9.yml +7 -0
 - data/test/fixtures/ratings.yml +14 -0
 - data/test/fixtures/readers.yml +17 -0
 - data/test/fixtures/references.yml +17 -0
 - data/test/fixtures/reserved_words/distinct.yml +5 -0
 - data/test/fixtures/reserved_words/distinct_select.yml +11 -0
 - data/test/fixtures/reserved_words/group.yml +14 -0
 - data/test/fixtures/reserved_words/select.yml +8 -0
 - data/test/fixtures/reserved_words/values.yml +7 -0
 - data/test/fixtures/ships.yml +6 -0
 - data/test/fixtures/speedometers.yml +8 -0
 - data/test/fixtures/sponsors.yml +15 -0
 - data/test/fixtures/strict_zines.yml +2 -0
 - data/test/fixtures/string_key_objects.yml +7 -0
 - data/test/fixtures/subscribers.yml +11 -0
 - data/test/fixtures/subscriptions.yml +12 -0
 - data/test/fixtures/taggings.yml +78 -0
 - data/test/fixtures/tags.yml +11 -0
 - data/test/fixtures/tasks.yml +7 -0
 - data/test/fixtures/teapots.yml +3 -0
 - data/test/fixtures/to_be_linked/accounts.yml +2 -0
 - data/test/fixtures/to_be_linked/users.yml +10 -0
 - data/test/fixtures/topics.yml +49 -0
 - data/test/fixtures/toys.yml +14 -0
 - data/test/fixtures/traffic_lights.yml +10 -0
 - data/test/fixtures/treasures.yml +10 -0
 - data/test/fixtures/trees.yml +3 -0
 - data/test/fixtures/uuid_children.yml +3 -0
 - data/test/fixtures/uuid_parents.yml +2 -0
 - data/test/fixtures/variants.yml +4 -0
 - data/test/fixtures/vegetables.yml +20 -0
 - data/test/fixtures/vertices.yml +4 -0
 - data/test/fixtures/warehouse-things.yml +3 -0
 - data/test/fixtures/warehouse_things.yml +3 -0
 - data/test/fixtures/zines.yml +5 -0
 - data/test/ibm_db_test.rb +25 -0
 - data/test/migrations/10_urban/9_add_expressions.rb +13 -0
 - data/test/migrations/decimal/1_give_me_big_numbers.rb +17 -0
 - data/test/migrations/magic/1_currencies_have_symbols.rb +13 -0
 - data/test/migrations/missing/1000_people_have_middle_names.rb +11 -0
 - data/test/migrations/missing/1_people_have_last_names.rb +11 -0
 - data/test/migrations/missing/3_we_need_reminders.rb +14 -0
 - data/test/migrations/missing/4_innocent_jointable.rb +14 -0
 - data/test/migrations/rename/1_we_need_things.rb +13 -0
 - data/test/migrations/rename/2_rename_things.rb +11 -0
 - data/test/migrations/to_copy/1_people_have_hobbies.rb +11 -0
 - data/test/migrations/to_copy/2_people_have_descriptions.rb +11 -0
 - data/test/migrations/to_copy2/1_create_articles.rb +9 -0
 - data/test/migrations/to_copy2/2_create_comments.rb +9 -0
 - data/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +11 -0
 - data/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +11 -0
 - data/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +11 -0
 - data/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +9 -0
 - data/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +9 -0
 - data/test/migrations/valid/1_valid_people_have_last_names.rb +11 -0
 - data/test/migrations/valid/2_we_need_reminders.rb +14 -0
 - data/test/migrations/valid/3_innocent_jointable.rb +14 -0
 - data/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +11 -0
 - data/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +14 -0
 - data/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +14 -0
 - data/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +11 -0
 - data/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +14 -0
 - data/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +14 -0
 - data/test/migrations/version_check/20131219224947_migration_version_check.rb +10 -0
 - data/test/models/account.rb +46 -0
 - data/test/models/admin/account.rb +5 -0
 - data/test/models/admin/randomly_named_c1.rb +9 -0
 - data/test/models/admin/user.rb +48 -0
 - data/test/models/admin.rb +7 -0
 - data/test/models/aircraft.rb +7 -0
 - data/test/models/arunit2_model.rb +5 -0
 - data/test/models/author.rb +260 -0
 - data/test/models/auto_id.rb +6 -0
 - data/test/models/autoloadable/extra_firm.rb +4 -0
 - data/test/models/binary.rb +4 -0
 - data/test/models/binary_field.rb +6 -0
 - data/test/models/bird.rb +24 -0
 - data/test/models/book.rb +33 -0
 - data/test/models/book_destroy_async.rb +24 -0
 - data/test/models/boolean.rb +7 -0
 - data/test/models/bulb.rb +61 -0
 - data/test/models/cake_designer.rb +5 -0
 - data/test/models/car.rb +36 -0
 - data/test/models/carrier.rb +4 -0
 - data/test/models/cart.rb +5 -0
 - data/test/models/cat.rb +12 -0
 - data/test/models/categorization.rb +21 -0
 - data/test/models/category.rb +47 -0
 - data/test/models/chef.rb +10 -0
 - data/test/models/citation.rb +7 -0
 - data/test/models/club.rb +28 -0
 - data/test/models/college.rb +12 -0
 - data/test/models/column.rb +5 -0
 - data/test/models/column_name.rb +5 -0
 - data/test/models/comment.rb +98 -0
 - data/test/models/company.rb +226 -0
 - data/test/models/company_in_module.rb +99 -0
 - data/test/models/computer.rb +5 -0
 - data/test/models/contact.rb +43 -0
 - data/test/models/content.rb +42 -0
 - data/test/models/contract.rb +38 -0
 - data/test/models/country.rb +5 -0
 - data/test/models/course.rb +8 -0
 - data/test/models/customer.rb +85 -0
 - data/test/models/customer_carrier.rb +16 -0
 - data/test/models/dashboard.rb +5 -0
 - data/test/models/default.rb +4 -0
 - data/test/models/department.rb +6 -0
 - data/test/models/destroy_async_parent.rb +15 -0
 - data/test/models/destroy_async_parent_soft_delete.rb +20 -0
 - data/test/models/developer.rb +341 -0
 - data/test/models/dl_keyed_belongs_to.rb +13 -0
 - data/test/models/dl_keyed_belongs_to_soft_delete.rb +19 -0
 - data/test/models/dl_keyed_has_many.rb +5 -0
 - data/test/models/dl_keyed_has_many_through.rb +5 -0
 - data/test/models/dl_keyed_has_one.rb +5 -0
 - data/test/models/dl_keyed_join.rb +10 -0
 - data/test/models/dog.rb +7 -0
 - data/test/models/dog_lover.rb +7 -0
 - data/test/models/doubloon.rb +14 -0
 - data/test/models/drink_designer.rb +20 -0
 - data/test/models/edge.rb +7 -0
 - data/test/models/electron.rb +7 -0
 - data/test/models/engine.rb +5 -0
 - data/test/models/entrant.rb +5 -0
 - data/test/models/entry.rb +5 -0
 - data/test/models/essay.rb +8 -0
 - data/test/models/essay_destroy_async.rb +12 -0
 - data/test/models/event.rb +5 -0
 - data/test/models/eye.rb +39 -0
 - data/test/models/face.rb +17 -0
 - data/test/models/family.rb +6 -0
 - data/test/models/family_tree.rb +6 -0
 - data/test/models/friendship.rb +8 -0
 - data/test/models/frog.rb +8 -0
 - data/test/models/guid.rb +4 -0
 - data/test/models/guitar.rb +6 -0
 - data/test/models/hotel.rb +13 -0
 - data/test/models/human.rb +39 -0
 - data/test/models/image.rb +5 -0
 - data/test/models/interest.rb +16 -0
 - data/test/models/invoice.rb +6 -0
 - data/test/models/item.rb +9 -0
 - data/test/models/job.rb +9 -0
 - data/test/models/joke.rb +9 -0
 - data/test/models/keyboard.rb +5 -0
 - data/test/models/legacy_thing.rb +5 -0
 - data/test/models/lesson.rb +13 -0
 - data/test/models/line_item.rb +5 -0
 - data/test/models/liquid.rb +6 -0
 - data/test/models/man.rb +11 -0
 - data/test/models/matey.rb +6 -0
 - data/test/models/measurement.rb +4 -0
 - data/test/models/member.rb +45 -0
 - data/test/models/member_detail.rb +11 -0
 - data/test/models/member_type.rb +5 -0
 - data/test/models/membership.rb +38 -0
 - data/test/models/mentor.rb +5 -0
 - data/test/models/message.rb +5 -0
 - data/test/models/minimalistic.rb +4 -0
 - data/test/models/minivan.rb +10 -0
 - data/test/models/mixed_case_monkey.rb +5 -0
 - data/test/models/mocktail_designer.rb +2 -0
 - data/test/models/molecule.rb +8 -0
 - data/test/models/mouse.rb +6 -0
 - data/test/models/movie.rb +7 -0
 - data/test/models/node.rb +7 -0
 - data/test/models/non_primary_key.rb +4 -0
 - data/test/models/notification.rb +5 -0
 - data/test/models/numeric_data.rb +12 -0
 - data/test/models/order.rb +6 -0
 - data/test/models/organization.rb +16 -0
 - data/test/models/other_dog.rb +7 -0
 - data/test/models/owner.rb +39 -0
 - data/test/models/parrot.rb +36 -0
 - data/test/models/person.rb +147 -0
 - data/test/models/personal_legacy_thing.rb +6 -0
 - data/test/models/pet.rb +20 -0
 - data/test/models/pet_treasure.rb +8 -0
 - data/test/models/pirate.rb +116 -0
 - data/test/models/possession.rb +5 -0
 - data/test/models/post.rb +371 -0
 - data/test/models/price_estimate.rb +14 -0
 - data/test/models/professor.rb +7 -0
 - data/test/models/project.rb +42 -0
 - data/test/models/publisher/article.rb +6 -0
 - data/test/models/publisher/magazine.rb +5 -0
 - data/test/models/publisher.rb +4 -0
 - data/test/models/randomly_named_c1.rb +5 -0
 - data/test/models/rating.rb +8 -0
 - data/test/models/reader.rb +25 -0
 - data/test/models/recipe.rb +5 -0
 - data/test/models/record.rb +4 -0
 - data/test/models/reference.rb +25 -0
 - data/test/models/reply.rb +79 -0
 - data/test/models/room.rb +6 -0
 - data/test/models/section.rb +6 -0
 - data/test/models/seminar.rb +6 -0
 - data/test/models/session.rb +6 -0
 - data/test/models/ship.rb +42 -0
 - data/test/models/ship_part.rb +10 -0
 - data/test/models/shop.rb +19 -0
 - data/test/models/shop_account.rb +8 -0
 - data/test/models/speedometer.rb +8 -0
 - data/test/models/sponsor.rb +10 -0
 - data/test/models/squeak.rb +6 -0
 - data/test/models/strict_zine.rb +7 -0
 - data/test/models/string_key_object.rb +5 -0
 - data/test/models/student.rb +6 -0
 - data/test/models/subject.rb +16 -0
 - data/test/models/subscriber.rb +10 -0
 - data/test/models/subscription.rb +8 -0
 - data/test/models/tag.rb +16 -0
 - data/test/models/tagging.rb +20 -0
 - data/test/models/task.rb +7 -0
 - data/test/models/topic.rb +153 -0
 - data/test/models/toy.rb +10 -0
 - data/test/models/traffic_light.rb +6 -0
 - data/test/models/treasure.rb +16 -0
 - data/test/models/treaty.rb +5 -0
 - data/test/models/tree.rb +5 -0
 - data/test/models/tuning_peg.rb +6 -0
 - data/test/models/tyre.rb +13 -0
 - data/test/models/user.rb +22 -0
 - data/test/models/uuid_child.rb +5 -0
 - data/test/models/uuid_item.rb +8 -0
 - data/test/models/uuid_parent.rb +5 -0
 - data/test/models/vegetables.rb +33 -0
 - data/test/models/vehicle.rb +7 -0
 - data/test/models/vertex.rb +11 -0
 - data/test/models/warehouse_thing.rb +7 -0
 - data/test/models/wheel.rb +5 -0
 - data/test/models/without_table.rb +5 -0
 - data/test/models/zine.rb +5 -0
 - data/test/schema/i5/ibm_db_specific_schema.rb +137 -0
 - data/test/schema/ids/ibm_db_specific_schema.rb +140 -0
 - data/test/schema/luw/ibm_db_specific_schema.rb +137 -0
 - data/test/schema/mysql2_specific_schema.rb +82 -0
 - data/test/schema/oracle_specific_schema.rb +38 -0
 - data/test/schema/postgresql_specific_schema.rb +125 -0
 - data/test/schema/schema.rb +1237 -0
 - data/test/schema/schema.rb.original +1057 -0
 - data/test/schema/sqlite_specific_schema.rb +11 -0
 - data/test/schema/zOS/ibm_db_specific_schema.rb +208 -0
 - data/test/support/config.rb +43 -0
 - data/test/support/connection.rb +29 -0
 - data/test/support/connection_helper.rb +16 -0
 - data/test/support/ddl_helper.rb +10 -0
 - data/test/support/marshal_compatibility_fixtures/IBM_DB/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/IBM_DB/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/Mysql2/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/Mysql2/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/PostgreSQL/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/PostgreSQL/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/SQLite/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/SQLite/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/legacy_6_0_record_mysql.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/legacy_relation.dump +0 -0
 - data/test/support/schema_dumping_helper.rb +22 -0
 - data/test/support/stubs/strong_parameters.rb +40 -0
 - data/test/support/yaml_compatibility_fixtures/rails_4_1.yml +22 -0
 - data/test/support/yaml_compatibility_fixtures/rails_4_2_0.yml +182 -0
 - data/test/support/yaml_compatibility_fixtures/rails_v1_mysql.yml +206 -0
 - data/test/support/yaml_compatibility_fixtures/rails_v2.yml +55 -0
 - metadata +876 -0
 
| 
         @@ -0,0 +1,147 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Person < ActiveRecord::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
              has_many :readers
         
     | 
| 
      
 5 
     | 
    
         
            +
              has_many :secure_readers
         
     | 
| 
      
 6 
     | 
    
         
            +
              has_one  :reader
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              has_many :posts, through: :readers
         
     | 
| 
      
 9 
     | 
    
         
            +
              has_many :secure_posts, through: :secure_readers
         
     | 
| 
      
 10 
     | 
    
         
            +
              has_many :posts_with_no_comments, -> { includes(:comments).where("comments.id is null").references(:comments) },
         
     | 
| 
      
 11 
     | 
    
         
            +
                                                through: :readers, source: :post
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              has_many :friendships, foreign_key: "friend_id"
         
     | 
| 
      
 14 
     | 
    
         
            +
              # friends_too exists to test a bug, and probably shouldn't be used elsewhere
         
     | 
| 
      
 15 
     | 
    
         
            +
              has_many :friends_too, foreign_key: "friend_id", class_name: "Friendship"
         
     | 
| 
      
 16 
     | 
    
         
            +
              has_many :followers, through: :friendships
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              has_many :references
         
     | 
| 
      
 19 
     | 
    
         
            +
              has_many :bad_references
         
     | 
| 
      
 20 
     | 
    
         
            +
              has_many :fixed_bad_references, -> { where favourite: true }, class_name: "BadReference"
         
     | 
| 
      
 21 
     | 
    
         
            +
              has_one  :favourite_reference, -> { where "favourite=?", true }, class_name: "Reference"
         
     | 
| 
      
 22 
     | 
    
         
            +
              has_many :posts_with_comments_sorted_by_comment_id, -> { includes(:comments).order("comments.id") }, through: :readers, source: :post
         
     | 
| 
      
 23 
     | 
    
         
            +
              has_many :first_posts, -> { where(id: [1, 2]) }, through: :readers
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              has_many :jobs, through: :references
         
     | 
| 
      
 26 
     | 
    
         
            +
              has_many :jobs_with_dependent_destroy,    source: :job, through: :references, dependent: :destroy
         
     | 
| 
      
 27 
     | 
    
         
            +
              has_many :jobs_with_dependent_delete_all, source: :job, through: :references, dependent: :delete_all
         
     | 
| 
      
 28 
     | 
    
         
            +
              has_many :jobs_with_dependent_nullify,    source: :job, through: :references, dependent: :nullify
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              belongs_to :primary_contact, class_name: "Person"
         
     | 
| 
      
 31 
     | 
    
         
            +
              has_many :agents, class_name: "Person", foreign_key: "primary_contact_id"
         
     | 
| 
      
 32 
     | 
    
         
            +
              has_many :agents_of_agents, through: :agents, source: :agents
         
     | 
| 
      
 33 
     | 
    
         
            +
              belongs_to :number1_fan, class_name: "Person"
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              has_many :personal_legacy_things, dependent: :destroy
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              has_many :agents_posts,         through: :agents,       source: :posts
         
     | 
| 
      
 38 
     | 
    
         
            +
              has_many :agents_posts_authors, through: :agents_posts, source: :author
         
     | 
| 
      
 39 
     | 
    
         
            +
              has_many :essays, primary_key: "first_name", foreign_key: "writer_id"
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              scope :males,   -> { where(gender: "M") }
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            class PersonWithDependentDestroyJobs < ActiveRecord::Base
         
     | 
| 
      
 45 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              has_many :references, foreign_key: :person_id
         
     | 
| 
      
 48 
     | 
    
         
            +
              has_many :jobs, source: :job, through: :references, dependent: :destroy
         
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            class PersonWithDependentDeleteAllJobs < ActiveRecord::Base
         
     | 
| 
      
 52 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              has_many :references, foreign_key: :person_id
         
     | 
| 
      
 55 
     | 
    
         
            +
              has_many :jobs, source: :job, through: :references, dependent: :delete_all
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            class PersonWithDependentNullifyJobs < ActiveRecord::Base
         
     | 
| 
      
 59 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              has_many :references, foreign_key: :person_id
         
     | 
| 
      
 62 
     | 
    
         
            +
              has_many :jobs, source: :job, through: :references, dependent: :nullify
         
     | 
| 
      
 63 
     | 
    
         
            +
            end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            class PersonWithPolymorphicDependentNullifyComments < ActiveRecord::Base
         
     | 
| 
      
 66 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 67 
     | 
    
         
            +
              has_many :comments, as: :author, dependent: :nullify
         
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            class LoosePerson < ActiveRecord::Base
         
     | 
| 
      
 71 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 72 
     | 
    
         
            +
              self.abstract_class = true
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              has_one    :best_friend,    class_name: "LoosePerson", foreign_key: :best_friend_id
         
     | 
| 
      
 75 
     | 
    
         
            +
              belongs_to :best_friend_of, class_name: "LoosePerson", foreign_key: :best_friend_of_id
         
     | 
| 
      
 76 
     | 
    
         
            +
              has_many   :best_friends,   class_name: "LoosePerson", foreign_key: :best_friend_id
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              accepts_nested_attributes_for :best_friend, :best_friend_of, :best_friends
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            class LooseDescendant < LoosePerson; end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            class TightPerson < ActiveRecord::Base
         
     | 
| 
      
 84 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              has_one    :best_friend,    class_name: "TightPerson", foreign_key: :best_friend_id
         
     | 
| 
      
 87 
     | 
    
         
            +
              belongs_to :best_friend_of, class_name: "TightPerson", foreign_key: :best_friend_of_id
         
     | 
| 
      
 88 
     | 
    
         
            +
              has_many   :best_friends,   class_name: "TightPerson", foreign_key: :best_friend_id
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              accepts_nested_attributes_for :best_friend, :best_friend_of, :best_friends
         
     | 
| 
      
 91 
     | 
    
         
            +
            end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            class TightDescendant < TightPerson; end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            class RichPerson < ActiveRecord::Base
         
     | 
| 
      
 96 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              has_and_belongs_to_many :treasures, join_table: "peoples_treasures"
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              before_validation :run_before_create, on: :create
         
     | 
| 
      
 101 
     | 
    
         
            +
              before_validation :run_before_validation
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              private
         
     | 
| 
      
 104 
     | 
    
         
            +
                def run_before_create
         
     | 
| 
      
 105 
     | 
    
         
            +
                  self.first_name = first_name.to_s + "run_before_create"
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                def run_before_validation
         
     | 
| 
      
 109 
     | 
    
         
            +
                  self.first_name = first_name.to_s + "run_before_validation"
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
            end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            class NestedPerson < ActiveRecord::Base
         
     | 
| 
      
 114 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
              has_one :best_friend, class_name: "NestedPerson", foreign_key: :best_friend_id
         
     | 
| 
      
 117 
     | 
    
         
            +
              accepts_nested_attributes_for :best_friend, update_only: true
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              def comments=(new_comments)
         
     | 
| 
      
 120 
     | 
    
         
            +
                raise RuntimeError
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
              def best_friend_first_name=(new_name)
         
     | 
| 
      
 124 
     | 
    
         
            +
                assign_attributes(best_friend_attributes: { first_name: new_name })
         
     | 
| 
      
 125 
     | 
    
         
            +
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
            end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            class Insure
         
     | 
| 
      
 129 
     | 
    
         
            +
              INSURES = %W{life annuality}
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
              def self.load(mask)
         
     | 
| 
      
 132 
     | 
    
         
            +
                INSURES.select do |insure|
         
     | 
| 
      
 133 
     | 
    
         
            +
                  (1 << INSURES.index(insure)) & mask.to_i > 0
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
              end
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              def self.dump(insures)
         
     | 
| 
      
 138 
     | 
    
         
            +
                numbers = insures.map { |insure| INSURES.index(insure) }
         
     | 
| 
      
 139 
     | 
    
         
            +
                numbers.inject(0) { |sum, n| sum + (1 << n) }
         
     | 
| 
      
 140 
     | 
    
         
            +
              end
         
     | 
| 
      
 141 
     | 
    
         
            +
            end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
            class SerializedPerson < ActiveRecord::Base
         
     | 
| 
      
 144 
     | 
    
         
            +
              self.table_name = "people"
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
              serialize :insures, Insure
         
     | 
| 
      
 147 
     | 
    
         
            +
            end
         
     | 
    
        data/test/models/pet.rb
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Pet < ActiveRecord::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
              attr_accessor :current_user
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              self.primary_key = :pet_id
         
     | 
| 
      
 7 
     | 
    
         
            +
              belongs_to :owner, touch: true
         
     | 
| 
      
 8 
     | 
    
         
            +
              has_many :toys
         
     | 
| 
      
 9 
     | 
    
         
            +
              has_many :pet_treasures
         
     | 
| 
      
 10 
     | 
    
         
            +
              has_many :treasures, through: :pet_treasures
         
     | 
| 
      
 11 
     | 
    
         
            +
              has_many :persons, through: :treasures, source: :looter, source_type: "Person"
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 14 
     | 
    
         
            +
                attr_accessor :after_destroy_output
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              after_destroy do |record|
         
     | 
| 
      
 18 
     | 
    
         
            +
                Pet.after_destroy_output = record.current_user
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,116 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Pirate < ActiveRecord::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
              belongs_to :parrot, validate: true
         
     | 
| 
      
 5 
     | 
    
         
            +
              belongs_to :non_validated_parrot, class_name: "Parrot"
         
     | 
| 
      
 6 
     | 
    
         
            +
              has_and_belongs_to_many :parrots, -> { order("parrots.id ASC") }, validate: true
         
     | 
| 
      
 7 
     | 
    
         
            +
              has_and_belongs_to_many :non_validated_parrots, class_name: "Parrot"
         
     | 
| 
      
 8 
     | 
    
         
            +
              has_and_belongs_to_many :parrots_with_method_callbacks, class_name: "Parrot",
         
     | 
| 
      
 9 
     | 
    
         
            +
                before_add: :log_before_add,
         
     | 
| 
      
 10 
     | 
    
         
            +
                after_add: :log_after_add,
         
     | 
| 
      
 11 
     | 
    
         
            +
                before_remove: :log_before_remove,
         
     | 
| 
      
 12 
     | 
    
         
            +
                after_remove: :log_after_remove
         
     | 
| 
      
 13 
     | 
    
         
            +
              has_and_belongs_to_many :parrots_with_proc_callbacks, class_name: "Parrot",
         
     | 
| 
      
 14 
     | 
    
         
            +
                before_add: proc { |p, pa| p.ship_log << "before_adding_proc_parrot_#{pa.id || '<new>'}" },
         
     | 
| 
      
 15 
     | 
    
         
            +
                after_add: proc { |p, pa| p.ship_log << "after_adding_proc_parrot_#{pa.id || '<new>'}" },
         
     | 
| 
      
 16 
     | 
    
         
            +
                before_remove: proc { |p, pa| p.ship_log << "before_removing_proc_parrot_#{pa.id}" },
         
     | 
| 
      
 17 
     | 
    
         
            +
                after_remove: proc { |p, pa| p.ship_log << "after_removing_proc_parrot_#{pa.id}" }
         
     | 
| 
      
 18 
     | 
    
         
            +
              has_and_belongs_to_many :autosaved_parrots, class_name: "Parrot", autosave: true
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              module PostTreasuresExtension
         
     | 
| 
      
 21 
     | 
    
         
            +
                def build(attributes = {})
         
     | 
| 
      
 22 
     | 
    
         
            +
                  super({ name: "from extension" }.merge(attributes))
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              has_many :treasures, as: :looter, extend: PostTreasuresExtension
         
     | 
| 
      
 27 
     | 
    
         
            +
              has_many :treasure_estimates, through: :treasures, source: :price_estimates
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              has_one :ship
         
     | 
| 
      
 30 
     | 
    
         
            +
              has_one :update_only_ship, class_name: "Ship"
         
     | 
| 
      
 31 
     | 
    
         
            +
              has_one :non_validated_ship, class_name: "Ship"
         
     | 
| 
      
 32 
     | 
    
         
            +
              has_many :birds, -> { order("birds.id ASC") }
         
     | 
| 
      
 33 
     | 
    
         
            +
              has_many :birds_with_method_callbacks, class_name: "Bird",
         
     | 
| 
      
 34 
     | 
    
         
            +
                before_add: :log_before_add,
         
     | 
| 
      
 35 
     | 
    
         
            +
                after_add: :log_after_add,
         
     | 
| 
      
 36 
     | 
    
         
            +
                before_remove: :log_before_remove,
         
     | 
| 
      
 37 
     | 
    
         
            +
                after_remove: :log_after_remove
         
     | 
| 
      
 38 
     | 
    
         
            +
              has_many :birds_with_proc_callbacks, class_name: "Bird",
         
     | 
| 
      
 39 
     | 
    
         
            +
                before_add: proc { |p, b| p.ship_log << "before_adding_proc_bird_#{b.id || '<new>'}" },
         
     | 
| 
      
 40 
     | 
    
         
            +
                after_add: proc { |p, b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}" },
         
     | 
| 
      
 41 
     | 
    
         
            +
                before_remove: proc { |p, b| p.ship_log << "before_removing_proc_bird_#{b.id}" },
         
     | 
| 
      
 42 
     | 
    
         
            +
                after_remove: proc { |p, b| p.ship_log << "after_removing_proc_bird_#{b.id}" }
         
     | 
| 
      
 43 
     | 
    
         
            +
              has_many :birds_with_reject_all_blank, class_name: "Bird"
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              has_one :foo_bulb, -> { where name: "foo" }, foreign_key: :car_id, class_name: "Bulb"
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              accepts_nested_attributes_for :parrots, :birds, allow_destroy: true, reject_if: proc(&:empty?)
         
     | 
| 
      
 48 
     | 
    
         
            +
              accepts_nested_attributes_for :ship, allow_destroy: true, reject_if: proc(&:empty?)
         
     | 
| 
      
 49 
     | 
    
         
            +
              accepts_nested_attributes_for :update_only_ship, update_only: true
         
     | 
| 
      
 50 
     | 
    
         
            +
              accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks,
         
     | 
| 
      
 51 
     | 
    
         
            +
                :birds_with_method_callbacks, :birds_with_proc_callbacks, allow_destroy: true
         
     | 
| 
      
 52 
     | 
    
         
            +
              accepts_nested_attributes_for :birds_with_reject_all_blank, reject_if: :all_blank
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              validates_presence_of :catchphrase
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              def ship_log
         
     | 
| 
      
 57 
     | 
    
         
            +
                @ship_log ||= []
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              def reject_empty_ships_on_create(attributes)
         
     | 
| 
      
 61 
     | 
    
         
            +
                attributes.delete("_reject_me_if_new").present? && !persisted?
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              attr_accessor :cancel_save_from_callback, :parrots_limit
         
     | 
| 
      
 65 
     | 
    
         
            +
              before_save :cancel_save_callback_method, if: :cancel_save_from_callback
         
     | 
| 
      
 66 
     | 
    
         
            +
              def cancel_save_callback_method
         
     | 
| 
      
 67 
     | 
    
         
            +
                throw(:abort)
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
              private
         
     | 
| 
      
 71 
     | 
    
         
            +
                def log_before_add(record)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  log(record, "before_adding_method")
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                def log_after_add(record)
         
     | 
| 
      
 76 
     | 
    
         
            +
                  log(record, "after_adding_method")
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                def log_before_remove(record)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  log(record, "before_removing_method")
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                def log_after_remove(record)
         
     | 
| 
      
 84 
     | 
    
         
            +
                  log(record, "after_removing_method")
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                def log(record, callback)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  ship_log << "#{callback}_#{record.class.name.downcase}_#{record.id || '<new>'}"
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
            end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            class DestructivePirate < Pirate
         
     | 
| 
      
 93 
     | 
    
         
            +
              has_one :dependent_ship, class_name: "Ship", foreign_key: :pirate_id, dependent: :destroy
         
     | 
| 
      
 94 
     | 
    
         
            +
            end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            class FamousPirate < ActiveRecord::Base
         
     | 
| 
      
 97 
     | 
    
         
            +
              self.table_name = "pirates"
         
     | 
| 
      
 98 
     | 
    
         
            +
              has_many :famous_ships, inverse_of: :famous_pirate, foreign_key: :pirate_id
         
     | 
| 
      
 99 
     | 
    
         
            +
              validates_presence_of :catchphrase, on: :conference
         
     | 
| 
      
 100 
     | 
    
         
            +
            end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
            class SpacePirate < ActiveRecord::Base
         
     | 
| 
      
 103 
     | 
    
         
            +
              self.table_name = "pirates"
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
              belongs_to :parrot
         
     | 
| 
      
 106 
     | 
    
         
            +
              belongs_to :parrot_with_annotation, -> { annotate("that tells jokes") }, class_name: :Parrot, foreign_key: :parrot_id
         
     | 
| 
      
 107 
     | 
    
         
            +
              has_and_belongs_to_many :parrots, foreign_key: :pirate_id
         
     | 
| 
      
 108 
     | 
    
         
            +
              has_and_belongs_to_many :parrots_with_annotation, -> { annotate("that are very colorful") }, class_name: :Parrot, foreign_key: :pirate_id
         
     | 
| 
      
 109 
     | 
    
         
            +
              has_one :ship, foreign_key: :pirate_id
         
     | 
| 
      
 110 
     | 
    
         
            +
              has_one :ship_with_annotation, -> { annotate("that is a rocket") }, class_name: :Ship, foreign_key: :pirate_id
         
     | 
| 
      
 111 
     | 
    
         
            +
              has_many :birds, foreign_key: :pirate_id
         
     | 
| 
      
 112 
     | 
    
         
            +
              has_many :birds_with_annotation, -> { annotate("that are also parrots") }, class_name: :Bird, foreign_key: :pirate_id
         
     | 
| 
      
 113 
     | 
    
         
            +
              has_many :treasures, as: :looter
         
     | 
| 
      
 114 
     | 
    
         
            +
              has_many :treasure_estimates, through: :treasures, source: :price_estimates
         
     | 
| 
      
 115 
     | 
    
         
            +
              has_many :treasure_estimates_with_annotation, -> { annotate("yarrr") }, through: :treasures, source: :price_estimates
         
     | 
| 
      
 116 
     | 
    
         
            +
            end
         
     | 
    
        data/test/models/post.rb
    ADDED
    
    | 
         @@ -0,0 +1,371 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Post < ActiveRecord::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
              class CategoryPost < ActiveRecord::Base
         
     | 
| 
      
 5 
     | 
    
         
            +
                self.table_name = "categories_posts"
         
     | 
| 
      
 6 
     | 
    
         
            +
                belongs_to :group, foreign_key: :category_id, class_name: "Category"
         
     | 
| 
      
 7 
     | 
    
         
            +
                belongs_to :category
         
     | 
| 
      
 8 
     | 
    
         
            +
                belongs_to :post
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              module NamedExtension
         
     | 
| 
      
 12 
     | 
    
         
            +
                def author
         
     | 
| 
      
 13 
     | 
    
         
            +
                  "lifo"
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def greeting
         
     | 
| 
      
 17 
     | 
    
         
            +
                  super + " :)"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              module NamedExtension2
         
     | 
| 
      
 22 
     | 
    
         
            +
                def greeting
         
     | 
| 
      
 23 
     | 
    
         
            +
                  "hullo"
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              alias_attribute :text, :body
         
     | 
| 
      
 28 
     | 
    
         
            +
              alias_attribute :comments_count, :legacy_comments_count
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              scope :containing_the_letter_a, -> { where("body LIKE '%a%'") }
         
     | 
| 
      
 31 
     | 
    
         
            +
              scope :titled_with_an_apostrophe, -> { where("title LIKE '%''%'") }
         
     | 
| 
      
 32 
     | 
    
         
            +
              scope :ranked_by_comments, -> { order(table[:comments_count].desc) }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              scope :limit_by, lambda { |l| limit(l) }
         
     | 
| 
      
 35 
     | 
    
         
            +
              scope :locked, -> { lock }
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              belongs_to :author
         
     | 
| 
      
 38 
     | 
    
         
            +
              belongs_to :readonly_author, -> { readonly }, class_name: "Author", foreign_key: :author_id
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              belongs_to :author_with_posts, -> { includes(:posts) }, class_name: "Author", foreign_key: :author_id
         
     | 
| 
      
 41 
     | 
    
         
            +
              belongs_to :author_with_address, -> { includes(:author_address) }, class_name: "Author", foreign_key: :author_id
         
     | 
| 
      
 42 
     | 
    
         
            +
              belongs_to :author_with_select, -> { select(:id) }, class_name: "Author", foreign_key: :author_id
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def first_comment
         
     | 
| 
      
 45 
     | 
    
         
            +
                super.body
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
              has_one :first_comment, -> { order("id ASC") }, class_name: "Comment"
         
     | 
| 
      
 48 
     | 
    
         
            +
              has_one :last_comment, -> { order("id desc") }, class_name: "Comment"
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              scope :no_comments, -> { left_joins(:comments).where(comments: { id: nil }) }
         
     | 
| 
      
 51 
     | 
    
         
            +
              scope :with_special_comments, -> { joins(:comments).where(comments: { type: "SpecialComment" }) }
         
     | 
| 
      
 52 
     | 
    
         
            +
              scope :with_very_special_comments, -> { joins(:comments).where(comments: { type: "VerySpecialComment" }) }
         
     | 
| 
      
 53 
     | 
    
         
            +
              scope :with_post, ->(post_id) { joins(:comments).where(comments: { post_id: post_id }) }
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              scope :with_comments, -> { preload(:comments) }
         
     | 
| 
      
 56 
     | 
    
         
            +
              scope :with_tags, -> { preload(:taggings) }
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              scope :tagged_with, ->(id) { joins(:taggings).where(taggings: { tag_id: id }) }
         
     | 
| 
      
 59 
     | 
    
         
            +
              scope :tagged_with_comment, ->(comment) { joins(:taggings).where(taggings: { comment: comment }) }
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              scope :typographically_interesting, -> { containing_the_letter_a.or(titled_with_an_apostrophe) }
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              has_many :comments do
         
     | 
| 
      
 64 
     | 
    
         
            +
                def find_most_recent
         
     | 
| 
      
 65 
     | 
    
         
            +
                  order("id DESC").first
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                def newest
         
     | 
| 
      
 69 
     | 
    
         
            +
                  created.last
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                def the_association
         
     | 
| 
      
 73 
     | 
    
         
            +
                  proxy_association
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                def with_content(content)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  self.detect { |comment| comment.body == content }
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              has_many :comments_with_extend, extend: NamedExtension, class_name: "Comment", foreign_key: "post_id" do
         
     | 
| 
      
 82 
     | 
    
         
            +
                def greeting
         
     | 
| 
      
 83 
     | 
    
         
            +
                  "hello"
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              has_many :comments_with_extend_2, extend: [NamedExtension, NamedExtension2], class_name: "Comment", foreign_key: "post_id"
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
              has_many :author_favorites, through: :author
         
     | 
| 
      
 90 
     | 
    
         
            +
              has_many :author_favorites_with_scope, through: :author, class_name: "AuthorFavoriteWithScope", source: "author_favorites"
         
     | 
| 
      
 91 
     | 
    
         
            +
              has_many :author_categorizations, through: :author, source: :categorizations
         
     | 
| 
      
 92 
     | 
    
         
            +
              has_many :author_addresses, through: :author
         
     | 
| 
      
 93 
     | 
    
         
            +
              has_many :author_address_extra_with_address,
         
     | 
| 
      
 94 
     | 
    
         
            +
                through: :author_with_address,
         
     | 
| 
      
 95 
     | 
    
         
            +
                source: :author_address_extra
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
              has_one  :very_special_comment
         
     | 
| 
      
 98 
     | 
    
         
            +
              has_one  :very_special_comment_with_post, -> { includes(:post) }, class_name: "VerySpecialComment"
         
     | 
| 
      
 99 
     | 
    
         
            +
              has_one :very_special_comment_with_post_with_joins, -> { joins(:post).order("posts.id") }, class_name: "VerySpecialComment"
         
     | 
| 
      
 100 
     | 
    
         
            +
              has_many :special_comments
         
     | 
| 
      
 101 
     | 
    
         
            +
              has_many :nonexistent_comments, -> { where "comments.id < 0" }, class_name: "Comment"
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              has_many :special_comments_ratings, through: :special_comments, source: :ratings
         
     | 
| 
      
 104 
     | 
    
         
            +
              has_many :special_comments_ratings_taggings, through: :special_comments_ratings, source: :taggings
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
              has_many :category_posts, class_name: "CategoryPost"
         
     | 
| 
      
 107 
     | 
    
         
            +
              has_many :scategories, through: :category_posts, source: :category
         
     | 
| 
      
 108 
     | 
    
         
            +
              has_many :hmt_special_categories, -> { where.not(name: nil) },  through: :category_posts, source: :category, class_name: "SpecialCategory"
         
     | 
| 
      
 109 
     | 
    
         
            +
              has_and_belongs_to_many :categories
         
     | 
| 
      
 110 
     | 
    
         
            +
              has_and_belongs_to_many :special_categories, join_table: "categories_posts", association_foreign_key: "category_id"
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
              has_many :taggings, as: :taggable, counter_cache: :tags_count
         
     | 
| 
      
 113 
     | 
    
         
            +
              has_many :tags, through: :taggings do
         
     | 
| 
      
 114 
     | 
    
         
            +
                def add_joins_and_select
         
     | 
| 
      
 115 
     | 
    
         
            +
                  select("tags.*, authors.id as author_id")
         
     | 
| 
      
 116 
     | 
    
         
            +
                    .joins("left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id")
         
     | 
| 
      
 117 
     | 
    
         
            +
                    .to_a
         
     | 
| 
      
 118 
     | 
    
         
            +
                end
         
     | 
| 
      
 119 
     | 
    
         
            +
              end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
              has_many :indestructible_taggings, as: :taggable, counter_cache: :indestructible_tags_count
         
     | 
| 
      
 122 
     | 
    
         
            +
              has_many :indestructible_tags, through: :indestructible_taggings, source: :tag
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
              has_many :taggings_with_delete_all, class_name: "Tagging", as: :taggable, dependent: :delete_all, counter_cache: :taggings_with_delete_all_count
         
     | 
| 
      
 125 
     | 
    
         
            +
              has_many :taggings_with_destroy, class_name: "Tagging", as: :taggable, dependent: :destroy, counter_cache: :taggings_with_destroy_count
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
              has_many :tags_with_destroy, through: :taggings, source: :tag, dependent: :destroy, counter_cache: :tags_with_destroy_count
         
     | 
| 
      
 128 
     | 
    
         
            +
              has_many :tags_with_nullify, through: :taggings, source: :tag, dependent: :nullify, counter_cache: :tags_with_nullify_count
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
              has_many :misc_tags, -> { where tags: { name: "Misc" } }, through: :taggings, source: :tag
         
     | 
| 
      
 131 
     | 
    
         
            +
              has_many :funky_tags, through: :taggings, source: :tag
         
     | 
| 
      
 132 
     | 
    
         
            +
              has_many :super_tags, through: :taggings
         
     | 
| 
      
 133 
     | 
    
         
            +
              has_many :ordered_tags, through: :taggings
         
     | 
| 
      
 134 
     | 
    
         
            +
              has_many :tags_with_primary_key, through: :taggings, source: :tag_with_primary_key
         
     | 
| 
      
 135 
     | 
    
         
            +
              has_one :tagging, as: :taggable
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              has_many :first_taggings, -> { where taggings: { comment: "first" } }, as: :taggable, class_name: "Tagging"
         
     | 
| 
      
 138 
     | 
    
         
            +
              has_many :first_blue_tags, -> { where tags: { name: "Blue" } }, through: :first_taggings, source: :tag
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
              has_many :first_blue_tags_2, -> { where taggings: { comment: "first" } }, through: :taggings, source: :blue_tag
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
              has_many :invalid_taggings, -> { where "taggings.id < 0" }, as: :taggable, class_name: "Tagging"
         
     | 
| 
      
 143 
     | 
    
         
            +
              has_many :invalid_tags, through: :invalid_taggings, source: :tag
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              has_many :categorizations, foreign_key: :category_id
         
     | 
| 
      
 146 
     | 
    
         
            +
              has_many :authors, through: :categorizations
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
              has_many :categorizations_using_author_id, primary_key: :author_id, foreign_key: :post_id, class_name: "Categorization"
         
     | 
| 
      
 149 
     | 
    
         
            +
              has_many :authors_using_author_id, through: :categorizations_using_author_id, source: :author
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
              has_many :taggings_using_author_id, primary_key: :author_id, as: :taggable, class_name: "Tagging"
         
     | 
| 
      
 152 
     | 
    
         
            +
              has_many :tags_using_author_id, through: :taggings_using_author_id, source: :tag
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              has_many :images, as: :imageable, foreign_key: :imageable_identifier, foreign_type: :imageable_class
         
     | 
| 
      
 155 
     | 
    
         
            +
              has_one :main_image, as: :imageable, foreign_key: :imageable_identifier, foreign_type: :imageable_class, class_name: "Image"
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
              has_many :standard_categorizations, class_name: "Categorization", foreign_key: :post_id
         
     | 
| 
      
 158 
     | 
    
         
            +
              has_many :author_using_custom_pk,  through: :standard_categorizations
         
     | 
| 
      
 159 
     | 
    
         
            +
              has_many :authors_using_custom_pk, through: :standard_categorizations
         
     | 
| 
      
 160 
     | 
    
         
            +
              has_many :named_categories, through: :standard_categorizations
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
              has_many :readers
         
     | 
| 
      
 163 
     | 
    
         
            +
              has_many :secure_readers
         
     | 
| 
      
 164 
     | 
    
         
            +
              has_many :readers_with_person, -> { includes(:person) }, class_name: "Reader"
         
     | 
| 
      
 165 
     | 
    
         
            +
              has_many :people, through: :readers
         
     | 
| 
      
 166 
     | 
    
         
            +
              has_many :single_people, through: :readers
         
     | 
| 
      
 167 
     | 
    
         
            +
              has_many :people_with_callbacks, source: :person, through: :readers,
         
     | 
| 
      
 168 
     | 
    
         
            +
                          before_add: lambda { |owner, reader| log(:added,   :before, reader.first_name) },
         
     | 
| 
      
 169 
     | 
    
         
            +
                          after_add: lambda { |owner, reader| log(:added,   :after,  reader.first_name) },
         
     | 
| 
      
 170 
     | 
    
         
            +
                          before_remove: lambda { |owner, reader| log(:removed, :before, reader.first_name) },
         
     | 
| 
      
 171 
     | 
    
         
            +
                          after_remove: lambda { |owner, reader| log(:removed, :after,  reader.first_name) }
         
     | 
| 
      
 172 
     | 
    
         
            +
              has_many :skimmers, -> { where skimmer: true }, class_name: "Reader"
         
     | 
| 
      
 173 
     | 
    
         
            +
              has_many :impatient_people, through: :skimmers, source: :person
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
              has_many :lazy_readers
         
     | 
| 
      
 176 
     | 
    
         
            +
              has_many :lazy_readers_skimmers_or_not, -> { where(skimmer: [ true, false ]) }, class_name: "LazyReader"
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
              has_many :lazy_people, through: :lazy_readers, source: :person
         
     | 
| 
      
 179 
     | 
    
         
            +
              has_many :lazy_readers_unscope_skimmers, -> { skimmers_or_not }, class_name: "LazyReader"
         
     | 
| 
      
 180 
     | 
    
         
            +
              has_many :lazy_people_unscope_skimmers, through: :lazy_readers_unscope_skimmers, source: :person
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
              def self.top(limit)
         
     | 
| 
      
 183 
     | 
    
         
            +
                ranked_by_comments.limit_by(limit)
         
     | 
| 
      
 184 
     | 
    
         
            +
              end
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
              def self.written_by(author)
         
     | 
| 
      
 187 
     | 
    
         
            +
                where(id: author.posts.pluck(:id))
         
     | 
| 
      
 188 
     | 
    
         
            +
              end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
              def self.reset_log
         
     | 
| 
      
 191 
     | 
    
         
            +
                @log = []
         
     | 
| 
      
 192 
     | 
    
         
            +
              end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
              def self.log(message = nil, side = nil, new_record = nil)
         
     | 
| 
      
 195 
     | 
    
         
            +
                return @log if message.nil?
         
     | 
| 
      
 196 
     | 
    
         
            +
                @log << [message, side, new_record]
         
     | 
| 
      
 197 
     | 
    
         
            +
              end
         
     | 
| 
      
 198 
     | 
    
         
            +
            end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
            class SpecialPost < Post; end
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
            class StiPost < Post
         
     | 
| 
      
 203 
     | 
    
         
            +
              has_one :special_comment, class_name: "SpecialComment"
         
     | 
| 
      
 204 
     | 
    
         
            +
            end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            class AbstractStiPost < Post
         
     | 
| 
      
 207 
     | 
    
         
            +
              self.abstract_class = true
         
     | 
| 
      
 208 
     | 
    
         
            +
            end
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
            class SubStiPost < StiPost
         
     | 
| 
      
 211 
     | 
    
         
            +
              self.table_name = Post.table_name
         
     | 
| 
      
 212 
     | 
    
         
            +
            end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
            class SubAbstractStiPost < AbstractStiPost; end
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
            class NullPost < Post
         
     | 
| 
      
 217 
     | 
    
         
            +
              default_scope { none }
         
     | 
| 
      
 218 
     | 
    
         
            +
            end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
            class FirstPost < ActiveRecord::Base
         
     | 
| 
      
 221 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 222 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 223 
     | 
    
         
            +
              default_scope { where(id: 1) }
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
              has_many :comments, foreign_key: :post_id
         
     | 
| 
      
 226 
     | 
    
         
            +
              has_one  :comment,  foreign_key: :post_id
         
     | 
| 
      
 227 
     | 
    
         
            +
            end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
            class PostWithDefaultSelect < ActiveRecord::Base
         
     | 
| 
      
 230 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
              default_scope { select(:author_id) }
         
     | 
| 
      
 233 
     | 
    
         
            +
            end
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
            class TaggedPost < Post
         
     | 
| 
      
 236 
     | 
    
         
            +
              has_many :taggings, -> { rewhere(taggable_type: "TaggedPost") }, as: :taggable
         
     | 
| 
      
 237 
     | 
    
         
            +
              has_many :tags, through: :taggings
         
     | 
| 
      
 238 
     | 
    
         
            +
            end
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
            class PostWithDefaultInclude < ActiveRecord::Base
         
     | 
| 
      
 241 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 242 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 243 
     | 
    
         
            +
              default_scope { includes(:comments) }
         
     | 
| 
      
 244 
     | 
    
         
            +
              has_many :comments, foreign_key: :post_id
         
     | 
| 
      
 245 
     | 
    
         
            +
            end
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
            class PostWithSpecialCategorization < Post
         
     | 
| 
      
 248 
     | 
    
         
            +
              has_many :categorizations, foreign_key: :post_id
         
     | 
| 
      
 249 
     | 
    
         
            +
              default_scope { where(type: "PostWithSpecialCategorization").joins(:categorizations).where(categorizations: { special: true }) }
         
     | 
| 
      
 250 
     | 
    
         
            +
            end
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
            class PostWithDefaultScope < ActiveRecord::Base
         
     | 
| 
      
 253 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 254 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 255 
     | 
    
         
            +
              default_scope { order(:title) }
         
     | 
| 
      
 256 
     | 
    
         
            +
            end
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
      
 258 
     | 
    
         
            +
            class PostWithPreloadDefaultScope < ActiveRecord::Base
         
     | 
| 
      
 259 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
              has_many :readers, foreign_key: "post_id"
         
     | 
| 
      
 262 
     | 
    
         
            +
             
     | 
| 
      
 263 
     | 
    
         
            +
              default_scope { preload(:readers) }
         
     | 
| 
      
 264 
     | 
    
         
            +
            end
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
            class PostWithIncludesDefaultScope < ActiveRecord::Base
         
     | 
| 
      
 267 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
              has_many :readers, foreign_key: "post_id"
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
              default_scope { includes(:readers) }
         
     | 
| 
      
 272 
     | 
    
         
            +
            end
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
      
 274 
     | 
    
         
            +
            class SpecialPostWithDefaultScope < ActiveRecord::Base
         
     | 
| 
      
 275 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 276 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 277 
     | 
    
         
            +
              default_scope { where(id: [1, 5, 6]) }
         
     | 
| 
      
 278 
     | 
    
         
            +
              scope :unscoped_all, -> { unscoped { all } }
         
     | 
| 
      
 279 
     | 
    
         
            +
              scope :authorless, -> { unscoped { where(author_id: 0) } }
         
     | 
| 
      
 280 
     | 
    
         
            +
            end
         
     | 
| 
      
 281 
     | 
    
         
            +
             
     | 
| 
      
 282 
     | 
    
         
            +
            class PostThatLoadsCommentsInAnAfterSaveHook < ActiveRecord::Base
         
     | 
| 
      
 283 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 284 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 285 
     | 
    
         
            +
              has_many :comments, class_name: "CommentThatAutomaticallyAltersPostBody", foreign_key: :post_id
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
              after_save do |post|
         
     | 
| 
      
 288 
     | 
    
         
            +
                post.comments.load
         
     | 
| 
      
 289 
     | 
    
         
            +
              end
         
     | 
| 
      
 290 
     | 
    
         
            +
            end
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
            class PostWithAfterCreateCallback < ActiveRecord::Base
         
     | 
| 
      
 293 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 294 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 295 
     | 
    
         
            +
              has_many :comments, foreign_key: :post_id
         
     | 
| 
      
 296 
     | 
    
         
            +
              has_and_belongs_to_many :categories, foreign_key: :post_id
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
              after_create do |post|
         
     | 
| 
      
 299 
     | 
    
         
            +
                update_attribute(:author_id, comments.first.id)
         
     | 
| 
      
 300 
     | 
    
         
            +
              end
         
     | 
| 
      
 301 
     | 
    
         
            +
            end
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
            class PostWithCommentWithDefaultScopeReferencesAssociation < ActiveRecord::Base
         
     | 
| 
      
 304 
     | 
    
         
            +
              self.inheritance_column = :disabled
         
     | 
| 
      
 305 
     | 
    
         
            +
              self.table_name = "posts"
         
     | 
| 
      
 306 
     | 
    
         
            +
              has_many :comment_with_default_scope_references_associations, foreign_key: :post_id
         
     | 
| 
      
 307 
     | 
    
         
            +
              has_one :first_comment, class_name: "CommentWithDefaultScopeReferencesAssociation", foreign_key: :post_id
         
     | 
| 
      
 308 
     | 
    
         
            +
            end
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
            class SerializedPost < ActiveRecord::Base
         
     | 
| 
      
 311 
     | 
    
         
            +
              serialize :title
         
     | 
| 
      
 312 
     | 
    
         
            +
            end
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
      
 314 
     | 
    
         
            +
            class ConditionalStiPost < Post
         
     | 
| 
      
 315 
     | 
    
         
            +
              default_scope { where(title: "Untitled") }
         
     | 
| 
      
 316 
     | 
    
         
            +
            end
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
            class SubConditionalStiPost < ConditionalStiPost
         
     | 
| 
      
 319 
     | 
    
         
            +
            end
         
     | 
| 
      
 320 
     | 
    
         
            +
             
     | 
| 
      
 321 
     | 
    
         
            +
            class FakeKlass
         
     | 
| 
      
 322 
     | 
    
         
            +
              extend ActiveRecord::Delegation::DelegateCache
         
     | 
| 
      
 323 
     | 
    
         
            +
             
     | 
| 
      
 324 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 325 
     | 
    
         
            +
                def connection
         
     | 
| 
      
 326 
     | 
    
         
            +
                  Post.connection
         
     | 
| 
      
 327 
     | 
    
         
            +
                end
         
     | 
| 
      
 328 
     | 
    
         
            +
             
     | 
| 
      
 329 
     | 
    
         
            +
                def table_name
         
     | 
| 
      
 330 
     | 
    
         
            +
                  "posts"
         
     | 
| 
      
 331 
     | 
    
         
            +
                end
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
                def attribute_aliases
         
     | 
| 
      
 334 
     | 
    
         
            +
                  {}
         
     | 
| 
      
 335 
     | 
    
         
            +
                end
         
     | 
| 
      
 336 
     | 
    
         
            +
             
     | 
| 
      
 337 
     | 
    
         
            +
                def sanitize_sql(sql)
         
     | 
| 
      
 338 
     | 
    
         
            +
                  sql
         
     | 
| 
      
 339 
     | 
    
         
            +
                end
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
                def sanitize_sql_for_order(sql)
         
     | 
| 
      
 342 
     | 
    
         
            +
                  sql
         
     | 
| 
      
 343 
     | 
    
         
            +
                end
         
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
      
 345 
     | 
    
         
            +
                def disallow_raw_sql!(*args)
         
     | 
| 
      
 346 
     | 
    
         
            +
                  # noop
         
     | 
| 
      
 347 
     | 
    
         
            +
                end
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
                def columns_hash
         
     | 
| 
      
 350 
     | 
    
         
            +
                  { "name" => nil }
         
     | 
| 
      
 351 
     | 
    
         
            +
                end
         
     | 
| 
      
 352 
     | 
    
         
            +
             
     | 
| 
      
 353 
     | 
    
         
            +
                def arel_table
         
     | 
| 
      
 354 
     | 
    
         
            +
                  Post.arel_table
         
     | 
| 
      
 355 
     | 
    
         
            +
                end
         
     | 
| 
      
 356 
     | 
    
         
            +
             
     | 
| 
      
 357 
     | 
    
         
            +
                def predicate_builder
         
     | 
| 
      
 358 
     | 
    
         
            +
                  Post.predicate_builder
         
     | 
| 
      
 359 
     | 
    
         
            +
                end
         
     | 
| 
      
 360 
     | 
    
         
            +
             
     | 
| 
      
 361 
     | 
    
         
            +
                def finder_needs_type_condition?
         
     | 
| 
      
 362 
     | 
    
         
            +
                  false
         
     | 
| 
      
 363 
     | 
    
         
            +
                end
         
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
      
 365 
     | 
    
         
            +
                def base_class?
         
     | 
| 
      
 366 
     | 
    
         
            +
                  true
         
     | 
| 
      
 367 
     | 
    
         
            +
                end
         
     | 
| 
      
 368 
     | 
    
         
            +
              end
         
     | 
| 
      
 369 
     | 
    
         
            +
             
     | 
| 
      
 370 
     | 
    
         
            +
              inherited self
         
     | 
| 
      
 371 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class PriceEstimate < ActiveRecord::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
              include ActiveSupport::NumberHelper
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              belongs_to :estimate_of, polymorphic: true
         
     | 
| 
      
 7 
     | 
    
         
            +
              belongs_to :thing, polymorphic: true
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              validates_numericality_of :price
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              def price
         
     | 
| 
      
 12 
     | 
    
         
            +
                number_to_currency super
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     |