sequel 5.28.0 → 5.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +64 -1922
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/doc/advanced_associations.rdoc +4 -4
- data/doc/association_basics.rdoc +3 -3
- data/doc/code_order.rdoc +12 -2
- data/doc/model_dataset_method_design.rdoc +1 -1
- data/doc/postgresql.rdoc +71 -0
- data/doc/release_notes/5.29.0.txt +22 -0
- data/doc/release_notes/5.30.0.txt +20 -0
- data/doc/release_notes/5.31.0.txt +148 -0
- data/doc/release_notes/5.32.0.txt +46 -0
- data/doc/release_notes/5.33.0.txt +24 -0
- data/doc/testing.rdoc +1 -1
- data/lib/sequel/adapters/postgres.rb +5 -1
- data/lib/sequel/adapters/shared/access.rb +6 -6
- data/lib/sequel/adapters/shared/mssql.rb +5 -5
- data/lib/sequel/adapters/shared/mysql.rb +10 -10
- data/lib/sequel/adapters/shared/oracle.rb +16 -16
- data/lib/sequel/adapters/shared/postgres.rb +169 -14
- data/lib/sequel/adapters/shared/sqlanywhere.rb +9 -9
- data/lib/sequel/adapters/shared/sqlite.rb +32 -5
- data/lib/sequel/adapters/tinytds.rb +1 -1
- data/lib/sequel/connection_pool/sharded_threaded.rb +2 -2
- data/lib/sequel/connection_pool/threaded.rb +1 -1
- data/lib/sequel/core.rb +318 -314
- data/lib/sequel/database/query.rb +1 -1
- data/lib/sequel/database/schema_generator.rb +1 -1
- data/lib/sequel/database/transactions.rb +8 -12
- data/lib/sequel/dataset/misc.rb +2 -2
- data/lib/sequel/extensions/connection_expiration.rb +2 -2
- data/lib/sequel/extensions/connection_validator.rb +2 -2
- data/lib/sequel/extensions/fiber_concurrency.rb +24 -0
- data/lib/sequel/extensions/index_caching.rb +9 -7
- data/lib/sequel/extensions/integer64.rb +2 -0
- data/lib/sequel/extensions/migration.rb +1 -1
- data/lib/sequel/extensions/pg_enum.rb +5 -2
- data/lib/sequel/extensions/pg_hstore.rb +6 -0
- data/lib/sequel/extensions/pg_inet.rb +13 -5
- data/lib/sequel/extensions/pg_interval.rb +2 -0
- data/lib/sequel/extensions/pg_range.rb +2 -0
- data/lib/sequel/extensions/pg_timestamptz.rb +2 -0
- data/lib/sequel/extensions/run_transaction_hooks.rb +72 -0
- data/lib/sequel/extensions/schema_dumper.rb +10 -4
- data/lib/sequel/extensions/server_block.rb +3 -3
- data/lib/sequel/model/associations.rb +18 -5
- data/lib/sequel/model/base.rb +60 -53
- data/lib/sequel/model/plugins.rb +1 -0
- data/lib/sequel/plugins/association_lazy_eager_option.rb +66 -0
- data/lib/sequel/plugins/association_multi_add_remove.rb +2 -0
- data/lib/sequel/plugins/association_proxies.rb +2 -0
- data/lib/sequel/plugins/boolean_subsets.rb +4 -1
- data/lib/sequel/plugins/class_table_inheritance.rb +26 -26
- data/lib/sequel/plugins/dirty.rb +13 -13
- data/lib/sequel/plugins/empty_failure_backtraces.rb +38 -0
- data/lib/sequel/plugins/forbid_lazy_load.rb +214 -0
- data/lib/sequel/plugins/json_serializer.rb +18 -11
- data/lib/sequel/plugins/single_table_inheritance.rb +15 -15
- data/lib/sequel/plugins/skip_saving_columns.rb +108 -0
- data/lib/sequel/plugins/subclasses.rb +2 -0
- data/lib/sequel/plugins/throw_failures.rb +1 -1
- data/lib/sequel/timezones.rb +6 -4
- data/lib/sequel/version.rb +1 -1
- metadata +18 -367
- data/Rakefile +0 -151
- data/doc/release_notes/4.0.0.txt +0 -262
- data/doc/release_notes/4.1.0.txt +0 -85
- data/doc/release_notes/4.10.0.txt +0 -226
- data/doc/release_notes/4.11.0.txt +0 -147
- data/doc/release_notes/4.12.0.txt +0 -105
- data/doc/release_notes/4.13.0.txt +0 -169
- data/doc/release_notes/4.14.0.txt +0 -68
- data/doc/release_notes/4.15.0.txt +0 -56
- data/doc/release_notes/4.16.0.txt +0 -36
- data/doc/release_notes/4.17.0.txt +0 -38
- data/doc/release_notes/4.18.0.txt +0 -36
- data/doc/release_notes/4.19.0.txt +0 -45
- data/doc/release_notes/4.2.0.txt +0 -129
- data/doc/release_notes/4.20.0.txt +0 -79
- data/doc/release_notes/4.21.0.txt +0 -94
- data/doc/release_notes/4.22.0.txt +0 -72
- data/doc/release_notes/4.23.0.txt +0 -65
- data/doc/release_notes/4.24.0.txt +0 -99
- data/doc/release_notes/4.25.0.txt +0 -181
- data/doc/release_notes/4.26.0.txt +0 -44
- data/doc/release_notes/4.27.0.txt +0 -78
- data/doc/release_notes/4.28.0.txt +0 -57
- data/doc/release_notes/4.29.0.txt +0 -41
- data/doc/release_notes/4.3.0.txt +0 -40
- data/doc/release_notes/4.30.0.txt +0 -37
- data/doc/release_notes/4.31.0.txt +0 -57
- data/doc/release_notes/4.32.0.txt +0 -132
- data/doc/release_notes/4.33.0.txt +0 -88
- data/doc/release_notes/4.34.0.txt +0 -86
- data/doc/release_notes/4.35.0.txt +0 -130
- data/doc/release_notes/4.36.0.txt +0 -116
- data/doc/release_notes/4.37.0.txt +0 -50
- data/doc/release_notes/4.38.0.txt +0 -67
- data/doc/release_notes/4.39.0.txt +0 -127
- data/doc/release_notes/4.4.0.txt +0 -92
- data/doc/release_notes/4.40.0.txt +0 -179
- data/doc/release_notes/4.41.0.txt +0 -77
- data/doc/release_notes/4.42.0.txt +0 -221
- data/doc/release_notes/4.43.0.txt +0 -87
- data/doc/release_notes/4.44.0.txt +0 -125
- data/doc/release_notes/4.45.0.txt +0 -370
- data/doc/release_notes/4.46.0.txt +0 -404
- data/doc/release_notes/4.47.0.txt +0 -56
- data/doc/release_notes/4.48.0.txt +0 -293
- data/doc/release_notes/4.49.0.txt +0 -222
- data/doc/release_notes/4.5.0.txt +0 -34
- data/doc/release_notes/4.6.0.txt +0 -30
- data/doc/release_notes/4.7.0.txt +0 -103
- data/doc/release_notes/4.8.0.txt +0 -175
- data/doc/release_notes/4.9.0.txt +0 -190
- data/spec/adapter_spec.rb +0 -4
- data/spec/adapters/db2_spec.rb +0 -170
- data/spec/adapters/mssql_spec.rb +0 -828
- data/spec/adapters/mysql_spec.rb +0 -1060
- data/spec/adapters/oracle_spec.rb +0 -371
- data/spec/adapters/postgres_spec.rb +0 -4476
- data/spec/adapters/spec_helper.rb +0 -44
- data/spec/adapters/sqlanywhere_spec.rb +0 -97
- data/spec/adapters/sqlite_spec.rb +0 -652
- data/spec/bin_spec.rb +0 -278
- data/spec/core/connection_pool_spec.rb +0 -1250
- data/spec/core/database_spec.rb +0 -2915
- data/spec/core/dataset_spec.rb +0 -5547
- data/spec/core/deprecated_spec.rb +0 -70
- data/spec/core/expression_filters_spec.rb +0 -1498
- data/spec/core/mock_adapter_spec.rb +0 -722
- data/spec/core/object_graph_spec.rb +0 -336
- data/spec/core/placeholder_literalizer_spec.rb +0 -166
- data/spec/core/schema_generator_spec.rb +0 -214
- data/spec/core/schema_spec.rb +0 -1844
- data/spec/core/spec_helper.rb +0 -24
- data/spec/core/version_spec.rb +0 -14
- data/spec/core_extensions_spec.rb +0 -763
- data/spec/core_model_spec.rb +0 -2
- data/spec/core_spec.rb +0 -1
- data/spec/deprecation_helper.rb +0 -30
- data/spec/extensions/accessed_columns_spec.rb +0 -51
- data/spec/extensions/active_model_spec.rb +0 -99
- data/spec/extensions/after_initialize_spec.rb +0 -28
- data/spec/extensions/any_not_empty_spec.rb +0 -23
- data/spec/extensions/arbitrary_servers_spec.rb +0 -109
- data/spec/extensions/association_dependencies_spec.rb +0 -125
- data/spec/extensions/association_multi_add_remove_spec.rb +0 -1041
- data/spec/extensions/association_pks_spec.rb +0 -423
- data/spec/extensions/association_proxies_spec.rb +0 -100
- data/spec/extensions/auto_literal_strings_spec.rb +0 -205
- data/spec/extensions/auto_validations_spec.rb +0 -229
- data/spec/extensions/blacklist_security_spec.rb +0 -95
- data/spec/extensions/blank_spec.rb +0 -69
- data/spec/extensions/boolean_readers_spec.rb +0 -93
- data/spec/extensions/boolean_subsets_spec.rb +0 -47
- data/spec/extensions/caching_spec.rb +0 -273
- data/spec/extensions/caller_logging_spec.rb +0 -52
- data/spec/extensions/class_table_inheritance_spec.rb +0 -750
- data/spec/extensions/column_conflicts_spec.rb +0 -75
- data/spec/extensions/column_select_spec.rb +0 -129
- data/spec/extensions/columns_introspection_spec.rb +0 -90
- data/spec/extensions/columns_updated_spec.rb +0 -35
- data/spec/extensions/composition_spec.rb +0 -248
- data/spec/extensions/connection_expiration_spec.rb +0 -151
- data/spec/extensions/connection_validator_spec.rb +0 -144
- data/spec/extensions/constant_sql_override_spec.rb +0 -24
- data/spec/extensions/constraint_validations_plugin_spec.rb +0 -300
- data/spec/extensions/constraint_validations_spec.rb +0 -439
- data/spec/extensions/core_refinements_spec.rb +0 -528
- data/spec/extensions/csv_serializer_spec.rb +0 -183
- data/spec/extensions/current_datetime_timestamp_spec.rb +0 -27
- data/spec/extensions/dataset_associations_spec.rb +0 -365
- data/spec/extensions/dataset_source_alias_spec.rb +0 -51
- data/spec/extensions/date_arithmetic_spec.rb +0 -181
- data/spec/extensions/datetime_parse_to_time_spec.rb +0 -169
- data/spec/extensions/def_dataset_method_spec.rb +0 -100
- data/spec/extensions/defaults_setter_spec.rb +0 -150
- data/spec/extensions/delay_add_association_spec.rb +0 -73
- data/spec/extensions/dirty_spec.rb +0 -222
- data/spec/extensions/duplicate_columns_handler_spec.rb +0 -104
- data/spec/extensions/eager_each_spec.rb +0 -62
- data/spec/extensions/eager_graph_eager_spec.rb +0 -100
- data/spec/extensions/empty_array_consider_nulls_spec.rb +0 -24
- data/spec/extensions/error_splitter_spec.rb +0 -18
- data/spec/extensions/error_sql_spec.rb +0 -20
- data/spec/extensions/escaped_like_spec.rb +0 -40
- data/spec/extensions/eval_inspect_spec.rb +0 -81
- data/spec/extensions/exclude_or_null_spec.rb +0 -15
- data/spec/extensions/finder_spec.rb +0 -260
- data/spec/extensions/force_encoding_spec.rb +0 -126
- data/spec/extensions/freeze_datasets_spec.rb +0 -31
- data/spec/extensions/graph_each_spec.rb +0 -113
- data/spec/extensions/hook_class_methods_spec.rb +0 -402
- data/spec/extensions/identifier_mangling_spec.rb +0 -201
- data/spec/extensions/implicit_subquery_spec.rb +0 -58
- data/spec/extensions/index_caching_spec.rb +0 -66
- data/spec/extensions/inflector_spec.rb +0 -183
- data/spec/extensions/input_transformer_spec.rb +0 -69
- data/spec/extensions/insert_conflict_spec.rb +0 -103
- data/spec/extensions/insert_returning_select_spec.rb +0 -72
- data/spec/extensions/instance_filters_spec.rb +0 -79
- data/spec/extensions/instance_hooks_spec.rb +0 -246
- data/spec/extensions/integer64_spec.rb +0 -22
- data/spec/extensions/inverted_subsets_spec.rb +0 -33
- data/spec/extensions/json_serializer_spec.rb +0 -336
- data/spec/extensions/lazy_attributes_spec.rb +0 -183
- data/spec/extensions/list_spec.rb +0 -291
- data/spec/extensions/looser_typecasting_spec.rb +0 -43
- data/spec/extensions/many_through_many_spec.rb +0 -2177
- data/spec/extensions/migration_spec.rb +0 -864
- data/spec/extensions/modification_detection_spec.rb +0 -93
- data/spec/extensions/mssql_optimistic_locking_spec.rb +0 -92
- data/spec/extensions/named_timezones_spec.rb +0 -218
- data/spec/extensions/nested_attributes_spec.rb +0 -815
- data/spec/extensions/null_dataset_spec.rb +0 -85
- data/spec/extensions/optimistic_locking_spec.rb +0 -127
- data/spec/extensions/pagination_spec.rb +0 -116
- data/spec/extensions/pg_array_associations_spec.rb +0 -802
- data/spec/extensions/pg_array_ops_spec.rb +0 -144
- data/spec/extensions/pg_array_spec.rb +0 -398
- data/spec/extensions/pg_auto_constraint_validations_spec.rb +0 -209
- data/spec/extensions/pg_enum_spec.rb +0 -118
- data/spec/extensions/pg_extended_date_support_spec.rb +0 -126
- data/spec/extensions/pg_hstore_ops_spec.rb +0 -238
- data/spec/extensions/pg_hstore_spec.rb +0 -219
- data/spec/extensions/pg_inet_ops_spec.rb +0 -102
- data/spec/extensions/pg_inet_spec.rb +0 -72
- data/spec/extensions/pg_interval_spec.rb +0 -103
- data/spec/extensions/pg_json_ops_spec.rb +0 -356
- data/spec/extensions/pg_json_spec.rb +0 -451
- data/spec/extensions/pg_loose_count_spec.rb +0 -23
- data/spec/extensions/pg_range_ops_spec.rb +0 -60
- data/spec/extensions/pg_range_spec.rb +0 -600
- data/spec/extensions/pg_row_ops_spec.rb +0 -61
- data/spec/extensions/pg_row_plugin_spec.rb +0 -60
- data/spec/extensions/pg_row_spec.rb +0 -363
- data/spec/extensions/pg_static_cache_updater_spec.rb +0 -93
- data/spec/extensions/pg_timestamptz_spec.rb +0 -17
- data/spec/extensions/prepared_statements_safe_spec.rb +0 -66
- data/spec/extensions/prepared_statements_spec.rb +0 -177
- data/spec/extensions/pretty_table_spec.rb +0 -123
- data/spec/extensions/query_spec.rb +0 -94
- data/spec/extensions/rcte_tree_spec.rb +0 -387
- data/spec/extensions/round_timestamps_spec.rb +0 -39
- data/spec/extensions/s_spec.rb +0 -60
- data/spec/extensions/schema_caching_spec.rb +0 -64
- data/spec/extensions/schema_dumper_spec.rb +0 -870
- data/spec/extensions/select_remove_spec.rb +0 -38
- data/spec/extensions/sequel_4_dataset_methods_spec.rb +0 -121
- data/spec/extensions/serialization_modification_detection_spec.rb +0 -98
- data/spec/extensions/serialization_spec.rb +0 -365
- data/spec/extensions/server_block_spec.rb +0 -135
- data/spec/extensions/server_logging_spec.rb +0 -45
- data/spec/extensions/sharding_spec.rb +0 -197
- data/spec/extensions/shared_caching_spec.rb +0 -151
- data/spec/extensions/single_table_inheritance_spec.rb +0 -347
- data/spec/extensions/singular_table_names_spec.rb +0 -22
- data/spec/extensions/skip_create_refresh_spec.rb +0 -18
- data/spec/extensions/spec_helper.rb +0 -70
- data/spec/extensions/split_array_nil_spec.rb +0 -24
- data/spec/extensions/split_values_spec.rb +0 -57
- data/spec/extensions/sql_comments_spec.rb +0 -33
- data/spec/extensions/sql_expr_spec.rb +0 -59
- data/spec/extensions/static_cache_cache_spec.rb +0 -35
- data/spec/extensions/static_cache_spec.rb +0 -471
- data/spec/extensions/string_agg_spec.rb +0 -90
- data/spec/extensions/string_date_time_spec.rb +0 -95
- data/spec/extensions/string_stripper_spec.rb +0 -68
- data/spec/extensions/subclasses_spec.rb +0 -79
- data/spec/extensions/subset_conditions_spec.rb +0 -38
- data/spec/extensions/symbol_aref_refinement_spec.rb +0 -28
- data/spec/extensions/symbol_as_refinement_spec.rb +0 -21
- data/spec/extensions/synchronize_sql_spec.rb +0 -124
- data/spec/extensions/table_select_spec.rb +0 -83
- data/spec/extensions/tactical_eager_loading_spec.rb +0 -402
- data/spec/extensions/thread_local_timezones_spec.rb +0 -67
- data/spec/extensions/throw_failures_spec.rb +0 -74
- data/spec/extensions/timestamps_spec.rb +0 -209
- data/spec/extensions/to_dot_spec.rb +0 -153
- data/spec/extensions/touch_spec.rb +0 -226
- data/spec/extensions/tree_spec.rb +0 -334
- data/spec/extensions/typecast_on_load_spec.rb +0 -86
- data/spec/extensions/unlimited_update_spec.rb +0 -21
- data/spec/extensions/update_or_create_spec.rb +0 -83
- data/spec/extensions/update_primary_key_spec.rb +0 -105
- data/spec/extensions/update_refresh_spec.rb +0 -59
- data/spec/extensions/uuid_spec.rb +0 -101
- data/spec/extensions/validate_associated_spec.rb +0 -52
- data/spec/extensions/validation_class_methods_spec.rb +0 -1040
- data/spec/extensions/validation_contexts_spec.rb +0 -31
- data/spec/extensions/validation_helpers_spec.rb +0 -525
- data/spec/extensions/whitelist_security_spec.rb +0 -157
- data/spec/extensions/xml_serializer_spec.rb +0 -213
- data/spec/files/bad_down_migration/001_create_alt_basic.rb +0 -4
- data/spec/files/bad_down_migration/002_create_alt_advanced.rb +0 -4
- data/spec/files/bad_timestamped_migrations/1273253849_create_sessions.rb +0 -9
- data/spec/files/bad_timestamped_migrations/1273253851_create_nodes.rb +0 -9
- data/spec/files/bad_timestamped_migrations/1273253853_3_create_users.rb +0 -3
- data/spec/files/bad_up_migration/001_create_alt_basic.rb +0 -4
- data/spec/files/bad_up_migration/002_create_alt_advanced.rb +0 -3
- data/spec/files/convert_to_timestamp_migrations/001_create_sessions.rb +0 -9
- data/spec/files/convert_to_timestamp_migrations/002_create_nodes.rb +0 -9
- data/spec/files/convert_to_timestamp_migrations/003_3_create_users.rb +0 -4
- data/spec/files/convert_to_timestamp_migrations/1273253850_create_artists.rb +0 -9
- data/spec/files/convert_to_timestamp_migrations/1273253852_create_albums.rb +0 -9
- data/spec/files/double_migration/001_create_sessions.rb +0 -9
- data/spec/files/double_migration/002_create_nodes.rb +0 -19
- data/spec/files/double_migration/003_3_create_users.rb +0 -4
- data/spec/files/duplicate_integer_migrations/001_create_alt_advanced.rb +0 -4
- data/spec/files/duplicate_integer_migrations/001_create_alt_basic.rb +0 -4
- data/spec/files/duplicate_timestamped_migrations/1273253849_create_sessions.rb +0 -9
- data/spec/files/duplicate_timestamped_migrations/1273253853_create_nodes.rb +0 -9
- data/spec/files/duplicate_timestamped_migrations/1273253853_create_users.rb +0 -4
- data/spec/files/empty_migration/001_create_sessions.rb +0 -9
- data/spec/files/empty_migration/002_create_nodes.rb +0 -0
- data/spec/files/empty_migration/003_3_create_users.rb +0 -4
- data/spec/files/integer_migrations/001_create_sessions.rb +0 -9
- data/spec/files/integer_migrations/002_create_nodes.rb +0 -9
- data/spec/files/integer_migrations/003_3_create_users.rb +0 -4
- data/spec/files/interleaved_timestamped_migrations/1273253849_create_sessions.rb +0 -9
- data/spec/files/interleaved_timestamped_migrations/1273253850_create_artists.rb +0 -9
- data/spec/files/interleaved_timestamped_migrations/1273253851_create_nodes.rb +0 -9
- data/spec/files/interleaved_timestamped_migrations/1273253852_create_albums.rb +0 -9
- data/spec/files/interleaved_timestamped_migrations/1273253853_3_create_users.rb +0 -4
- data/spec/files/missing_integer_migrations/001_create_alt_basic.rb +0 -4
- data/spec/files/missing_integer_migrations/003_create_alt_advanced.rb +0 -4
- data/spec/files/missing_timestamped_migrations/1273253849_create_sessions.rb +0 -9
- data/spec/files/missing_timestamped_migrations/1273253853_3_create_users.rb +0 -4
- data/spec/files/reversible_migrations/001_reversible.rb +0 -5
- data/spec/files/reversible_migrations/002_reversible.rb +0 -5
- data/spec/files/reversible_migrations/003_reversible.rb +0 -5
- data/spec/files/reversible_migrations/004_reversible.rb +0 -5
- data/spec/files/reversible_migrations/005_reversible.rb +0 -10
- data/spec/files/reversible_migrations/006_reversible.rb +0 -10
- data/spec/files/reversible_migrations/007_reversible.rb +0 -10
- data/spec/files/timestamped_migrations/1273253849_create_sessions.rb +0 -9
- data/spec/files/timestamped_migrations/1273253851_create_nodes.rb +0 -9
- data/spec/files/timestamped_migrations/1273253853_3_create_users.rb +0 -4
- data/spec/files/transaction_specified_migrations/001_create_alt_basic.rb +0 -4
- data/spec/files/transaction_specified_migrations/002_create_basic.rb +0 -4
- data/spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb +0 -3
- data/spec/files/transaction_unspecified_migrations/002_create_basic.rb +0 -3
- data/spec/files/uppercase_timestamped_migrations/1273253849_CREATE_SESSIONS.RB +0 -9
- data/spec/files/uppercase_timestamped_migrations/1273253851_CREATE_NODES.RB +0 -9
- data/spec/files/uppercase_timestamped_migrations/1273253853_3_CREATE_USERS.RB +0 -4
- data/spec/guards_helper.rb +0 -59
- data/spec/integration/associations_test.rb +0 -2597
- data/spec/integration/database_test.rb +0 -113
- data/spec/integration/dataset_test.rb +0 -2037
- data/spec/integration/eager_loader_test.rb +0 -687
- data/spec/integration/migrator_test.rb +0 -262
- data/spec/integration/model_test.rb +0 -203
- data/spec/integration/plugin_test.rb +0 -2423
- data/spec/integration/prepared_statement_test.rb +0 -405
- data/spec/integration/schema_test.rb +0 -903
- data/spec/integration/spec_helper.rb +0 -71
- data/spec/integration/timezone_test.rb +0 -86
- data/spec/integration/transaction_test.rb +0 -603
- data/spec/integration/type_test.rb +0 -127
- data/spec/model/association_reflection_spec.rb +0 -803
- data/spec/model/associations_spec.rb +0 -4738
- data/spec/model/base_spec.rb +0 -875
- data/spec/model/class_dataset_methods_spec.rb +0 -146
- data/spec/model/dataset_methods_spec.rb +0 -198
- data/spec/model/eager_loading_spec.rb +0 -2377
- data/spec/model/hooks_spec.rb +0 -370
- data/spec/model/inflector_spec.rb +0 -26
- data/spec/model/model_spec.rb +0 -956
- data/spec/model/plugins_spec.rb +0 -429
- data/spec/model/record_spec.rb +0 -2118
- data/spec/model/spec_helper.rb +0 -46
- data/spec/model/validations_spec.rb +0 -220
- data/spec/model_no_assoc_spec.rb +0 -1
- data/spec/model_spec.rb +0 -1
- data/spec/plugin_spec.rb +0 -1
- data/spec/sequel_coverage.rb +0 -15
- data/spec/sequel_warning.rb +0 -4
- data/spec/spec_config.rb +0 -12
@@ -325,7 +325,7 @@ module Sequel
|
|
325
325
|
:integer
|
326
326
|
when /\Adate\z/io
|
327
327
|
:date
|
328
|
-
when /\A((small)?datetime|timestamp( with(out)? time zone)?)
|
328
|
+
when /\A((small)?datetime|timestamp(\(\d\))?( with(out)? time zone)?)\z/io
|
329
329
|
:datetime
|
330
330
|
when /\Atime( with(out)? time zone)?\z/io
|
331
331
|
:time
|
@@ -126,7 +126,7 @@ module Sequel
|
|
126
126
|
# :on_update :: Specify the behavior of this column when being updated
|
127
127
|
# (:restrict, :cascade, :set_null, :set_default, :no_action).
|
128
128
|
# :primary_key :: Make the column as a single primary key column. This should not
|
129
|
-
# be used if you
|
129
|
+
# be used if you want a single autoincrementing primary key column
|
130
130
|
# (use the primary_key method in that case).
|
131
131
|
# :primary_key_constraint_name :: The name to give the primary key constraint
|
132
132
|
# :primary_key_deferrable :: Similar to :deferrable, but for the primary key constraint
|
@@ -142,7 +142,7 @@ module Sequel
|
|
142
142
|
# :num_retries :: The number of times to retry if the :retry_on option is used.
|
143
143
|
# The default is 5 times. Can be set to nil to retry indefinitely,
|
144
144
|
# but that is not recommended.
|
145
|
-
# :before_retry :: Proc to execute before
|
145
|
+
# :before_retry :: Proc to execute before retrying if the :retry_on option is used.
|
146
146
|
# Called with two arguments: the number of retry attempts (counting
|
147
147
|
# the current one) and the error the last attempt failed with.
|
148
148
|
# :prepare :: A string to use as the transaction identifier for a
|
@@ -178,19 +178,15 @@ module Sequel
|
|
178
178
|
opts = Hash[opts]
|
179
179
|
if retry_on = opts[:retry_on]
|
180
180
|
tot_retries = opts.fetch(:num_retries, 5)
|
181
|
-
num_retries = 0
|
181
|
+
num_retries = 0
|
182
182
|
begin
|
183
183
|
opts[:retry_on] = nil
|
184
184
|
opts[:retrying] = true
|
185
185
|
transaction(opts, &block)
|
186
186
|
rescue *retry_on => e
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
opts[:before_retry].call(num_retries, e) if opts[:before_retry]
|
191
|
-
retry
|
192
|
-
end
|
193
|
-
else
|
187
|
+
num_retries += 1
|
188
|
+
if tot_retries.nil? || num_retries <= tot_retries
|
189
|
+
opts[:before_retry].call(num_retries, e) if opts[:before_retry]
|
194
190
|
retry
|
195
191
|
end
|
196
192
|
raise
|
@@ -439,13 +435,12 @@ module Sequel
|
|
439
435
|
|
440
436
|
# Remove the current thread from the list of active transactions
|
441
437
|
def remove_transaction(conn, committed)
|
438
|
+
callbacks = transaction_hooks(conn, committed)
|
442
439
|
if in_savepoint?(conn)
|
443
440
|
savepoint_callbacks = savepoint_hooks(conn, committed)
|
444
441
|
if committed
|
445
442
|
savepoint_rollback_callbacks = savepoint_hooks(conn, false)
|
446
443
|
end
|
447
|
-
else
|
448
|
-
callbacks = transaction_hooks(conn, committed)
|
449
444
|
end
|
450
445
|
|
451
446
|
if transaction_finished?(conn)
|
@@ -453,7 +448,6 @@ module Sequel
|
|
453
448
|
rolled_back = !committed
|
454
449
|
Sequel.synchronize{h[:rolled_back] = rolled_back}
|
455
450
|
Sequel.synchronize{@transactions.delete(conn)}
|
456
|
-
callbacks.each(&:call) if callbacks
|
457
451
|
elsif savepoint_callbacks || savepoint_rollback_callbacks
|
458
452
|
if committed
|
459
453
|
meth = in_savepoint?(conn) ? :add_savepoint_hook : :add_transaction_hook
|
@@ -473,6 +467,8 @@ module Sequel
|
|
473
467
|
savepoint_callbacks.each(&:call)
|
474
468
|
end
|
475
469
|
end
|
470
|
+
|
471
|
+
callbacks.each(&:call) if callbacks
|
476
472
|
end
|
477
473
|
|
478
474
|
# SQL to rollback to a savepoint
|
data/lib/sequel/dataset/misc.rb
CHANGED
@@ -329,7 +329,7 @@ module Sequel
|
|
329
329
|
end
|
330
330
|
|
331
331
|
# Set the db, opts, and cache for the copy of the dataset.
|
332
|
-
def
|
332
|
+
def initialize_clone(c, _=nil)
|
333
333
|
@db = c.db
|
334
334
|
@opts = Hash[c.opts]
|
335
335
|
if cols = c.cache_get(:_columns)
|
@@ -338,7 +338,7 @@ module Sequel
|
|
338
338
|
@cache = {}
|
339
339
|
end
|
340
340
|
end
|
341
|
-
alias initialize_clone
|
341
|
+
alias initialize_copy initialize_clone
|
342
342
|
|
343
343
|
# Internal recursive version of unqualified_column_for, handling Strings inside
|
344
344
|
# of other objects.
|
@@ -80,9 +80,9 @@ module Sequel
|
|
80
80
|
Sequel.elapsed_seconds_since(cet[0]) > cet[1]
|
81
81
|
|
82
82
|
if pool_type == :sharded_threaded
|
83
|
-
sync{allocated(a.last).delete(
|
83
|
+
sync{allocated(a.last).delete(Sequel.current)}
|
84
84
|
else
|
85
|
-
sync{@allocated.delete(
|
85
|
+
sync{@allocated.delete(Sequel.current)}
|
86
86
|
end
|
87
87
|
|
88
88
|
disconnect_connection(conn)
|
@@ -104,9 +104,9 @@ module Sequel
|
|
104
104
|
!db.valid_connection?(conn)
|
105
105
|
|
106
106
|
if pool_type == :sharded_threaded
|
107
|
-
sync{allocated(a.last).delete(
|
107
|
+
sync{allocated(a.last).delete(Sequel.current)}
|
108
108
|
else
|
109
|
-
sync{@allocated.delete(
|
109
|
+
sync{@allocated.delete(Sequel.current)}
|
110
110
|
end
|
111
111
|
|
112
112
|
disconnect_connection(conn)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
3
|
+
# The fiber_concurrency extension changes the default concurrency
|
4
|
+
# primitive in Sequel to be Fiber.current instead of Thread.current.
|
5
|
+
# This is the value used in various hash keys to implement safe
|
6
|
+
# concurrency (thread-safe concurrency by default, fiber-safe
|
7
|
+
# concurrency with this extension. It can be enabled via:
|
8
|
+
#
|
9
|
+
# Sequel.extension :fiber_concurrency
|
10
|
+
#
|
11
|
+
# Related module: Sequel::FiberConcurrency
|
12
|
+
|
13
|
+
require 'fiber'
|
14
|
+
|
15
|
+
module Sequel
|
16
|
+
module FiberConcurrency
|
17
|
+
# Make the current concurrency primitive be Fiber.current.
|
18
|
+
def current
|
19
|
+
Fiber.current
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
extend FiberConcurrency
|
24
|
+
end
|
@@ -54,13 +54,6 @@ module Sequel
|
|
54
54
|
db.instance_variable_set(:@indexes, {})
|
55
55
|
end
|
56
56
|
|
57
|
-
# Remove the index cache for the given schema name
|
58
|
-
def remove_cached_schema(table)
|
59
|
-
k = quote_schema_table(table)
|
60
|
-
Sequel.synchronize{@indexes.delete(k)}
|
61
|
-
super
|
62
|
-
end
|
63
|
-
|
64
57
|
# Dump the index cache to the filename given in Marshal format.
|
65
58
|
def dump_index_cache(file)
|
66
59
|
File.open(file, 'wb'){|f| f.write(Marshal.dump(@indexes))}
|
@@ -101,6 +94,15 @@ module Sequel
|
|
101
94
|
Sequel.synchronize{@indexes[quoted_name] = result}
|
102
95
|
result
|
103
96
|
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# Remove the index cache for the given schema name
|
101
|
+
def remove_cached_schema(table)
|
102
|
+
k = quote_schema_table(table)
|
103
|
+
Sequel.synchronize{@indexes.delete(k)}
|
104
|
+
super
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
Database.register_extension(:index_caching, IndexCaching)
|
@@ -176,7 +176,7 @@ module Sequel
|
|
176
176
|
just_raise = true
|
177
177
|
end
|
178
178
|
if just_raise
|
179
|
-
Proc.new{raise Sequel::Error,
|
179
|
+
Proc.new{raise Sequel::Error, "irreversible migration method used in #{block.source_location.first}, you may need to write your own down method"}
|
180
180
|
else
|
181
181
|
actions = @actions.reverse
|
182
182
|
Proc.new do
|
@@ -40,8 +40,11 @@
|
|
40
40
|
# DB.schema(:table_name)
|
41
41
|
# [[:column_name, {:type=>:enum, :enum_values=>['value1', 'value2']}]]
|
42
42
|
#
|
43
|
-
#
|
44
|
-
#
|
43
|
+
# This extension integrates with the pg_array extension. If you plan
|
44
|
+
# to use arrays of enum types, load the pg_array extension before the
|
45
|
+
# pg_interval extension:
|
46
|
+
#
|
47
|
+
# DB.extension :pg_array, :pg_enum
|
45
48
|
#
|
46
49
|
# DB.create_table(:table_name) do
|
47
50
|
# column :column_name, 'enum_type_name[]'
|
@@ -74,6 +74,12 @@
|
|
74
74
|
#
|
75
75
|
# DB.extension :pg_hstore
|
76
76
|
#
|
77
|
+
# This extension integrates with the pg_array extension. If you plan
|
78
|
+
# to use arrays of hstore types, load the pg_array extension before the
|
79
|
+
# pg_interval extension:
|
80
|
+
#
|
81
|
+
# DB.extension :pg_array, :pg_hstore
|
82
|
+
#
|
77
83
|
# See the {schema modification guide}[rdoc-ref:doc/schema_modification.rdoc]
|
78
84
|
# for details on using hstore columns in CREATE/ALTER TABLE statements.
|
79
85
|
#
|
@@ -40,12 +40,20 @@ module Sequel
|
|
40
40
|
def self.extended(db)
|
41
41
|
db.instance_exec do
|
42
42
|
extend_datasets(InetDatasetMethods)
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
|
44
|
+
if !defined?(SEQUEL_PG_VERSION_INTEGER) || SEQUEL_PG_VERSION_INTEGER >= 11300
|
45
|
+
# sequel_pg 1.13.0+ will use inet/cidr conversion procs, but doing so is
|
46
|
+
# slower, so don't add the conversion procs if using sequel_pg 1.13.0+.
|
47
|
+
meth = IPAddr.method(:new)
|
48
|
+
add_conversion_proc(869, meth)
|
49
|
+
add_conversion_proc(650, meth)
|
50
|
+
if respond_to?(:register_array_type)
|
51
|
+
register_array_type('inet', :oid=>1041, :scalar_oid=>869)
|
52
|
+
register_array_type('cidr', :oid=>651, :scalar_oid=>650)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
46
56
|
if respond_to?(:register_array_type)
|
47
|
-
register_array_type('inet', :oid=>1041, :scalar_oid=>869)
|
48
|
-
register_array_type('cidr', :oid=>651, :scalar_oid=>650)
|
49
57
|
register_array_type('macaddr', :oid=>1040, :scalar_oid=>829)
|
50
58
|
end
|
51
59
|
@schema_type_classes[:ipaddr] = IPAddr
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
3
|
+
# The run_transaction_hooks extension allows for running after_commit or
|
4
|
+
# after_rollback extensions before commit or rollback. It then removes
|
5
|
+
# the hook after running it, so it will not be run twice.
|
6
|
+
#
|
7
|
+
# This extension should only be used in transactional tests where the
|
8
|
+
# transaction always rolls back, to test the behavior of the after_commit
|
9
|
+
# and after_rollback hooks. Any other usage is probably a bad idea.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# DB.extension :run_transaction_hooks
|
14
|
+
# x = 1
|
15
|
+
# DB.transaction(rollback: :always) do
|
16
|
+
# DB.after_rollback{x = 3}
|
17
|
+
# DB.after_commit{x = 2}
|
18
|
+
#
|
19
|
+
# x # => 1
|
20
|
+
# DB.run_after_rollback_hooks
|
21
|
+
# x # => 3
|
22
|
+
# DB.run_after_commit_hooks
|
23
|
+
# x # => 2
|
24
|
+
# end
|
25
|
+
# x # => 2
|
26
|
+
|
27
|
+
#
|
28
|
+
class Sequel::Database
|
29
|
+
module RunTransactionHooks
|
30
|
+
# Run all savepoint and transaction after_commit hooks for the current transaction,
|
31
|
+
# and remove the hooks after running them.
|
32
|
+
# Options:
|
33
|
+
# :server :: The server/shard to use.
|
34
|
+
def run_after_commit_hooks(opts=OPTS)
|
35
|
+
_run_transaction_hooks(:after_commit, opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Run all savepoint and transaction after_rollback hooks for the current transaction,
|
39
|
+
# and remove the hooks after running them.
|
40
|
+
# Options:
|
41
|
+
# :server :: The server/shard to use.
|
42
|
+
def run_after_rollback_hooks(opts=OPTS)
|
43
|
+
_run_transaction_hooks(:after_rollback, opts)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def _run_transaction_hooks(type, opts)
|
49
|
+
synchronize(opts[:server]) do |conn|
|
50
|
+
unless h = _trans(conn)
|
51
|
+
raise Error, "Cannot call run_#{type}_hooks outside of a transaction"
|
52
|
+
end
|
53
|
+
|
54
|
+
if hooks = h[type]
|
55
|
+
hooks.each(&:call)
|
56
|
+
hooks.clear
|
57
|
+
end
|
58
|
+
|
59
|
+
if (savepoints = h[:savepoints])
|
60
|
+
savepoints.each do |savepoint|
|
61
|
+
if hooks = savepoint[type]
|
62
|
+
hooks.each(&:call)
|
63
|
+
hooks.clear
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
register_extension(:run_transaction_hooks, RunTransactionHooks)
|
72
|
+
end
|
@@ -199,12 +199,18 @@ END_MIG
|
|
199
199
|
end
|
200
200
|
type = col_opts.delete(:type)
|
201
201
|
col_opts.delete(:size) if col_opts[:size].nil?
|
202
|
-
|
203
|
-
|
202
|
+
if schema[:generated]
|
203
|
+
if options[:same_db] && database_type == :postgres
|
204
|
+
col_opts[:generated_always_as] = column_schema_to_ruby_default_fallback(schema[:default], options)
|
205
|
+
end
|
204
206
|
else
|
205
|
-
schema[:ruby_default]
|
207
|
+
col_opts[:default] = if schema[:ruby_default].nil?
|
208
|
+
column_schema_to_ruby_default_fallback(schema[:default], options)
|
209
|
+
else
|
210
|
+
schema[:ruby_default]
|
211
|
+
end
|
212
|
+
col_opts.delete(:default) if col_opts[:default].nil?
|
206
213
|
end
|
207
|
-
col_opts.delete(:default) if col_opts[:default].nil?
|
208
214
|
col_opts[:null] = false if schema[:allow_null] == false
|
209
215
|
if table = schema[:table]
|
210
216
|
[:key, :on_delete, :on_update, :deferrable].each{|f| col_opts[f] = schema[f] if schema[f]}
|
@@ -143,13 +143,13 @@ module Sequel
|
|
143
143
|
|
144
144
|
# Make the given server the new default server for the current thread.
|
145
145
|
def set_default_server(default_server, read_only_server=default_server)
|
146
|
-
sync{(@default_servers[
|
146
|
+
sync{(@default_servers[Sequel.current] ||= [])} << [default_server, read_only_server]
|
147
147
|
end
|
148
148
|
|
149
149
|
# Remove the current default server for the current thread, restoring the
|
150
150
|
# previous default server.
|
151
151
|
def clear_default_server
|
152
|
-
t =
|
152
|
+
t = Sequel.current
|
153
153
|
a = sync{@default_servers[t]}
|
154
154
|
a.pop
|
155
155
|
sync{@default_servers.delete(t)} if a.empty?
|
@@ -157,7 +157,7 @@ module Sequel
|
|
157
157
|
|
158
158
|
# Use the server given to with_server for the given thread, if appropriate.
|
159
159
|
def pick_server(server)
|
160
|
-
a = sync{@default_servers[
|
160
|
+
a = sync{@default_servers[Sequel.current]}
|
161
161
|
if !a || a.empty?
|
162
162
|
super
|
163
163
|
else
|
@@ -2966,8 +2966,8 @@ module Sequel
|
|
2966
2966
|
# dataset. If that association also has dependent associations, instead of a callable object,
|
2967
2967
|
# use a hash with the callable object being the key, and the dependent association(s) as the value.
|
2968
2968
|
#
|
2969
|
-
# You can specify an alias
|
2970
|
-
# an a Symbol for the
|
2969
|
+
# You can specify an custom alias and/or join type on a per-association basis by providing an
|
2970
|
+
# Sequel::SQL::AliasedExpression object instead of an a Symbol for the association name.
|
2971
2971
|
#
|
2972
2972
|
# Examples:
|
2973
2973
|
#
|
@@ -2983,6 +2983,14 @@ module Sequel
|
|
2983
2983
|
# # FROM albums
|
2984
2984
|
# # LEFT OUTER JOIN artists AS a ON (a.id = albums.artist_id)
|
2985
2985
|
#
|
2986
|
+
# # For each album, eager_graph load the artist, using a specified alias
|
2987
|
+
# # and custom join type
|
2988
|
+
#
|
2989
|
+
# Album.eager_graph(Sequel[:artist].as(:a, join_type: :inner)).all
|
2990
|
+
# # SELECT ...
|
2991
|
+
# # FROM albums
|
2992
|
+
# # INNER JOIN artists AS a ON (a.id = albums.artist_id)
|
2993
|
+
#
|
2986
2994
|
# # For each album, eager_graph load the artist and genre
|
2987
2995
|
# Album.eager_graph(:artist, :genre).all
|
2988
2996
|
# Album.eager_graph(:artist).eager_graph(:genre).all
|
@@ -3125,11 +3133,16 @@ module Sequel
|
|
3125
3133
|
# ta :: table_alias used for the parent association
|
3126
3134
|
# requirements :: an array, used as a stack for requirements
|
3127
3135
|
# r :: association reflection for the current association, or an SQL::AliasedExpression
|
3128
|
-
# with the reflection as the expression
|
3136
|
+
# with the reflection as the expression, the alias base as the alias (or nil to
|
3137
|
+
# use the default alias), and an optional hash with a :join_type entry as the columns
|
3138
|
+
# to use a custom join type.
|
3129
3139
|
# *associations :: any associations dependent on this one
|
3130
3140
|
def eager_graph_association(ds, model, ta, requirements, r, *associations)
|
3131
3141
|
if r.is_a?(SQL::AliasedExpression)
|
3132
3142
|
alias_base = r.alias
|
3143
|
+
if r.columns.is_a?(Hash)
|
3144
|
+
join_type = r.columns[:join_type]
|
3145
|
+
end
|
3133
3146
|
r = r.expression
|
3134
3147
|
else
|
3135
3148
|
alias_base = r[:graph_alias_base]
|
@@ -3152,7 +3165,7 @@ module Sequel
|
|
3152
3165
|
raise Error, "Cannot eager_graph association when :conditions specified and not a hash or an array of pairs. Specify :graph_conditions, :graph_only_conditions, or :graph_block for the association. Model: #{r[:model]}, association: #{r[:name]}"
|
3153
3166
|
end
|
3154
3167
|
|
3155
|
-
ds = loader.call(:self=>ds, :table_alias=>assoc_table_alias, :implicit_qualifier=>(ta == ds.opts[:eager_graph][:master]) ? first_source : qualifier_from_alias_symbol(ta, first_source), :callback=>callback, :join_type=>local_opts[:join_type], :join_only=>local_opts[:join_only], :limit_strategy=>limit_strategy, :from_self_alias=>ds.opts[:eager_graph][:master])
|
3168
|
+
ds = loader.call(:self=>ds, :table_alias=>assoc_table_alias, :implicit_qualifier=>(ta == ds.opts[:eager_graph][:master]) ? first_source : qualifier_from_alias_symbol(ta, first_source), :callback=>callback, :join_type=>join_type || local_opts[:join_type], :join_only=>local_opts[:join_only], :limit_strategy=>limit_strategy, :from_self_alias=>ds.opts[:eager_graph][:master])
|
3156
3169
|
if r[:order_eager_graph] && (order = r.fetch(:graph_order, r[:order]))
|
3157
3170
|
ds = ds.order_append(*qualified_expression(order, assoc_table_alias))
|
3158
3171
|
end
|
@@ -3307,7 +3320,7 @@ module Sequel
|
|
3307
3320
|
end
|
3308
3321
|
end
|
3309
3322
|
|
3310
|
-
SQL::AliasedExpression.new(check_association(model, expr), association.alias)
|
3323
|
+
SQL::AliasedExpression.new(check_association(model, expr), association.alias || expr, association.columns)
|
3311
3324
|
else
|
3312
3325
|
check_association(model, association)
|
3313
3326
|
end
|