sequel 5.20.0 → 5.49.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +398 -1922
- data/MIT-LICENSE +1 -1
- data/README.rdoc +7 -7
- data/doc/advanced_associations.rdoc +4 -4
- data/doc/association_basics.rdoc +80 -16
- data/doc/cheat_sheet.rdoc +6 -5
- data/doc/code_order.rdoc +10 -12
- data/doc/dataset_filtering.rdoc +17 -2
- data/doc/fork_safety.rdoc +84 -0
- data/doc/migration.rdoc +11 -5
- data/doc/model_dataset_method_design.rdoc +1 -1
- data/doc/model_plugins.rdoc +1 -1
- data/doc/opening_databases.rdoc +10 -2
- data/doc/postgresql.rdoc +82 -3
- data/doc/querying.rdoc +4 -4
- data/doc/release_notes/5.21.0.txt +87 -0
- data/doc/release_notes/5.22.0.txt +48 -0
- data/doc/release_notes/5.23.0.txt +56 -0
- data/doc/release_notes/5.24.0.txt +56 -0
- data/doc/release_notes/5.25.0.txt +32 -0
- data/doc/release_notes/5.26.0.txt +35 -0
- data/doc/release_notes/5.27.0.txt +21 -0
- data/doc/release_notes/5.28.0.txt +16 -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/release_notes/5.34.0.txt +40 -0
- data/doc/release_notes/5.35.0.txt +56 -0
- data/doc/release_notes/5.36.0.txt +60 -0
- data/doc/release_notes/5.37.0.txt +30 -0
- data/doc/release_notes/5.38.0.txt +28 -0
- data/doc/release_notes/5.39.0.txt +19 -0
- data/doc/release_notes/5.40.0.txt +40 -0
- data/doc/release_notes/5.41.0.txt +25 -0
- data/doc/release_notes/5.42.0.txt +136 -0
- data/doc/release_notes/5.43.0.txt +98 -0
- data/doc/release_notes/5.44.0.txt +32 -0
- data/doc/release_notes/5.45.0.txt +34 -0
- data/doc/release_notes/5.46.0.txt +87 -0
- data/doc/release_notes/5.47.0.txt +59 -0
- data/doc/release_notes/5.48.0.txt +14 -0
- data/doc/release_notes/5.49.0.txt +59 -0
- data/doc/sharding.rdoc +2 -0
- data/doc/sql.rdoc +13 -1
- data/doc/testing.rdoc +20 -7
- data/doc/transactions.rdoc +0 -8
- data/doc/validations.rdoc +1 -1
- data/doc/virtual_rows.rdoc +1 -1
- data/lib/sequel/adapters/ado/access.rb +1 -1
- data/lib/sequel/adapters/ado.rb +43 -35
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc/mysql.rb +6 -6
- data/lib/sequel/adapters/jdbc/postgresql.rb +11 -17
- data/lib/sequel/adapters/jdbc/sqlite.rb +29 -0
- data/lib/sequel/adapters/jdbc.rb +24 -6
- data/lib/sequel/adapters/mysql.rb +1 -1
- data/lib/sequel/adapters/mysql2.rb +2 -3
- data/lib/sequel/adapters/odbc.rb +8 -6
- data/lib/sequel/adapters/oracle.rb +5 -4
- data/lib/sequel/adapters/postgres.rb +15 -9
- data/lib/sequel/adapters/shared/access.rb +6 -6
- data/lib/sequel/adapters/shared/mssql.rb +66 -21
- data/lib/sequel/adapters/shared/mysql.rb +27 -10
- data/lib/sequel/adapters/shared/oracle.rb +29 -23
- data/lib/sequel/adapters/shared/postgres.rb +271 -32
- data/lib/sequel/adapters/shared/sqlanywhere.rb +9 -9
- data/lib/sequel/adapters/shared/sqlite.rb +161 -19
- data/lib/sequel/adapters/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/sqlite.rb +1 -1
- data/lib/sequel/adapters/tinytds.rb +15 -2
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +4 -1
- data/lib/sequel/ast_transformer.rb +6 -0
- data/lib/sequel/connection_pool/sharded_single.rb +4 -1
- data/lib/sequel/connection_pool/sharded_threaded.rb +12 -12
- data/lib/sequel/connection_pool/single.rb +1 -1
- data/lib/sequel/connection_pool/threaded.rb +2 -2
- data/lib/sequel/core.rb +333 -319
- data/lib/sequel/database/connecting.rb +3 -4
- data/lib/sequel/database/logging.rb +7 -1
- data/lib/sequel/database/misc.rb +31 -12
- data/lib/sequel/database/query.rb +3 -1
- data/lib/sequel/database/schema_generator.rb +53 -51
- data/lib/sequel/database/schema_methods.rb +38 -23
- data/lib/sequel/database/transactions.rb +17 -18
- data/lib/sequel/dataset/actions.rb +14 -9
- data/lib/sequel/dataset/features.rb +16 -0
- data/lib/sequel/dataset/misc.rb +2 -2
- data/lib/sequel/dataset/placeholder_literalizer.rb +3 -7
- data/lib/sequel/dataset/prepared_statements.rb +2 -0
- data/lib/sequel/dataset/query.rb +26 -9
- data/lib/sequel/dataset/sql.rb +76 -25
- data/lib/sequel/dataset.rb +4 -2
- data/lib/sequel/deprecated.rb +3 -1
- data/lib/sequel/exceptions.rb +2 -0
- data/lib/sequel/extensions/_pretty_table.rb +1 -2
- data/lib/sequel/extensions/any_not_empty.rb +45 -0
- data/lib/sequel/extensions/async_thread_pool.rb +438 -0
- data/lib/sequel/extensions/blank.rb +8 -0
- data/lib/sequel/extensions/columns_introspection.rb +1 -2
- data/lib/sequel/extensions/connection_expiration.rb +2 -2
- data/lib/sequel/extensions/connection_validator.rb +2 -2
- data/lib/sequel/extensions/core_refinements.rb +2 -0
- data/lib/sequel/extensions/date_arithmetic.rb +36 -24
- data/lib/sequel/extensions/duplicate_columns_handler.rb +3 -1
- data/lib/sequel/extensions/eval_inspect.rb +2 -0
- data/lib/sequel/extensions/exclude_or_null.rb +68 -0
- data/lib/sequel/extensions/fiber_concurrency.rb +24 -0
- data/lib/sequel/extensions/index_caching.rb +9 -7
- data/lib/sequel/extensions/inflector.rb +9 -1
- data/lib/sequel/extensions/integer64.rb +2 -0
- data/lib/sequel/extensions/migration.rb +11 -3
- data/lib/sequel/extensions/named_timezones.rb +56 -8
- data/lib/sequel/extensions/pagination.rb +1 -1
- data/lib/sequel/extensions/pg_array.rb +5 -0
- data/lib/sequel/extensions/pg_array_ops.rb +14 -6
- data/lib/sequel/extensions/pg_enum.rb +11 -3
- data/lib/sequel/extensions/pg_extended_date_support.rb +2 -2
- data/lib/sequel/extensions/pg_hstore.rb +6 -0
- data/lib/sequel/extensions/pg_hstore_ops.rb +54 -2
- data/lib/sequel/extensions/pg_inet.rb +15 -5
- data/lib/sequel/extensions/pg_interval.rb +36 -8
- data/lib/sequel/extensions/pg_json.rb +387 -123
- data/lib/sequel/extensions/pg_json_ops.rb +238 -0
- data/lib/sequel/extensions/pg_loose_count.rb +3 -1
- data/lib/sequel/extensions/pg_range.rb +17 -9
- data/lib/sequel/extensions/pg_range_ops.rb +2 -0
- data/lib/sequel/extensions/pg_row.rb +4 -2
- data/lib/sequel/extensions/pg_row_ops.rb +24 -0
- data/lib/sequel/extensions/pg_timestamptz.rb +2 -0
- data/lib/sequel/extensions/query.rb +3 -0
- data/lib/sequel/extensions/run_transaction_hooks.rb +72 -0
- data/lib/sequel/extensions/s.rb +2 -0
- data/lib/sequel/extensions/schema_dumper.rb +24 -7
- data/lib/sequel/extensions/server_block.rb +18 -7
- data/lib/sequel/extensions/sql_comments.rb +2 -2
- data/lib/sequel/extensions/string_agg.rb +1 -1
- data/lib/sequel/extensions/symbol_aref_refinement.rb +2 -0
- data/lib/sequel/extensions/symbol_as_refinement.rb +2 -0
- data/lib/sequel/extensions/to_dot.rb +9 -3
- data/lib/sequel/model/associations.rb +356 -117
- data/lib/sequel/model/base.rb +107 -68
- data/lib/sequel/model/errors.rb +10 -1
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/model/plugins.rb +9 -3
- data/lib/sequel/model.rb +3 -1
- data/lib/sequel/plugins/association_lazy_eager_option.rb +66 -0
- data/lib/sequel/plugins/association_multi_add_remove.rb +85 -0
- data/lib/sequel/plugins/association_pks.rb +60 -18
- data/lib/sequel/plugins/association_proxies.rb +8 -2
- data/lib/sequel/plugins/async_thread_pool.rb +39 -0
- data/lib/sequel/plugins/auto_validations.rb +39 -5
- data/lib/sequel/plugins/auto_validations_constraint_validations_presence_message.rb +68 -0
- data/lib/sequel/plugins/blacklist_security.rb +1 -2
- data/lib/sequel/plugins/boolean_subsets.rb +4 -1
- data/lib/sequel/plugins/caching.rb +3 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +33 -28
- data/lib/sequel/plugins/column_encryption.rb +728 -0
- data/lib/sequel/plugins/composition.rb +7 -2
- data/lib/sequel/plugins/concurrent_eager_loading.rb +174 -0
- data/lib/sequel/plugins/constraint_validations.rb +2 -1
- data/lib/sequel/plugins/csv_serializer.rb +28 -9
- data/lib/sequel/plugins/dataset_associations.rb +4 -1
- data/lib/sequel/plugins/dirty.rb +60 -22
- data/lib/sequel/plugins/empty_failure_backtraces.rb +38 -0
- data/lib/sequel/plugins/forbid_lazy_load.rb +216 -0
- data/lib/sequel/plugins/insert_conflict.rb +72 -0
- data/lib/sequel/plugins/instance_specific_default.rb +113 -0
- data/lib/sequel/plugins/json_serializer.rb +57 -35
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/many_through_many.rb +108 -9
- data/lib/sequel/plugins/nested_attributes.rb +15 -3
- data/lib/sequel/plugins/pg_array_associations.rb +58 -41
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +91 -30
- data/lib/sequel/plugins/prepared_statements.rb +15 -12
- data/lib/sequel/plugins/prepared_statements_safe.rb +1 -3
- data/lib/sequel/plugins/rcte_tree.rb +43 -35
- data/lib/sequel/plugins/serialization.rb +8 -3
- data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +11 -5
- data/lib/sequel/plugins/single_table_inheritance.rb +22 -15
- data/lib/sequel/plugins/skip_saving_columns.rb +108 -0
- data/lib/sequel/plugins/static_cache.rb +9 -4
- data/lib/sequel/plugins/static_cache_cache.rb +53 -0
- data/lib/sequel/plugins/string_stripper.rb +1 -1
- data/lib/sequel/plugins/subclasses.rb +2 -0
- data/lib/sequel/plugins/throw_failures.rb +1 -1
- data/lib/sequel/plugins/timestamps.rb +1 -1
- data/lib/sequel/plugins/tree.rb +9 -4
- data/lib/sequel/plugins/typecast_on_load.rb +3 -2
- data/lib/sequel/plugins/unused_associations.rb +521 -0
- data/lib/sequel/plugins/update_or_create.rb +1 -1
- data/lib/sequel/plugins/validation_class_methods.rb +5 -1
- data/lib/sequel/plugins/validation_helpers.rb +18 -11
- data/lib/sequel/plugins/xml_serializer.rb +1 -1
- data/lib/sequel/sql.rb +20 -5
- data/lib/sequel/timezones.rb +63 -17
- data/lib/sequel/version.rb +1 -1
- metadata +113 -381
- 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 -804
- data/spec/adapters/mysql_spec.rb +0 -1065
- data/spec/adapters/oracle_spec.rb +0 -371
- data/spec/adapters/postgres_spec.rb +0 -4125
- 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 -2865
- data/spec/core/dataset_spec.rb +0 -5515
- data/spec/core/deprecated_spec.rb +0 -70
- data/spec/core/expression_filters_spec.rb +0 -1455
- 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 -1826
- 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/arbitrary_servers_spec.rb +0 -109
- data/spec/extensions/association_dependencies_spec.rb +0 -125
- 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 -189
- 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/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_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 -111
- data/spec/extensions/nested_attributes_spec.rb +0 -767
- 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 -172
- 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 -289
- data/spec/extensions/pg_json_spec.rb +0 -262
- 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 -519
- 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 -381
- 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 -97
- data/spec/extensions/server_logging_spec.rb +0 -45
- data/spec/extensions/sharding_spec.rb +0 -189
- 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 -63
- 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_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 -1981
- 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 -2396
- data/spec/integration/prepared_statement_test.rb +0 -405
- data/spec/integration/schema_test.rb +0 -889
- data/spec/integration/spec_helper.rb +0 -65
- 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
@@ -10,6 +10,11 @@ module Sequel
|
|
10
10
|
def self.mock_adapter_setup(db)
|
11
11
|
db.instance_exec do
|
12
12
|
@sqlite_version = 30903
|
13
|
+
|
14
|
+
def schema_parse_table(*)
|
15
|
+
[]
|
16
|
+
end
|
17
|
+
singleton_class.send(:private, :schema_parse_table)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
@@ -33,6 +38,10 @@ module Sequel
|
|
33
38
|
# booleans be stored as integers, but historically Sequel has used 't'/'f'.
|
34
39
|
attr_accessor :integer_booleans
|
35
40
|
|
41
|
+
# Whether to keep CURRENT_TIMESTAMP and similar expressions in UTC. By
|
42
|
+
# default, the expressions are converted to localtime.
|
43
|
+
attr_accessor :current_timestamp_utc
|
44
|
+
|
36
45
|
# A symbol signifying the value of the default transaction mode
|
37
46
|
attr_reader :transaction_mode
|
38
47
|
|
@@ -60,7 +69,7 @@ module Sequel
|
|
60
69
|
def foreign_key_list(table, opts=OPTS)
|
61
70
|
m = output_identifier_meth
|
62
71
|
h = {}
|
63
|
-
|
72
|
+
_foreign_key_list_ds(table).each do |row|
|
64
73
|
if r = h[row[:id]]
|
65
74
|
r[:columns] << m.call(row[:from])
|
66
75
|
r[:key] << m.call(row[:to]) if r[:key]
|
@@ -173,6 +182,16 @@ module Sequel
|
|
173
182
|
|
174
183
|
private
|
175
184
|
|
185
|
+
# Dataset used for parsing foreign key lists
|
186
|
+
def _foreign_key_list_ds(table)
|
187
|
+
metadata_dataset.with_sql("PRAGMA foreign_key_list(?)", input_identifier_meth.call(table))
|
188
|
+
end
|
189
|
+
|
190
|
+
# Dataset used for parsing schema
|
191
|
+
def _parse_pragma_ds(table_name, opts)
|
192
|
+
metadata_dataset.with_sql("PRAGMA table_#{'x' if sqlite_version > 33100}info(?)", input_identifier_meth(opts[:dataset]).call(table_name))
|
193
|
+
end
|
194
|
+
|
176
195
|
# Run all alter_table commands in a transaction. This is technically only
|
177
196
|
# needed for drop column.
|
178
197
|
def apply_alter_table(table, ops)
|
@@ -220,8 +239,12 @@ module Sequel
|
|
220
239
|
super
|
221
240
|
end
|
222
241
|
when :drop_column
|
223
|
-
|
224
|
-
|
242
|
+
if sqlite_version >= 33500
|
243
|
+
super
|
244
|
+
else
|
245
|
+
ocp = lambda{|oc| oc.delete_if{|c| c.to_s == op[:name].to_s}}
|
246
|
+
duplicate_table(table, :old_columns_proc=>ocp){|columns| columns.delete_if{|s| s[:name].to_s == op[:name].to_s}}
|
247
|
+
end
|
225
248
|
when :rename_column
|
226
249
|
if sqlite_version >= 32500
|
227
250
|
super
|
@@ -238,13 +261,20 @@ module Sequel
|
|
238
261
|
when :drop_constraint
|
239
262
|
case op[:type]
|
240
263
|
when :primary_key
|
241
|
-
duplicate_table(table)
|
264
|
+
duplicate_table(table) do |columns|
|
265
|
+
columns.each do |s|
|
266
|
+
s[:unique] = false if s[:primary_key]
|
267
|
+
s[:primary_key] = s[:auto_increment] = nil
|
268
|
+
end
|
269
|
+
end
|
242
270
|
when :foreign_key
|
243
271
|
if op[:columns]
|
244
272
|
duplicate_table(table, :skip_foreign_key_columns=>op[:columns])
|
245
273
|
else
|
246
274
|
duplicate_table(table, :no_foreign_keys=>true)
|
247
275
|
end
|
276
|
+
when :unique
|
277
|
+
duplicate_table(table, :no_unique=>true)
|
248
278
|
else
|
249
279
|
duplicate_table(table)
|
250
280
|
end
|
@@ -279,9 +309,15 @@ module Sequel
|
|
279
309
|
false
|
280
310
|
end
|
281
311
|
|
282
|
-
# Surround default with parens to appease SQLite
|
312
|
+
# Surround default with parens to appease SQLite. Add support for GENERATED ALWAYS AS.
|
283
313
|
def column_definition_default_sql(sql, column)
|
284
314
|
sql << " DEFAULT (#{literal(column[:default])})" if column.include?(:default)
|
315
|
+
if (generated = column[:generated_always_as])
|
316
|
+
if (generated_type = column[:generated_type]) && (generated_type == :stored || generated_type == :virtual)
|
317
|
+
generated_type = generated_type.to_s.upcase
|
318
|
+
end
|
319
|
+
sql << " GENERATED ALWAYS AS (#{literal(generated)}) #{generated_type}"
|
320
|
+
end
|
285
321
|
end
|
286
322
|
|
287
323
|
# Array of PRAGMA SQL statements based on the Database options that should be applied to
|
@@ -357,7 +393,7 @@ module Sequel
|
|
357
393
|
old_columns = def_columns.map{|c| c[:name]}
|
358
394
|
opts[:old_columns_proc].call(old_columns) if opts[:old_columns_proc]
|
359
395
|
|
360
|
-
yield def_columns if
|
396
|
+
yield def_columns if defined?(yield)
|
361
397
|
|
362
398
|
constraints = (opts[:constraints] || []).dup
|
363
399
|
pks = []
|
@@ -392,15 +428,19 @@ module Sequel
|
|
392
428
|
skip_indexes = []
|
393
429
|
indexes(table, :only_autocreated=>true).each do |name, h|
|
394
430
|
skip_indexes << name
|
395
|
-
if h[:
|
396
|
-
|
431
|
+
if h[:unique] && !opts[:no_unique]
|
432
|
+
if h[:columns].length == 1
|
433
|
+
unique_columns.concat(h[:columns])
|
434
|
+
elsif h[:columns].map(&:to_s) != pks
|
435
|
+
constraints << {:type=>:unique, :columns=>h[:columns]}
|
436
|
+
end
|
397
437
|
end
|
398
438
|
end
|
399
439
|
unique_columns -= pks
|
400
440
|
unless unique_columns.empty?
|
401
441
|
unique_columns.map!{|c| quote_identifier(c)}
|
402
442
|
def_columns.each do |c|
|
403
|
-
c[:unique] = true if unique_columns.include?(quote_identifier(c[:name]))
|
443
|
+
c[:unique] = true if unique_columns.include?(quote_identifier(c[:name])) && c[:unique] != false
|
404
444
|
end
|
405
445
|
end
|
406
446
|
|
@@ -445,7 +485,16 @@ module Sequel
|
|
445
485
|
# Parse the output of the table_info pragma
|
446
486
|
def parse_pragma(table_name, opts)
|
447
487
|
pks = 0
|
448
|
-
sch =
|
488
|
+
sch = _parse_pragma_ds(table_name, opts).map do |row|
|
489
|
+
if sqlite_version > 33100
|
490
|
+
# table_xinfo PRAGMA used, remove hidden columns
|
491
|
+
# that are not generated columns
|
492
|
+
if row[:generated] = (row.delete(:hidden) != 0)
|
493
|
+
next unless row[:type].end_with?(' GENERATED ALWAYS')
|
494
|
+
row[:type] = row[:type].sub(' GENERATED ALWAYS', '')
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
449
498
|
row.delete(:cid)
|
450
499
|
row[:allow_null] = row.delete(:notnull).to_i == 0
|
451
500
|
row[:default] = row.delete(:dflt_value)
|
@@ -462,6 +511,8 @@ module Sequel
|
|
462
511
|
row
|
463
512
|
end
|
464
513
|
|
514
|
+
sch.compact!
|
515
|
+
|
465
516
|
if pks > 1
|
466
517
|
# SQLite does not allow use of auto increment for tables
|
467
518
|
# with composite primary keys, so remove auto_increment
|
@@ -511,10 +562,10 @@ module Sequel
|
|
511
562
|
EXTRACT_MAP = {:year=>"'%Y'", :month=>"'%m'", :day=>"'%d'", :hour=>"'%H'", :minute=>"'%M'", :second=>"'%f'"}.freeze
|
512
563
|
EXTRACT_MAP.each_value(&:freeze)
|
513
564
|
|
514
|
-
Dataset.def_sql_method(self, :delete, [['if db.sqlite_version >= 30803', %w'with delete from where'], ["else", %w'delete from where']])
|
515
|
-
Dataset.def_sql_method(self, :insert, [['if db.sqlite_version >= 30803', %w'with insert conflict into columns values on_conflict'], ["else", %w'insert conflict into columns values']])
|
516
|
-
Dataset.def_sql_method(self, :select, [['if opts[:values]', %w'with values compounds'], ['else', %w'with select distinct columns from join where group having compounds order limit lock']])
|
517
|
-
Dataset.def_sql_method(self, :update, [['if db.sqlite_version >= 30803', %w'with update table set where'], ["else", %w'update table set where']])
|
565
|
+
Dataset.def_sql_method(self, :delete, [['if db.sqlite_version >= 33500', %w'with delete from where returning'], ['elsif db.sqlite_version >= 30803', %w'with delete from where'], ["else", %w'delete from where']])
|
566
|
+
Dataset.def_sql_method(self, :insert, [['if db.sqlite_version >= 33500', %w'with insert conflict into columns values on_conflict returning'], ['elsif db.sqlite_version >= 30803', %w'with insert conflict into columns values on_conflict'], ["else", %w'insert conflict into columns values']])
|
567
|
+
Dataset.def_sql_method(self, :select, [['if opts[:values]', %w'with values compounds'], ['else', %w'with select distinct columns from join where group having window compounds order limit lock']])
|
568
|
+
Dataset.def_sql_method(self, :update, [['if db.sqlite_version >= 33500', %w'with update table set from where returning'], ['elsif db.sqlite_version >= 33300', %w'with update table set from where'], ['elsif db.sqlite_version >= 30803', %w'with update table set where'], ["else", %w'update table set where']])
|
518
569
|
|
519
570
|
def cast_sql_append(sql, expr, type)
|
520
571
|
if type == Time or type == DateTime
|
@@ -578,7 +629,7 @@ module Sequel
|
|
578
629
|
# SQLite has CURRENT_TIMESTAMP and related constants in UTC instead
|
579
630
|
# of in localtime, so convert those constants to local time.
|
580
631
|
def constant_sql_append(sql, constant)
|
581
|
-
if c = CONSTANT_MAP[constant]
|
632
|
+
if (c = CONSTANT_MAP[constant]) && !db.current_timestamp_utc
|
582
633
|
sql << c
|
583
634
|
else
|
584
635
|
super
|
@@ -588,8 +639,8 @@ module Sequel
|
|
588
639
|
# SQLite performs a TRUNCATE style DELETE if no filter is specified.
|
589
640
|
# Since we want to always return the count of records, add a condition
|
590
641
|
# that is always true and then delete.
|
591
|
-
def delete
|
592
|
-
@opts[:where] ? super : where(1=>1).delete
|
642
|
+
def delete(&block)
|
643
|
+
@opts[:where] ? super : where(1=>1).delete(&block)
|
593
644
|
end
|
594
645
|
|
595
646
|
# Return an array of strings specifying a query explanation for a SELECT of the
|
@@ -610,6 +661,21 @@ module Sequel
|
|
610
661
|
super
|
611
662
|
end
|
612
663
|
|
664
|
+
# Support insert select for associations, so that the model code can use
|
665
|
+
# returning instead of a separate query.
|
666
|
+
def insert_select(*values)
|
667
|
+
return unless supports_insert_select?
|
668
|
+
# Handle case where query does not return a row
|
669
|
+
server?(:default).with_sql_first(insert_select_sql(*values)) || false
|
670
|
+
end
|
671
|
+
|
672
|
+
# The SQL to use for an insert_select, adds a RETURNING clause to the insert
|
673
|
+
# unless the RETURNING clause is already present.
|
674
|
+
def insert_select_sql(*values)
|
675
|
+
ds = opts[:returning] ? self : returning
|
676
|
+
ds.insert_sql(*values)
|
677
|
+
end
|
678
|
+
|
613
679
|
# SQLite uses the nonstandard ` (backtick) for quoting identifiers.
|
614
680
|
def quoted_identifier_append(sql, c)
|
615
681
|
sql << '`' << c.to_s.gsub('`', '``') << '`'
|
@@ -691,6 +757,13 @@ module Sequel
|
|
691
757
|
insert_conflict(:ignore)
|
692
758
|
end
|
693
759
|
|
760
|
+
# Automatically add aliases to RETURNING values to work around SQLite bug.
|
761
|
+
def returning(*values)
|
762
|
+
return super if values.empty?
|
763
|
+
raise Error, "RETURNING is not supported on #{db.database_type}" unless supports_returning?(:insert)
|
764
|
+
clone(:returning=>_returning_values(values).freeze)
|
765
|
+
end
|
766
|
+
|
694
767
|
# SQLite 3.8.3+ supports common table expressions.
|
695
768
|
def supports_cte?(type=:select)
|
696
769
|
db.sqlite_version >= 30803
|
@@ -706,6 +779,11 @@ module Sequel
|
|
706
779
|
false
|
707
780
|
end
|
708
781
|
|
782
|
+
# SQLite does not support deleting from a joined dataset
|
783
|
+
def supports_deleting_joins?
|
784
|
+
false
|
785
|
+
end
|
786
|
+
|
709
787
|
# SQLite does not support INTERSECT ALL or EXCEPT ALL
|
710
788
|
def supports_intersect_except_all?
|
711
789
|
false
|
@@ -716,11 +794,21 @@ module Sequel
|
|
716
794
|
false
|
717
795
|
end
|
718
796
|
|
797
|
+
# SQLite 3.33.0 supports modifying joined datasets
|
798
|
+
def supports_modifying_joins?
|
799
|
+
db.sqlite_version >= 33300
|
800
|
+
end
|
801
|
+
|
719
802
|
# SQLite does not support multiple columns for the IN/NOT IN operators
|
720
803
|
def supports_multiple_column_in?
|
721
804
|
false
|
722
805
|
end
|
723
806
|
|
807
|
+
# SQLite 3.35.0 supports RETURNING on INSERT/UPDATE/DELETE.
|
808
|
+
def supports_returning?(_)
|
809
|
+
db.sqlite_version >= 33500
|
810
|
+
end
|
811
|
+
|
724
812
|
# SQLite supports timezones in literal timestamps, since it stores them
|
725
813
|
# as text. But using timezones in timestamps breaks SQLite datetime
|
726
814
|
# functions, so we allow the user to override the default per database.
|
@@ -732,6 +820,11 @@ module Sequel
|
|
732
820
|
def supports_where_true?
|
733
821
|
false
|
734
822
|
end
|
823
|
+
|
824
|
+
# SQLite 3.28+ supports the WINDOW clause.
|
825
|
+
def supports_window_clause?
|
826
|
+
db.sqlite_version >= 32800
|
827
|
+
end
|
735
828
|
|
736
829
|
# SQLite 3.25+ supports window functions. However, support is only enabled
|
737
830
|
# on SQLite 3.26.0+ because internal Sequel usage of window functions
|
@@ -741,8 +834,28 @@ module Sequel
|
|
741
834
|
db.sqlite_version >= 32600
|
742
835
|
end
|
743
836
|
|
837
|
+
# SQLite 3.28.0+ supports all window frame options that Sequel supports
|
838
|
+
def supports_window_function_frame_option?(option)
|
839
|
+
db.sqlite_version >= 32800 ? true : super
|
840
|
+
end
|
841
|
+
|
744
842
|
private
|
745
843
|
|
844
|
+
# Add aliases to symbols and identifiers to work around SQLite bug.
|
845
|
+
def _returning_values(values)
|
846
|
+
values.map do |v|
|
847
|
+
case v
|
848
|
+
when Symbol
|
849
|
+
_, c, a = split_symbol(v)
|
850
|
+
a ? v : Sequel.as(v, c)
|
851
|
+
when SQL::Identifier, SQL::QualifiedIdentifier
|
852
|
+
Sequel.as(v, unqualified_column_for(v))
|
853
|
+
else
|
854
|
+
v
|
855
|
+
end
|
856
|
+
end
|
857
|
+
end
|
858
|
+
|
746
859
|
# SQLite uses string literals instead of identifiers in AS clauses.
|
747
860
|
def as_sql_append(sql, aliaz, column_aliases=nil)
|
748
861
|
raise Error, "sqlite does not support derived column lists" if column_aliases
|
@@ -768,6 +881,13 @@ module Sequel
|
|
768
881
|
end
|
769
882
|
end
|
770
883
|
|
884
|
+
# Raise an InvalidOperation exception if insert is not allowed for this dataset.
|
885
|
+
def check_insert_allowed!
|
886
|
+
raise(InvalidOperation, "Grouped datasets cannot be modified") if opts[:group]
|
887
|
+
raise(InvalidOperation, "Joined datasets cannot be modified") if joined_dataset?
|
888
|
+
end
|
889
|
+
alias check_delete_allowed! check_insert_allowed!
|
890
|
+
|
771
891
|
# SQLite supports a maximum of 500 rows in a VALUES clause.
|
772
892
|
def default_import_slice
|
773
893
|
500
|
@@ -845,9 +965,9 @@ module Sequel
|
|
845
965
|
end
|
846
966
|
end
|
847
967
|
|
848
|
-
# SQLite
|
968
|
+
# SQLite supports NULLS FIRST/LAST natively in 3.30+.
|
849
969
|
def requires_emulating_nulls_first?
|
850
|
-
|
970
|
+
db.sqlite_version < 33000
|
851
971
|
end
|
852
972
|
|
853
973
|
# SQLite does not support FOR UPDATE, but silently ignore it
|
@@ -873,6 +993,11 @@ module Sequel
|
|
873
993
|
false
|
874
994
|
end
|
875
995
|
|
996
|
+
# SQLite 3.30 supports the FILTER clause for aggregate functions.
|
997
|
+
def supports_filtered_aggregates?
|
998
|
+
db.sqlite_version >= 33000
|
999
|
+
end
|
1000
|
+
|
876
1001
|
# SQLite supports quoted function names.
|
877
1002
|
def supports_quoted_function_names?
|
878
1003
|
true
|
@@ -882,6 +1007,23 @@ module Sequel
|
|
882
1007
|
def _truncate_sql(table)
|
883
1008
|
"DELETE FROM #{table}"
|
884
1009
|
end
|
1010
|
+
|
1011
|
+
# Use FROM to specify additional tables in an update query
|
1012
|
+
def update_from_sql(sql)
|
1013
|
+
if(from = @opts[:from][1..-1]).empty?
|
1014
|
+
raise(Error, 'Need multiple FROM tables if updating/deleting a dataset with JOINs') if @opts[:join]
|
1015
|
+
else
|
1016
|
+
sql << ' FROM '
|
1017
|
+
source_list_append(sql, from)
|
1018
|
+
select_join_sql(sql)
|
1019
|
+
end
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
# Only include the primary table in the main update clause
|
1023
|
+
def update_table_sql(sql)
|
1024
|
+
sql << ' '
|
1025
|
+
source_list_append(sql, @opts[:from][0..0])
|
1026
|
+
end
|
885
1027
|
end
|
886
1028
|
end
|
887
1029
|
end
|
@@ -112,7 +112,7 @@ module Sequel
|
|
112
112
|
sqlite3_opts = {}
|
113
113
|
sqlite3_opts[:readonly] = typecast_value_boolean(opts[:readonly]) if opts.has_key?(:readonly)
|
114
114
|
db = ::SQLite3::Database.new(opts[:database].to_s, sqlite3_opts)
|
115
|
-
db.busy_timeout(opts.fetch(:timeout, 5000))
|
115
|
+
db.busy_timeout(typecast_value_integer(opts.fetch(:timeout, 5000)))
|
116
116
|
|
117
117
|
if USE_EXTENDED_RESULT_CODES
|
118
118
|
db.extended_result_codes = true
|
@@ -16,6 +16,19 @@ module Sequel
|
|
16
16
|
c = TinyTds::Client.new(opts)
|
17
17
|
c.query_options.merge!(:cache_rows=>false)
|
18
18
|
|
19
|
+
# SEQUEL6: Default to ansi: true
|
20
|
+
if opts[:ansi]
|
21
|
+
sql = %w(
|
22
|
+
ANSI_NULLS
|
23
|
+
ANSI_PADDING
|
24
|
+
ANSI_WARNINGS
|
25
|
+
ANSI_NULL_DFLT_ON
|
26
|
+
QUOTED_IDENTIFIER
|
27
|
+
CONCAT_NULL_YIELDS_NULL
|
28
|
+
).map{|v| "SET #{v} ON"}.join(";")
|
29
|
+
log_connection_yield(sql, c){c.execute(sql)}
|
30
|
+
end
|
31
|
+
|
19
32
|
if (ts = opts[:textsize])
|
20
33
|
sql = "SET TEXTSIZE #{typecast_value_integer(ts)}"
|
21
34
|
log_connection_yield(sql, c){c.execute(sql)}
|
@@ -62,7 +75,7 @@ module Sequel
|
|
62
75
|
return r.public_send(m) if m
|
63
76
|
end
|
64
77
|
end
|
65
|
-
yield(r) if
|
78
|
+
yield(r) if defined?(yield)
|
66
79
|
rescue TinyTds::Error => e
|
67
80
|
raise_error(e, :disconnect=>!c.active?)
|
68
81
|
ensure
|
@@ -133,7 +146,7 @@ module Sequel
|
|
133
146
|
|
134
147
|
# Return true if the :conn argument is present and not active.
|
135
148
|
def disconnect_error?(e, opts)
|
136
|
-
super || (opts[:conn] && !opts[:conn].active?) || ((e.is_a?(::TinyTds::Error) && /\A(Attempt to initiate a new Adaptive Server operation with results pending|The request failed to run because the batch is aborted, this can be caused by abort signal sent from client|Adaptive Server connection timed out)/.match(e.message)))
|
149
|
+
super || (opts[:conn] && !opts[:conn].active?) || ((e.is_a?(::TinyTds::Error) && /\A(Attempt to initiate a new Adaptive Server operation with results pending|The request failed to run because the batch is aborted, this can be caused by abort signal sent from client|Adaptive Server connection timed out|DBPROCESS is dead or not enabled)/.match(e.message)))
|
137
150
|
end
|
138
151
|
|
139
152
|
# Dispose of any possible results of execution.
|
@@ -18,6 +18,7 @@ module Sequel
|
|
18
18
|
This connection is still waiting for a result, try again once you have the result
|
19
19
|
closed MySQL connection
|
20
20
|
The MySQL server is running with the --read-only option so it cannot execute this statement
|
21
|
+
Connection was killed
|
21
22
|
END
|
22
23
|
# Error messages for mysql and mysql2 that indicate the current connection should be disconnected
|
23
24
|
MYSQL_DATABASE_DISCONNECT_ERRORS = /\A#{Regexp.union(disconnect_errors)}/
|
@@ -55,10 +56,12 @@ module Sequel
|
|
55
56
|
NotNullConstraintViolation
|
56
57
|
when 1062
|
57
58
|
UniqueConstraintViolation
|
58
|
-
when 1451, 1452
|
59
|
+
when 1451, 1452, 1216, 1217
|
59
60
|
ForeignKeyConstraintViolation
|
60
61
|
when 4025
|
61
62
|
CheckConstraintViolation
|
63
|
+
when 1205
|
64
|
+
DatabaseLockTimeout
|
62
65
|
else
|
63
66
|
super
|
64
67
|
end
|
@@ -80,6 +80,12 @@ module Sequel
|
|
80
80
|
SQL::DelayedEvaluation.new(lambda{|ds| v(o.call(ds))})
|
81
81
|
when SQL::Wrapper
|
82
82
|
SQL::Wrapper.new(v(o.value))
|
83
|
+
when SQL::Expression
|
84
|
+
if o.respond_to?(:sequel_ast_transform)
|
85
|
+
o.sequel_ast_transform(method(:v))
|
86
|
+
else
|
87
|
+
o
|
88
|
+
end
|
83
89
|
else
|
84
90
|
o
|
85
91
|
end
|
@@ -41,7 +41,10 @@ class Sequel::ShardedSingleConnectionPool < Sequel::ConnectionPool
|
|
41
41
|
# :server :: Should be a symbol specifing the server to disconnect from,
|
42
42
|
# or an array of symbols to specify multiple servers.
|
43
43
|
def disconnect(opts=OPTS)
|
44
|
-
(opts[:server] ? Array(opts[:server]) : servers).each
|
44
|
+
(opts[:server] ? Array(opts[:server]) : servers).each do |s|
|
45
|
+
raise Sequel::Error, "invalid server: #{s}" unless @servers.has_key?(s)
|
46
|
+
disconnect_server(s)
|
47
|
+
end
|
45
48
|
end
|
46
49
|
|
47
50
|
def freeze
|
@@ -57,7 +57,7 @@ class Sequel::ShardedThreadedConnectionPool < Sequel::ThreadedConnectionPool
|
|
57
57
|
# it is yielding all of the connections, which means that until
|
58
58
|
# the method's block returns, the pool is locked.
|
59
59
|
def all_connections
|
60
|
-
t =
|
60
|
+
t = Sequel.current
|
61
61
|
sync do
|
62
62
|
@allocated.values.each do |threads|
|
63
63
|
threads.each do |thread, conn|
|
@@ -95,9 +95,7 @@ class Sequel::ShardedThreadedConnectionPool < Sequel::ThreadedConnectionPool
|
|
95
95
|
# or an array of symbols to specify multiple servers.
|
96
96
|
def disconnect(opts=OPTS)
|
97
97
|
(opts[:server] ? Array(opts[:server]) : sync{@servers.keys}).each do |s|
|
98
|
-
|
99
|
-
disconnect_connections(conns)
|
100
|
-
end
|
98
|
+
disconnect_connections(sync{disconnect_server_connections(s)})
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
@@ -121,7 +119,7 @@ class Sequel::ShardedThreadedConnectionPool < Sequel::ThreadedConnectionPool
|
|
121
119
|
# connection can be acquired, a Sequel::PoolTimeout is raised.
|
122
120
|
def hold(server=:default)
|
123
121
|
server = pick_server(server)
|
124
|
-
t =
|
122
|
+
t = Sequel.current
|
125
123
|
if conn = owned_connection(t, server)
|
126
124
|
return yield(conn)
|
127
125
|
end
|
@@ -203,9 +201,9 @@ class Sequel::ShardedThreadedConnectionPool < Sequel::ThreadedConnectionPool
|
|
203
201
|
|
204
202
|
until conn = assign_connection(thread, server)
|
205
203
|
elapsed = Sequel.elapsed_seconds_since(timer)
|
204
|
+
# :nocov:
|
206
205
|
raise_pool_timeout(elapsed, server) if elapsed > timeout
|
207
206
|
|
208
|
-
# :nocov:
|
209
207
|
# It's difficult to get to this point, it can only happen if there is a race condition
|
210
208
|
# where a connection cannot be acquired even after the thread is signalled by the condition variable
|
211
209
|
sync do
|
@@ -278,13 +276,15 @@ class Sequel::ShardedThreadedConnectionPool < Sequel::ThreadedConnectionPool
|
|
278
276
|
# Mark any allocated connections to be removed when they are checked back in. The calling
|
279
277
|
# code should already have the mutex before calling this.
|
280
278
|
def disconnect_server_connections(server)
|
281
|
-
|
279
|
+
remove_conns = allocated(server)
|
280
|
+
dis_conns = available_connections(server)
|
281
|
+
raise Sequel::Error, "invalid server: #{server}" unless remove_conns && dis_conns
|
282
282
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
283
|
+
@connections_to_remove.concat(remove_conns.values)
|
284
|
+
|
285
|
+
conns = dis_conns.dup
|
286
|
+
dis_conns.clear
|
287
|
+
@waiters[server].signal
|
288
288
|
conns
|
289
289
|
end
|
290
290
|
|
@@ -11,7 +11,7 @@ class Sequel::SingleConnectionPool < Sequel::ConnectionPool
|
|
11
11
|
|
12
12
|
# Yield the connection if one has been made.
|
13
13
|
def all_connections
|
14
|
-
yield @conn.first
|
14
|
+
yield @conn.first unless @conn.empty?
|
15
15
|
end
|
16
16
|
|
17
17
|
# Disconnect the connection from the database.
|
@@ -83,7 +83,7 @@ class Sequel::ThreadedConnectionPool < Sequel::ConnectionPool
|
|
83
83
|
# is available or the timeout expires. If the timeout expires before a
|
84
84
|
# connection can be acquired, a Sequel::PoolTimeout is raised.
|
85
85
|
def hold(server=nil)
|
86
|
-
t =
|
86
|
+
t = Sequel.current
|
87
87
|
if conn = owned_connection(t)
|
88
88
|
return yield(conn)
|
89
89
|
end
|
@@ -152,9 +152,9 @@ class Sequel::ThreadedConnectionPool < Sequel::ConnectionPool
|
|
152
152
|
|
153
153
|
until conn = assign_connection(thread)
|
154
154
|
elapsed = Sequel.elapsed_seconds_since(timer)
|
155
|
+
# :nocov:
|
155
156
|
raise_pool_timeout(elapsed) if elapsed > timeout
|
156
157
|
|
157
|
-
# :nocov:
|
158
158
|
# It's difficult to get to this point, it can only happen if there is a race condition
|
159
159
|
# where a connection cannot be acquired even after the thread is signalled by the condition variable
|
160
160
|
sync do
|