sequel 4.49.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +70 -0
- data/README.rdoc +195 -136
- data/Rakefile +26 -42
- data/bin/sequel +3 -5
- data/doc/advanced_associations.rdoc +86 -163
- data/doc/association_basics.rdoc +197 -274
- data/doc/bin_sequel.rdoc +5 -3
- data/doc/cheat_sheet.rdoc +66 -43
- data/doc/code_order.rdoc +1 -8
- data/doc/core_extensions.rdoc +81 -56
- data/doc/dataset_basics.rdoc +8 -17
- data/doc/dataset_filtering.rdoc +81 -86
- data/doc/extensions.rdoc +3 -10
- data/doc/mass_assignment.rdoc +73 -30
- data/doc/migration.rdoc +19 -36
- data/doc/model_dataset_method_design.rdoc +14 -17
- data/doc/model_hooks.rdoc +15 -25
- data/doc/model_plugins.rdoc +10 -10
- data/doc/mssql_stored_procedures.rdoc +3 -3
- data/doc/object_model.rdoc +52 -70
- data/doc/opening_databases.rdoc +39 -32
- data/doc/postgresql.rdoc +48 -38
- data/doc/prepared_statements.rdoc +27 -22
- data/doc/querying.rdoc +173 -150
- data/doc/reflection.rdoc +5 -6
- data/doc/release_notes/5.0.0.txt +159 -0
- data/doc/schema_modification.rdoc +63 -60
- data/doc/security.rdoc +97 -88
- data/doc/sharding.rdoc +43 -30
- data/doc/sql.rdoc +53 -65
- data/doc/testing.rdoc +3 -5
- data/doc/thread_safety.rdoc +2 -4
- data/doc/transactions.rdoc +18 -17
- data/doc/validations.rdoc +48 -45
- data/doc/virtual_rows.rdoc +87 -115
- data/lib/sequel.rb +1 -1
- data/lib/sequel/adapters/ado.rb +9 -25
- data/lib/sequel/adapters/ado/access.rb +7 -13
- data/lib/sequel/adapters/ado/mssql.rb +2 -9
- data/lib/sequel/adapters/amalgalite.rb +3 -18
- data/lib/sequel/adapters/ibmdb.rb +9 -45
- data/lib/sequel/adapters/jdbc.rb +13 -73
- data/lib/sequel/adapters/jdbc/db2.rb +8 -37
- data/lib/sequel/adapters/jdbc/derby.rb +4 -50
- data/lib/sequel/adapters/jdbc/h2.rb +4 -25
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -26
- data/lib/sequel/adapters/jdbc/jtds.rb +2 -9
- data/lib/sequel/adapters/jdbc/mssql.rb +1 -11
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -15
- data/lib/sequel/adapters/jdbc/oracle.rb +4 -26
- data/lib/sequel/adapters/jdbc/postgresql.rb +2 -31
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +4 -17
- data/lib/sequel/adapters/jdbc/sqlite.rb +1 -7
- data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -13
- data/lib/sequel/adapters/jdbc/transactions.rb +1 -14
- data/lib/sequel/adapters/mock.rb +4 -30
- data/lib/sequel/adapters/mysql.rb +7 -44
- data/lib/sequel/adapters/mysql2.rb +5 -23
- data/lib/sequel/adapters/odbc.rb +0 -19
- data/lib/sequel/adapters/odbc/db2.rb +1 -1
- data/lib/sequel/adapters/odbc/mssql.rb +4 -12
- data/lib/sequel/adapters/odbc/oracle.rb +1 -1
- data/lib/sequel/adapters/oracle.rb +7 -13
- data/lib/sequel/adapters/postgres.rb +13 -57
- data/lib/sequel/adapters/postgresql.rb +1 -1
- data/lib/sequel/adapters/shared/access.rb +11 -51
- data/lib/sequel/adapters/shared/db2.rb +3 -61
- data/lib/sequel/adapters/shared/mssql.rb +21 -157
- data/lib/sequel/adapters/shared/mysql.rb +23 -224
- data/lib/sequel/adapters/shared/oracle.rb +13 -41
- data/lib/sequel/adapters/shared/postgres.rb +44 -259
- data/lib/sequel/adapters/shared/sqlanywhere.rb +4 -96
- data/lib/sequel/adapters/shared/sqlite.rb +12 -101
- data/lib/sequel/adapters/sqlanywhere.rb +4 -23
- data/lib/sequel/adapters/sqlite.rb +2 -19
- data/lib/sequel/adapters/tinytds.rb +5 -15
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +1 -1
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +2 -4
- data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +3 -6
- data/lib/sequel/adapters/utils/replace.rb +0 -5
- data/lib/sequel/adapters/utils/stored_procedures.rb +0 -2
- data/lib/sequel/adapters/utils/unmodified_identifiers.rb +2 -0
- data/lib/sequel/ast_transformer.rb +3 -94
- data/lib/sequel/connection_pool.rb +26 -28
- data/lib/sequel/connection_pool/sharded_single.rb +1 -4
- data/lib/sequel/connection_pool/sharded_threaded.rb +97 -95
- data/lib/sequel/connection_pool/single.rb +0 -2
- data/lib/sequel/connection_pool/threaded.rb +94 -110
- data/lib/sequel/core.rb +42 -101
- data/lib/sequel/database.rb +12 -2
- data/lib/sequel/database/connecting.rb +23 -60
- data/lib/sequel/database/dataset.rb +6 -9
- data/lib/sequel/database/dataset_defaults.rb +4 -48
- data/lib/sequel/database/features.rb +5 -4
- data/lib/sequel/database/logging.rb +2 -9
- data/lib/sequel/database/misc.rb +23 -55
- data/lib/sequel/database/query.rb +8 -13
- data/lib/sequel/database/schema_generator.rb +89 -64
- data/lib/sequel/database/schema_methods.rb +61 -79
- data/lib/sequel/database/transactions.rb +4 -24
- data/lib/sequel/dataset.rb +18 -10
- data/lib/sequel/dataset/actions.rb +53 -107
- data/lib/sequel/dataset/dataset_module.rb +3 -15
- data/lib/sequel/dataset/features.rb +30 -30
- data/lib/sequel/dataset/graph.rb +40 -49
- data/lib/sequel/dataset/misc.rb +12 -37
- data/lib/sequel/dataset/placeholder_literalizer.rb +4 -4
- data/lib/sequel/dataset/prepared_statements.rb +23 -51
- data/lib/sequel/dataset/query.rb +71 -155
- data/lib/sequel/dataset/sql.rb +30 -225
- data/lib/sequel/deprecated.rb +18 -27
- data/lib/sequel/exceptions.rb +1 -17
- data/lib/sequel/extensions/_model_pg_row.rb +0 -7
- data/lib/sequel/extensions/_pretty_table.rb +1 -3
- data/lib/sequel/extensions/arbitrary_servers.rb +10 -10
- data/lib/sequel/extensions/connection_expiration.rb +1 -1
- data/lib/sequel/extensions/connection_validator.rb +1 -1
- data/lib/sequel/extensions/constraint_validations.rb +11 -11
- data/lib/sequel/extensions/core_extensions.rb +39 -49
- data/lib/sequel/extensions/core_refinements.rb +39 -45
- data/lib/sequel/extensions/current_datetime_timestamp.rb +0 -4
- data/lib/sequel/extensions/date_arithmetic.rb +7 -7
- data/lib/sequel/extensions/duplicate_columns_handler.rb +12 -9
- data/lib/sequel/extensions/empty_array_consider_nulls.rb +2 -2
- data/lib/sequel/extensions/eval_inspect.rb +4 -11
- data/lib/sequel/extensions/freeze_datasets.rb +1 -69
- data/lib/sequel/extensions/from_block.rb +1 -35
- data/lib/sequel/extensions/graph_each.rb +2 -2
- data/lib/sequel/extensions/identifier_mangling.rb +9 -19
- data/lib/sequel/extensions/implicit_subquery.rb +2 -2
- data/lib/sequel/extensions/inflector.rb +4 -4
- data/lib/sequel/extensions/migration.rb +23 -40
- data/lib/sequel/extensions/no_auto_literal_strings.rb +2 -84
- data/lib/sequel/extensions/null_dataset.rb +2 -8
- data/lib/sequel/extensions/pagination.rb +1 -17
- data/lib/sequel/extensions/pg_array.rb +20 -189
- data/lib/sequel/extensions/pg_hstore.rb +11 -50
- data/lib/sequel/extensions/pg_hstore_ops.rb +2 -2
- data/lib/sequel/extensions/pg_inet.rb +2 -15
- data/lib/sequel/extensions/pg_interval.rb +1 -20
- data/lib/sequel/extensions/pg_json.rb +7 -27
- data/lib/sequel/extensions/pg_loose_count.rb +1 -1
- data/lib/sequel/extensions/pg_range.rb +6 -121
- data/lib/sequel/extensions/pg_range_ops.rb +1 -3
- data/lib/sequel/extensions/pg_row.rb +5 -77
- data/lib/sequel/extensions/pg_row_ops.rb +2 -13
- data/lib/sequel/extensions/query.rb +3 -4
- data/lib/sequel/extensions/round_timestamps.rb +0 -6
- data/lib/sequel/extensions/schema_dumper.rb +13 -13
- data/lib/sequel/extensions/select_remove.rb +3 -3
- data/lib/sequel/extensions/split_array_nil.rb +2 -2
- data/lib/sequel/extensions/sql_comments.rb +2 -2
- data/lib/sequel/extensions/string_agg.rb +11 -8
- data/lib/sequel/extensions/symbol_aref.rb +6 -20
- data/lib/sequel/model.rb +27 -62
- data/lib/sequel/model/associations.rb +128 -131
- data/lib/sequel/model/base.rb +171 -711
- data/lib/sequel/model/default_inflections.rb +1 -1
- data/lib/sequel/model/errors.rb +0 -3
- data/lib/sequel/model/exceptions.rb +2 -6
- data/lib/sequel/model/inflections.rb +1 -26
- data/lib/sequel/model/plugins.rb +1 -0
- data/lib/sequel/plugins/active_model.rb +2 -5
- data/lib/sequel/plugins/association_dependencies.rb +15 -15
- data/lib/sequel/plugins/association_pks.rb +14 -28
- data/lib/sequel/plugins/association_proxies.rb +6 -7
- data/lib/sequel/plugins/auto_validations.rb +4 -4
- data/lib/sequel/plugins/before_after_save.rb +0 -43
- data/lib/sequel/plugins/blacklist_security.rb +9 -8
- data/lib/sequel/plugins/boolean_readers.rb +3 -3
- data/lib/sequel/plugins/boolean_subsets.rb +2 -2
- data/lib/sequel/plugins/caching.rb +5 -5
- data/lib/sequel/plugins/class_table_inheritance.rb +71 -102
- data/lib/sequel/plugins/column_conflicts.rb +2 -2
- data/lib/sequel/plugins/column_select.rb +2 -2
- data/lib/sequel/plugins/composition.rb +15 -24
- data/lib/sequel/plugins/constraint_validations.rb +4 -3
- data/lib/sequel/plugins/csv_serializer.rb +13 -20
- data/lib/sequel/plugins/dataset_associations.rb +2 -2
- data/lib/sequel/plugins/def_dataset_method.rb +5 -5
- data/lib/sequel/plugins/defaults_setter.rb +1 -1
- data/lib/sequel/plugins/delay_add_association.rb +1 -1
- data/lib/sequel/plugins/finder.rb +16 -10
- data/lib/sequel/plugins/force_encoding.rb +1 -7
- data/lib/sequel/plugins/hook_class_methods.rb +4 -106
- data/lib/sequel/plugins/input_transformer.rb +10 -11
- data/lib/sequel/plugins/insert_returning_select.rb +1 -9
- data/lib/sequel/plugins/instance_filters.rb +5 -5
- data/lib/sequel/plugins/instance_hooks.rb +7 -52
- data/lib/sequel/plugins/inverted_subsets.rb +3 -1
- data/lib/sequel/plugins/json_serializer.rb +19 -19
- data/lib/sequel/plugins/lazy_attributes.rb +1 -10
- data/lib/sequel/plugins/list.rb +6 -6
- data/lib/sequel/plugins/many_through_many.rb +11 -8
- data/lib/sequel/plugins/mssql_optimistic_locking.rb +3 -3
- data/lib/sequel/plugins/nested_attributes.rb +18 -31
- data/lib/sequel/plugins/optimistic_locking.rb +3 -3
- data/lib/sequel/plugins/pg_array_associations.rb +8 -2
- data/lib/sequel/plugins/pg_row.rb +2 -11
- data/lib/sequel/plugins/prepared_statements.rb +13 -66
- data/lib/sequel/plugins/prepared_statements_safe.rb +1 -1
- data/lib/sequel/plugins/rcte_tree.rb +7 -7
- data/lib/sequel/plugins/serialization.rb +15 -33
- data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +2 -8
- data/lib/sequel/plugins/single_table_inheritance.rb +10 -13
- data/lib/sequel/plugins/skip_create_refresh.rb +3 -3
- data/lib/sequel/plugins/static_cache.rb +8 -9
- data/lib/sequel/plugins/string_stripper.rb +3 -3
- data/lib/sequel/plugins/subclasses.rb +1 -1
- data/lib/sequel/plugins/subset_conditions.rb +2 -2
- data/lib/sequel/plugins/table_select.rb +2 -2
- data/lib/sequel/plugins/tactical_eager_loading.rb +4 -4
- data/lib/sequel/plugins/timestamps.rb +6 -7
- data/lib/sequel/plugins/touch.rb +4 -8
- data/lib/sequel/plugins/tree.rb +3 -3
- data/lib/sequel/plugins/typecast_on_load.rb +2 -2
- data/lib/sequel/plugins/unlimited_update.rb +1 -7
- data/lib/sequel/plugins/update_or_create.rb +3 -3
- data/lib/sequel/plugins/update_refresh.rb +3 -3
- data/lib/sequel/plugins/uuid.rb +7 -11
- data/lib/sequel/plugins/validation_class_methods.rb +10 -9
- data/lib/sequel/plugins/validation_contexts.rb +4 -4
- data/lib/sequel/plugins/validation_helpers.rb +26 -25
- data/lib/sequel/plugins/whitelist_security.rb +13 -9
- data/lib/sequel/plugins/xml_serializer.rb +24 -25
- data/lib/sequel/sql.rb +145 -276
- data/lib/sequel/timezones.rb +8 -22
- data/lib/sequel/version.rb +2 -2
- data/spec/adapter_spec.rb +1 -1
- data/spec/adapters/db2_spec.rb +2 -103
- data/spec/adapters/mssql_spec.rb +89 -68
- data/spec/adapters/mysql_spec.rb +101 -480
- data/spec/adapters/oracle_spec.rb +1 -9
- data/spec/adapters/postgres_spec.rb +312 -565
- data/spec/adapters/spec_helper.rb +12 -31
- data/spec/adapters/sqlanywhere_spec.rb +2 -77
- data/spec/adapters/sqlite_spec.rb +8 -146
- data/spec/bin_spec.rb +11 -16
- data/spec/core/connection_pool_spec.rb +173 -74
- data/spec/core/database_spec.rb +64 -244
- data/spec/core/dataset_spec.rb +81 -415
- data/spec/core/deprecated_spec.rb +3 -3
- data/spec/core/expression_filters_spec.rb +37 -144
- data/spec/core/mock_adapter_spec.rb +176 -4
- data/spec/core/object_graph_spec.rb +11 -60
- data/spec/core/placeholder_literalizer_spec.rb +1 -14
- data/spec/core/schema_generator_spec.rb +51 -40
- data/spec/core/schema_spec.rb +74 -77
- data/spec/core/spec_helper.rb +6 -24
- data/spec/core/version_spec.rb +1 -1
- data/spec/core_extensions_spec.rb +7 -83
- data/spec/core_model_spec.rb +2 -2
- data/spec/deprecation_helper.rb +2 -14
- data/spec/extensions/accessed_columns_spec.rb +1 -1
- data/spec/extensions/active_model_spec.rb +3 -3
- data/spec/extensions/after_initialize_spec.rb +1 -1
- data/spec/extensions/arbitrary_servers_spec.rb +2 -2
- data/spec/extensions/association_dependencies_spec.rb +1 -1
- data/spec/extensions/association_pks_spec.rb +4 -59
- data/spec/extensions/association_proxies_spec.rb +1 -1
- data/spec/extensions/auto_literal_strings_spec.rb +1 -12
- data/spec/extensions/auto_validations_spec.rb +1 -1
- data/spec/extensions/blacklist_security_spec.rb +1 -1
- data/spec/extensions/blank_spec.rb +1 -1
- data/spec/extensions/boolean_readers_spec.rb +1 -1
- data/spec/extensions/boolean_subsets_spec.rb +1 -1
- data/spec/extensions/caching_spec.rb +1 -1
- data/spec/extensions/class_table_inheritance_spec.rb +35 -1086
- data/spec/extensions/column_conflicts_spec.rb +1 -1
- data/spec/extensions/column_select_spec.rb +4 -4
- data/spec/extensions/columns_introspection_spec.rb +1 -1
- data/spec/extensions/columns_updated_spec.rb +1 -1
- data/spec/extensions/composition_spec.rb +1 -7
- data/spec/extensions/connection_expiration_spec.rb +3 -3
- data/spec/extensions/connection_validator_spec.rb +3 -3
- data/spec/extensions/constraint_validations_plugin_spec.rb +1 -1
- data/spec/extensions/constraint_validations_spec.rb +1 -1
- data/spec/extensions/core_refinements_spec.rb +1 -3
- data/spec/extensions/csv_serializer_spec.rb +4 -9
- data/spec/extensions/current_datetime_timestamp_spec.rb +1 -1
- data/spec/extensions/dataset_associations_spec.rb +2 -1
- data/spec/extensions/dataset_source_alias_spec.rb +1 -1
- data/spec/extensions/date_arithmetic_spec.rb +3 -3
- data/spec/extensions/def_dataset_method_spec.rb +1 -1
- data/spec/extensions/defaults_setter_spec.rb +2 -2
- data/spec/extensions/delay_add_association_spec.rb +8 -9
- data/spec/extensions/dirty_spec.rb +1 -1
- data/spec/extensions/duplicate_columns_handler_spec.rb +1 -1
- data/spec/extensions/eager_each_spec.rb +2 -2
- data/spec/extensions/empty_array_consider_nulls_spec.rb +1 -1
- data/spec/extensions/error_splitter_spec.rb +1 -1
- data/spec/extensions/error_sql_spec.rb +1 -1
- data/spec/extensions/eval_inspect_spec.rb +1 -1
- data/spec/extensions/finder_spec.rb +1 -1
- data/spec/extensions/force_encoding_spec.rb +2 -5
- data/spec/extensions/freeze_datasets_spec.rb +1 -1
- data/spec/extensions/graph_each_spec.rb +5 -5
- data/spec/extensions/hook_class_methods_spec.rb +1 -194
- data/spec/extensions/identifier_mangling_spec.rb +17 -170
- data/spec/extensions/implicit_subquery_spec.rb +1 -5
- data/spec/extensions/inflector_spec.rb +1 -1
- data/spec/extensions/input_transformer_spec.rb +7 -2
- data/spec/extensions/insert_returning_select_spec.rb +1 -1
- data/spec/extensions/instance_filters_spec.rb +1 -1
- data/spec/extensions/instance_hooks_spec.rb +1 -95
- data/spec/extensions/inverted_subsets_spec.rb +1 -1
- data/spec/extensions/json_serializer_spec.rb +1 -1
- data/spec/extensions/lazy_attributes_spec.rb +1 -7
- data/spec/extensions/list_spec.rb +1 -1
- data/spec/extensions/looser_typecasting_spec.rb +1 -1
- data/spec/extensions/many_through_many_spec.rb +1 -1
- data/spec/extensions/migration_spec.rb +2 -2
- data/spec/extensions/modification_detection_spec.rb +1 -1
- data/spec/extensions/mssql_optimistic_locking_spec.rb +1 -1
- data/spec/extensions/named_timezones_spec.rb +3 -3
- data/spec/extensions/nested_attributes_spec.rb +1 -29
- data/spec/extensions/null_dataset_spec.rb +1 -11
- data/spec/extensions/optimistic_locking_spec.rb +1 -1
- data/spec/extensions/pagination_spec.rb +1 -1
- data/spec/extensions/pg_array_associations_spec.rb +4 -1
- data/spec/extensions/pg_array_ops_spec.rb +1 -1
- data/spec/extensions/pg_array_spec.rb +3 -48
- data/spec/extensions/pg_enum_spec.rb +1 -1
- data/spec/extensions/pg_hstore_ops_spec.rb +1 -1
- data/spec/extensions/pg_hstore_spec.rb +23 -32
- data/spec/extensions/pg_inet_ops_spec.rb +1 -1
- data/spec/extensions/pg_inet_spec.rb +1 -14
- data/spec/extensions/pg_interval_spec.rb +3 -13
- data/spec/extensions/pg_json_ops_spec.rb +1 -1
- data/spec/extensions/pg_json_spec.rb +1 -13
- data/spec/extensions/pg_loose_count_spec.rb +1 -1
- data/spec/extensions/pg_range_ops_spec.rb +1 -1
- data/spec/extensions/pg_range_spec.rb +3 -88
- data/spec/extensions/pg_row_ops_spec.rb +1 -1
- data/spec/extensions/pg_row_plugin_spec.rb +1 -1
- data/spec/extensions/pg_row_spec.rb +1 -44
- data/spec/extensions/pg_static_cache_updater_spec.rb +1 -1
- data/spec/extensions/prepared_statements_safe_spec.rb +1 -1
- data/spec/extensions/prepared_statements_spec.rb +13 -48
- data/spec/extensions/pretty_table_spec.rb +1 -1
- data/spec/extensions/query_spec.rb +1 -12
- data/spec/extensions/rcte_tree_spec.rb +1 -1
- data/spec/extensions/round_timestamps_spec.rb +1 -5
- data/spec/extensions/s_spec.rb +1 -1
- data/spec/extensions/schema_caching_spec.rb +1 -1
- data/spec/extensions/schema_dumper_spec.rb +1 -1
- data/spec/extensions/select_remove_spec.rb +1 -1
- data/spec/extensions/sequel_4_dataset_methods_spec.rb +1 -1
- data/spec/extensions/serialization_modification_detection_spec.rb +1 -1
- data/spec/extensions/serialization_spec.rb +2 -14
- data/spec/extensions/server_block_spec.rb +1 -1
- data/spec/extensions/server_logging_spec.rb +2 -2
- data/spec/extensions/sharding_spec.rb +1 -1
- data/spec/extensions/shared_caching_spec.rb +1 -28
- data/spec/extensions/single_table_inheritance_spec.rb +2 -5
- data/spec/extensions/singular_table_names_spec.rb +1 -1
- data/spec/extensions/skip_create_refresh_spec.rb +1 -1
- data/spec/extensions/spec_helper.rb +5 -27
- data/spec/extensions/split_array_nil_spec.rb +1 -1
- data/spec/extensions/split_values_spec.rb +1 -1
- data/spec/extensions/sql_comments_spec.rb +1 -1
- data/spec/extensions/sql_expr_spec.rb +1 -1
- data/spec/extensions/static_cache_spec.rb +1 -1
- data/spec/extensions/string_agg_spec.rb +2 -2
- data/spec/extensions/string_date_time_spec.rb +1 -1
- data/spec/extensions/string_stripper_spec.rb +1 -1
- data/spec/extensions/subclasses_spec.rb +1 -1
- data/spec/extensions/subset_conditions_spec.rb +1 -1
- data/spec/extensions/symbol_aref_refinement_spec.rb +1 -1
- data/spec/extensions/symbol_as_refinement_spec.rb +1 -1
- data/spec/extensions/table_select_spec.rb +4 -4
- data/spec/extensions/tactical_eager_loading_spec.rb +1 -6
- data/spec/extensions/thread_local_timezones_spec.rb +1 -1
- data/spec/extensions/timestamps_spec.rb +3 -3
- data/spec/extensions/to_dot_spec.rb +1 -1
- data/spec/extensions/touch_spec.rb +1 -1
- data/spec/extensions/tree_spec.rb +1 -1
- data/spec/extensions/typecast_on_load_spec.rb +1 -1
- data/spec/extensions/unlimited_update_spec.rb +1 -1
- data/spec/extensions/update_or_create_spec.rb +1 -1
- data/spec/extensions/update_primary_key_spec.rb +4 -3
- data/spec/extensions/update_refresh_spec.rb +1 -1
- data/spec/extensions/uuid_spec.rb +10 -12
- data/spec/extensions/validate_associated_spec.rb +1 -1
- data/spec/extensions/validation_class_methods_spec.rb +3 -3
- data/spec/extensions/validation_contexts_spec.rb +1 -1
- data/spec/extensions/validation_helpers_spec.rb +10 -44
- data/spec/extensions/whitelist_security_spec.rb +5 -5
- data/spec/extensions/xml_serializer_spec.rb +3 -3
- data/spec/guards_helper.rb +2 -1
- data/spec/integration/associations_test.rb +1 -23
- data/spec/integration/database_test.rb +7 -7
- data/spec/integration/dataset_test.rb +5 -47
- data/spec/integration/eager_loader_test.rb +1 -1
- data/spec/integration/migrator_test.rb +1 -1
- data/spec/integration/model_test.rb +4 -82
- data/spec/integration/plugin_test.rb +6 -22
- data/spec/integration/prepared_statement_test.rb +8 -88
- data/spec/integration/schema_test.rb +6 -6
- data/spec/integration/spec_helper.rb +13 -21
- data/spec/integration/timezone_test.rb +5 -5
- data/spec/integration/transaction_test.rb +3 -55
- data/spec/integration/type_test.rb +9 -9
- data/spec/model/association_reflection_spec.rb +24 -9
- data/spec/model/associations_spec.rb +124 -303
- data/spec/model/base_spec.rb +18 -137
- data/spec/model/class_dataset_methods_spec.rb +2 -20
- data/spec/model/dataset_methods_spec.rb +1 -20
- data/spec/model/eager_loading_spec.rb +17 -11
- data/spec/model/hooks_spec.rb +5 -300
- data/spec/model/inflector_spec.rb +1 -1
- data/spec/model/model_spec.rb +15 -320
- data/spec/model/plugins_spec.rb +2 -16
- data/spec/model/record_spec.rb +29 -121
- data/spec/model/spec_helper.rb +5 -15
- data/spec/model/validations_spec.rb +1 -1
- data/spec/sequel_warning.rb +1 -12
- metadata +8 -64
- data/doc/active_record.rdoc +0 -927
- data/lib/sequel/adapters/cubrid.rb +0 -160
- data/lib/sequel/adapters/do.rb +0 -166
- data/lib/sequel/adapters/do/mysql.rb +0 -69
- data/lib/sequel/adapters/do/postgres.rb +0 -46
- data/lib/sequel/adapters/do/sqlite3.rb +0 -41
- data/lib/sequel/adapters/jdbc/as400.rb +0 -92
- data/lib/sequel/adapters/jdbc/cubrid.rb +0 -65
- data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -37
- data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -34
- data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -34
- data/lib/sequel/adapters/odbc/progress.rb +0 -12
- data/lib/sequel/adapters/shared/cubrid.rb +0 -245
- data/lib/sequel/adapters/shared/firebird.rb +0 -261
- data/lib/sequel/adapters/shared/informix.rb +0 -63
- data/lib/sequel/adapters/shared/progress.rb +0 -40
- data/lib/sequel/adapters/swift.rb +0 -169
- data/lib/sequel/adapters/swift/mysql.rb +0 -50
- data/lib/sequel/adapters/swift/postgres.rb +0 -49
- data/lib/sequel/adapters/swift/sqlite.rb +0 -48
- data/lib/sequel/adapters/utils/pg_types.rb +0 -4
- data/lib/sequel/dataset/mutation.rb +0 -98
- data/lib/sequel/extensions/_deprecated_identifier_mangling.rb +0 -117
- data/lib/sequel/extensions/empty_array_ignore_nulls.rb +0 -8
- data/lib/sequel/extensions/filter_having.rb +0 -65
- data/lib/sequel/extensions/hash_aliases.rb +0 -51
- data/lib/sequel/extensions/meta_def.rb +0 -37
- data/lib/sequel/extensions/query_literals.rb +0 -86
- data/lib/sequel/extensions/ruby18_symbol_extensions.rb +0 -26
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +0 -133
- data/lib/sequel/extensions/set_overrides.rb +0 -82
- data/lib/sequel/no_core_ext.rb +0 -4
- data/lib/sequel/plugins/association_autoreloading.rb +0 -11
- data/lib/sequel/plugins/identifier_columns.rb +0 -49
- data/lib/sequel/plugins/many_to_one_pk_lookup.rb +0 -11
- data/lib/sequel/plugins/pg_typecast_on_load.rb +0 -90
- data/lib/sequel/plugins/prepared_statements_associations.rb +0 -137
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +0 -71
- data/lib/sequel/plugins/schema.rb +0 -84
- data/lib/sequel/plugins/scissors.rb +0 -37
- data/spec/core/dataset_mutation_spec.rb +0 -253
- data/spec/extensions/_deprecated_identifier_mangling_spec.rb +0 -314
- data/spec/extensions/before_after_save_spec.rb +0 -40
- data/spec/extensions/filter_having_spec.rb +0 -42
- data/spec/extensions/from_block_spec.rb +0 -21
- data/spec/extensions/hash_aliases_spec.rb +0 -26
- data/spec/extensions/identifier_columns_spec.rb +0 -19
- data/spec/extensions/meta_def_spec.rb +0 -35
- data/spec/extensions/no_auto_literal_strings_spec.rb +0 -69
- data/spec/extensions/pg_typecast_on_load_spec.rb +0 -70
- data/spec/extensions/prepared_statements_associations_spec.rb +0 -212
- data/spec/extensions/prepared_statements_with_pk_spec.rb +0 -40
- data/spec/extensions/query_literals_spec.rb +0 -185
- data/spec/extensions/schema_spec.rb +0 -123
- data/spec/extensions/scissors_spec.rb +0 -27
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +0 -118
- data/spec/extensions/set_overrides_spec.rb +0 -75
data/doc/virtual_rows.rdoc
CHANGED
@@ -7,28 +7,16 @@ many Sequel::Dataset methods that take virtual row blocks.
|
|
7
7
|
|
8
8
|
== Why Virtual Rows
|
9
9
|
|
10
|
-
Virtual
|
11
|
-
|
12
|
-
following Sequel code historically worked on ruby 1.8, but not ruby 1.9:
|
13
|
-
|
14
|
-
dataset.where(:a > :b[:c])
|
15
|
-
# WHERE a > b(c)
|
16
|
-
|
17
|
-
This code does not work on ruby 1.9 for two reasons. First, Symbol#>
|
18
|
-
(like other inequality methods) is already defined in ruby 1.9, so Sequel
|
19
|
-
does not override it to return an SQL inequality expression. Second, Symbol#[]
|
20
|
-
is already defined on ruby 1.9, so Sequel does not override it to return an
|
21
|
-
SQL function expression.
|
22
|
-
|
23
|
-
It's possible to use Sequel's DSL to represent such expressions, but it is a
|
24
|
-
little verbose:
|
10
|
+
Virtual rows offer a less verbose way to express many queries. For example,
|
11
|
+
by default if you want to express an inequality filter in Sequel, you can do:
|
25
12
|
|
26
13
|
dataset.where(Sequel[:a] > Sequel.function(:b, :c))
|
27
|
-
# WHERE a > b(c)
|
14
|
+
# WHERE (a > b(c))
|
28
15
|
|
29
|
-
|
16
|
+
With virtual rows, you can use the less verbose:
|
30
17
|
|
31
18
|
dataset.where{a > b(c)}
|
19
|
+
# WHERE (a > b(c))
|
32
20
|
|
33
21
|
== Regular Procs vs Instance Evaled Procs
|
34
22
|
|
@@ -38,96 +26,101 @@ of Sequel::SQL::VirtualRow. If it does not accept an argument, it is
|
|
38
26
|
evaluated in the context of an instance of Sequel::SQL::VirtualRow.
|
39
27
|
|
40
28
|
ds = DB[:items]
|
41
|
-
# Regular
|
29
|
+
# Regular block
|
42
30
|
ds.where{|o| o.column > 1}
|
43
|
-
# WHERE column > 1
|
31
|
+
# WHERE (column > 1)
|
44
32
|
|
45
|
-
# Instance-evaled
|
33
|
+
# Instance-evaled block
|
46
34
|
ds.where{column > 1}
|
47
|
-
# WHERE column > 1
|
35
|
+
# WHERE (column > 1)
|
48
36
|
|
49
37
|
If you aren't familiar with the difference between regular blocks and instance
|
50
|
-
evaled blocks,
|
51
|
-
|
52
|
-
|
53
|
-
|
38
|
+
evaled blocks, inside regular blocks methods called without an explicit receiver call
|
39
|
+
the method on the receiver in the surrounding scope, while instance
|
40
|
+
evaled blocks call the method on the receiver of the instance_eval call (the
|
41
|
+
Sequel::SQL::VirtualRow instance in this case).
|
42
|
+
|
54
43
|
in both cases, local variables available in the surrounding scope will be available
|
55
|
-
inside the
|
44
|
+
inside the block. However, instance variables in the surrounding scope will not
|
45
|
+
be available inside the block if using an instance evaled block, and methods called
|
46
|
+
without an explicit receiver inside an instance evaled block will not call
|
47
|
+
methods in the surrounding scope. For example:
|
56
48
|
|
57
49
|
def self.a
|
58
50
|
42
|
59
51
|
end
|
60
52
|
b = 32
|
53
|
+
@d = 100
|
61
54
|
|
62
|
-
# Regular
|
63
|
-
ds.where{|o| o.c > a - b}
|
64
|
-
# WHERE c >
|
55
|
+
# Regular block
|
56
|
+
ds.where{|o| o.c > a - b + @d}
|
57
|
+
# WHERE (c > 100)
|
65
58
|
|
66
|
-
# Instance-evaled
|
67
|
-
ds.where{c > a - b}
|
68
|
-
# WHERE c > (a - 32)
|
59
|
+
# Instance-evaled block
|
60
|
+
ds.where{c > a - b + @d}
|
61
|
+
# WHERE (c > ((a - 32) + NULL))
|
69
62
|
|
70
|
-
There are
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
63
|
+
There are three related differences here:
|
64
|
+
|
65
|
+
* Regular blocks use +o.c+ instead of just +c+
|
66
|
+
* +a+ results in 42 in the regular block, but creates an expression object in the instance evaled block
|
67
|
+
* @d results in 100 in the regular block, but nil in the instance evaled block
|
68
|
+
|
69
|
+
In the regular block, you need to call +c+ with an explicit receiver (the virtual
|
70
|
+
row block argument), while in the instance evaled block +c+ can be called directly,
|
71
|
+
as the default receiver has changed inside the block.
|
72
|
+
|
73
|
+
For +a+, note how ruby calls the method on
|
74
|
+
the receiver of the surrounding scope in the regular block, which returns an integer,
|
75
75
|
and does the subtraction before Sequel gets access to it. In the instance evaled
|
76
|
-
|
76
|
+
block, calling +a+ without a receiver calls the a method on the VirtualRow instance.
|
77
|
+
For @d, note that in a regular block, the value hasn't changed, but in the instance evaled
|
78
|
+
block, instance variable access returns nil.
|
77
79
|
For +b+, note that it operates the same in both cases, as it is a local variable.
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
Instance evaled
|
82
|
-
can be more difficult
|
83
|
-
|
84
|
-
|
81
|
+
The choice for whether to use a regular block or an instance evaled block is
|
82
|
+
up to you. The same things can be accomplished with both.
|
83
|
+
Instance evaled block tend to produce shorter code, but by modifying the scope
|
84
|
+
can be more difficult to understand.
|
85
|
+
|
86
|
+
If you are not sure which to use, use instance evaled blocks unless you need to
|
87
|
+
call methods or access instance variables of the surrounding scope inside the block.
|
85
88
|
|
86
89
|
== Local Variables vs Method Calls
|
87
90
|
|
88
91
|
If you have a method that accepts 0 arguments and has the same name as a local
|
89
92
|
variable, you can call it with () to differentiate the method call from the
|
90
|
-
local variable access. This is mostly useful in
|
93
|
+
local variable access. This is mostly useful in instance evaled blocks:
|
91
94
|
|
92
95
|
b = 32
|
93
96
|
ds.where{b() > b}
|
94
97
|
# WHERE b > 32
|
95
98
|
|
99
|
+
It's also possible to use an explicit self receiver in instance evaled blocks:
|
100
|
+
|
101
|
+
b = 32
|
102
|
+
ds.where{self.b > b}
|
103
|
+
# WHERE b > 32
|
104
|
+
|
105
|
+
|
96
106
|
== VirtualRow Methods
|
97
107
|
|
98
|
-
VirtualRow is a class that returns SQL::Identifiers
|
99
|
-
|
108
|
+
VirtualRow is a class that returns SQL::Identifiers or SQL::Functions depending
|
109
|
+
on how it is called.
|
100
110
|
|
101
111
|
== SQL::Identifiers - Regular columns
|
102
112
|
|
103
113
|
SQL::Identifiers can be thought of as regular column references in SQL,
|
104
114
|
not qualified by any table. You get an SQL::Identifier if the method is called
|
105
|
-
without
|
106
|
-
name:
|
115
|
+
without arguments:
|
107
116
|
|
108
117
|
ds.where{|o| o.column > 1}
|
109
118
|
ds.where{column > 1}
|
110
|
-
# WHERE column > 1
|
119
|
+
# WHERE (column > 1)
|
111
120
|
|
112
121
|
== SQL::QualifiedIdentifiers - Qualified columns
|
113
122
|
|
114
|
-
|
115
|
-
are qualified to a specific table. You get an SQL::QualifiedIdentifier if
|
116
|
-
the method is called without a block or arguments, and has a double underscore
|
117
|
-
in the method name:
|
118
|
-
|
119
|
-
ds.where{|o| o.table__column > 1}
|
120
|
-
ds.where{table__column > 1}
|
121
|
-
# WHERE table.column > 1
|
122
|
-
|
123
|
-
Using the double underscore for SQL::QualifiedIdentifiers was done to make
|
124
|
-
usage very similar to using symbols, which by default also translate the
|
125
|
-
double underscore into a qualified column.
|
126
|
-
|
127
|
-
Note that when <tt>Sequel.split_symbols = false</tt> is used, then virtual
|
128
|
-
rows do not split symbols either. If you need to create qualified identifers
|
129
|
-
when disabling symbol splitting, it is easy to do by calling #[] on the
|
130
|
-
SQL::Identifiers returned by regular methods calls:
|
123
|
+
You can qualified identifiers by calling #[] on an identifier:
|
131
124
|
|
132
125
|
ds.where{|o| o.table[:column] > 1}
|
133
126
|
ds.where{table[:column] > 1}
|
@@ -136,7 +129,7 @@ SQL::Identifiers returned by regular methods calls:
|
|
136
129
|
== SQL::Functions - SQL function calls
|
137
130
|
|
138
131
|
SQL::Functions can be thought of as function calls in SQL. You get a simple
|
139
|
-
function call if you call a method with arguments
|
132
|
+
function call if you call a method with arguments:
|
140
133
|
|
141
134
|
ds.where{|o| o.function(1) > 1}
|
142
135
|
ds.where{function(1) > 1}
|
@@ -176,8 +169,7 @@ distinct method on the returned Function:
|
|
176
169
|
|
177
170
|
== SQL::Functions with windows - SQL window function calls
|
178
171
|
|
179
|
-
|
180
|
-
queries. To use them, you should just call the over method on the Function
|
172
|
+
To create a window function call, just call the over method on the Function
|
181
173
|
object returned, with the options for the window:
|
182
174
|
|
183
175
|
ds.select{|o| o.rank.function.over}
|
@@ -188,19 +180,18 @@ object returned, with the options for the window:
|
|
188
180
|
ds.select{count.function.*.over}
|
189
181
|
# SELECT count(*) OVER ()
|
190
182
|
|
191
|
-
ds.select{|o| o.sum(o.col1).over(:
|
192
|
-
ds.select{sum(col1).over(:
|
183
|
+
ds.select{|o| o.sum(o.col1).over(partition: o.col2, order: o.col3)}
|
184
|
+
ds.select{sum(col1).over(partition: col2, order: col3)}
|
193
185
|
# SELECT sum(col1) OVER (PARTITION BY col2 ORDER BY col3)
|
194
186
|
|
195
187
|
== Operators
|
196
188
|
|
197
189
|
VirtualRows use method_missing to handle almost all method calls. Since the
|
198
|
-
objects given by method_missing are SQL::Identifiers
|
199
|
-
or SQL::Functions, you can use all operators that they provide (see
|
190
|
+
objects given by method_missing are SQL::Identifiers or SQL::Functions, you can use all operators that they provide (see
|
200
191
|
DatasetFiltering[http://sequel.jeremyevans.net/rdoc/files/doc/dataset_filtering_rdoc.html#label-Filtering+using+expressions]):
|
201
192
|
|
202
193
|
ds.select{|o| o.price - 100}
|
203
|
-
ds.select{
|
194
|
+
ds.select{price - 100}
|
204
195
|
# SELECT (price - 100)
|
205
196
|
|
206
197
|
ds.where{|o| (o.price < 200) & (o.tax * 100 >= 23)}
|
@@ -222,14 +213,14 @@ The standard +, -, *, and / mathematical operators are defined:
|
|
222
213
|
|
223
214
|
The & and | methods are defined to use AND and OR:
|
224
215
|
|
225
|
-
ds.where{|o| o.&({:
|
226
|
-
ds.where{self.&({:
|
216
|
+
ds.where{|o| o.&({a: :b}, :c)}
|
217
|
+
ds.where{self.&({a: :b}, :c)}
|
227
218
|
# WHERE ((a = b) AND c)
|
228
219
|
|
229
220
|
The ~ method is defined to do inversion:
|
230
221
|
|
231
|
-
ds.where{|o| o.~({:
|
232
|
-
ds.where{self.~({:
|
222
|
+
ds.where{|o| o.~({a: 1, b: 2})}
|
223
|
+
ds.where{self.~({a: 1, b: 2})}
|
233
224
|
# WHERE ((a != 1) OR (b != 2))
|
234
225
|
|
235
226
|
=== Inequality Operators
|
@@ -240,19 +231,6 @@ The standard >, <, >=, and <= inequality operators are defined:
|
|
240
231
|
ds.where{self.>(1, :c)}
|
241
232
|
# WHERE (1 > c)
|
242
233
|
|
243
|
-
== Literal Strings
|
244
|
-
|
245
|
-
The backtick operator can be used inside an instance-evaled
|
246
|
-
virtual row block to create a literal string:
|
247
|
-
|
248
|
-
ds.where{a > `some SQL`}
|
249
|
-
# WHERE (a > some SQL)
|
250
|
-
|
251
|
-
You can use this on a regular virtual row block too, but it
|
252
|
-
doesn't look as nice:
|
253
|
-
|
254
|
-
ds.where{|o| o.>(:a, o.`('some SQL'))}
|
255
|
-
|
256
234
|
== Returning multiple values
|
257
235
|
|
258
236
|
It's common when using select and order virtual row blocks to want to
|
@@ -268,26 +246,20 @@ Note that if you forget the array brackets, you'll end up with a syntax error:
|
|
268
246
|
# Invalid ruby syntax
|
269
247
|
ds.select{|o| o.column1, o.sum(o.column2).as(o.sum)}
|
270
248
|
ds.select{column1, sum(column2).as(sum)}
|
271
|
-
|
272
|
-
==
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
name of the method used and the arguments given.
|
289
|
-
* If there are no arguments and the method contains a double
|
290
|
-
underscore, split on the double underscore and return an
|
291
|
-
SQL::QualifiedIdentifier with the table and column.
|
292
|
-
* Otherwise, create an SQL::Identifier with the name of the
|
293
|
-
method.
|
249
|
+
|
250
|
+
== Split symbols
|
251
|
+
|
252
|
+
Note that if you turn on symbol splitting for backwards compatibility,
|
253
|
+
Sequel will split virtual row methods with double underscores and
|
254
|
+
return them as qualified identifiers:
|
255
|
+
|
256
|
+
Sequel.split_symbols = true
|
257
|
+
ds.where{|o| o.table__column}
|
258
|
+
ds.where{table__column}
|
259
|
+
WHERE table.column
|
260
|
+
|
261
|
+
It's not recommended that you rely on this, it's better to convert the calls
|
262
|
+
to the recommended form:
|
263
|
+
|
264
|
+
ds.where{|o| o.table[:column]}
|
265
|
+
ds.where{table[:column]}
|
data/lib/sequel.rb
CHANGED
data/lib/sequel/adapters/ado.rb
CHANGED
@@ -61,14 +61,8 @@ module Sequel
|
|
61
61
|
Sequel.blob(v.pack('c*'))
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
Date.new(v.year, v.month, v.day)
|
67
|
-
end
|
68
|
-
else
|
69
|
-
def cp.date(v)
|
70
|
-
Date.new(*v[0...10].split('/').map{|x| x.to_i})
|
71
|
-
end
|
64
|
+
def cp.date(v)
|
65
|
+
Date.new(v.year, v.month, v.day)
|
72
66
|
end
|
73
67
|
|
74
68
|
CONVERSION_PROCS = {}
|
@@ -83,12 +77,9 @@ module Sequel
|
|
83
77
|
CONVERSION_PROCS[i] = method
|
84
78
|
end
|
85
79
|
end
|
86
|
-
|
80
|
+
CONVERSION_PROCS.freeze
|
87
81
|
|
88
82
|
class Database < Sequel::Database
|
89
|
-
DISCONNECT_ERROR_RE = /Communication link failure/
|
90
|
-
Sequel::Deprecation.deprecate_constant(self, :DISCONNECT_ERROR_RE)
|
91
|
-
|
92
83
|
set_adapter_scheme :ado
|
93
84
|
|
94
85
|
attr_reader :conversion_procs
|
@@ -99,7 +90,6 @@ module Sequel
|
|
99
90
|
# :command_timeout :: Sets the time in seconds to wait while attempting
|
100
91
|
# to execute a command before cancelling the attempt and generating
|
101
92
|
# an error. Specifically, it sets the ADO CommandTimeout property.
|
102
|
-
# If this property is not set, the default of 30 seconds is used.
|
103
93
|
# :driver :: The driver to use in the ADO connection string. If not provided, a default
|
104
94
|
# of "SQL Server" is used.
|
105
95
|
# :conn_string :: The full ADO connection string. If this is provided,
|
@@ -111,8 +101,8 @@ module Sequel
|
|
111
101
|
#
|
112
102
|
# Pay special attention to the :provider option, as without specifying a provider,
|
113
103
|
# many things will be broken. The SQLNCLI10 provider appears to work well if you
|
114
|
-
# are connecting to Microsoft SQL Server, but it is not the default as that
|
115
|
-
# break backwards compatability.
|
104
|
+
# are connecting to Microsoft SQL Server, but it is not the default as that is not
|
105
|
+
# always available and would break backwards compatability.
|
116
106
|
def connect(server)
|
117
107
|
opts = server_opts(server)
|
118
108
|
s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}"
|
@@ -184,14 +174,14 @@ module Sequel
|
|
184
174
|
def adapter_initialize
|
185
175
|
case @opts[:conn_string]
|
186
176
|
when /Microsoft\.(Jet|ACE)\.OLEDB/io
|
187
|
-
|
177
|
+
require_relative 'ado/access'
|
188
178
|
extend Sequel::ADO::Access::DatabaseMethods
|
189
179
|
self.dataset_class = ADO::Access::Dataset
|
190
180
|
else
|
191
181
|
@opts[:driver] ||= 'SQL Server'
|
192
182
|
case @opts[:driver]
|
193
183
|
when 'SQL Server'
|
194
|
-
|
184
|
+
require_relative 'ado/mssql'
|
195
185
|
extend Sequel::ADO::MSSQL::DatabaseMethods
|
196
186
|
self.dataset_class = ADO::MSSQL::Dataset
|
197
187
|
set_mssql_unicode_strings
|
@@ -232,9 +222,6 @@ module Sequel
|
|
232
222
|
end
|
233
223
|
|
234
224
|
class Dataset < Sequel::Dataset
|
235
|
-
Database::DatasetClass = self
|
236
|
-
Sequel::Deprecation.deprecate_constant(Database, :DatasetClass)
|
237
|
-
|
238
225
|
def fetch_rows(sql)
|
239
226
|
execute(sql) do |recordset|
|
240
227
|
cols = []
|
@@ -245,7 +232,7 @@ module Sequel
|
|
245
232
|
recordset.Fields.each do |field|
|
246
233
|
type = field.Type
|
247
234
|
cp = if type == AdDBTimeStamp
|
248
|
-
ts_cp ||=
|
235
|
+
ts_cp ||= begin
|
249
236
|
nsec_div = 1000000000.0/(10**(timestamp_precision))
|
250
237
|
nsec_mul = 10**(timestamp_precision+3)
|
251
238
|
meth = db.method(:to_application_timestamp)
|
@@ -253,9 +240,6 @@ module Sequel
|
|
253
240
|
# Fractional second handling is not correct on ruby <2.2
|
254
241
|
meth.call([v.year, v.month, v.day, v.hour, v.min, v.sec, (v.nsec/nsec_div).round * nsec_mul])
|
255
242
|
end
|
256
|
-
else
|
257
|
-
# Ruby 1.8 returns AdDBTimeStamp values as a string
|
258
|
-
db.method(:to_application_timestamp)
|
259
243
|
end
|
260
244
|
else
|
261
245
|
conversion_procs[type]
|
@@ -282,7 +266,7 @@ module Sequel
|
|
282
266
|
end
|
283
267
|
end
|
284
268
|
|
285
|
-
# ADO
|
269
|
+
# ADO can return for for delete and update statements, depending on the provider.
|
286
270
|
def provides_accurate_rows_matched?
|
287
271
|
false
|
288
272
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative '../shared/access'
|
4
|
+
require_relative '../utils/split_alter_table'
|
5
5
|
|
6
6
|
module Sequel
|
7
7
|
module ADO
|
@@ -15,7 +15,7 @@ module Sequel
|
|
15
15
|
:tables => 20,
|
16
16
|
:views => 23,
|
17
17
|
:foreign_keys => 27
|
18
|
-
}
|
18
|
+
}.freeze
|
19
19
|
|
20
20
|
attr_reader :type, :criteria
|
21
21
|
|
@@ -42,8 +42,8 @@ module Sequel
|
|
42
42
|
131 => "DECIMAL",
|
43
43
|
201 => "TEXT",
|
44
44
|
205 => "IMAGE"
|
45
|
-
}
|
46
|
-
|
45
|
+
}.freeze
|
46
|
+
DATA_TYPE.each_value(&:freeze)
|
47
47
|
|
48
48
|
def initialize(row)
|
49
49
|
@row = row
|
@@ -90,11 +90,6 @@ module Sequel
|
|
90
90
|
include Sequel::Access::DatabaseMethods
|
91
91
|
include Sequel::Database::SplitAlterTable
|
92
92
|
|
93
|
-
DECIMAL_TYPE_RE = /decimal/io
|
94
|
-
Sequel::Deprecation.deprecate_constant(self, :DECIMAL_TYPE_RE)
|
95
|
-
LAST_INSERT_ID = "SELECT @@IDENTITY".freeze
|
96
|
-
Sequel::Deprecation.deprecate_constant(self, :LAST_INSERT_ID)
|
97
|
-
|
98
93
|
# Remove cached schema after altering a table, since otherwise it can be cached
|
99
94
|
# incorrectly in the rename column case.
|
100
95
|
def alter_table(name, *)
|
@@ -134,7 +129,7 @@ module Sequel
|
|
134
129
|
ado_schema_views.map {|tbl| m.call(tbl['TABLE_NAME'])}
|
135
130
|
end
|
136
131
|
|
137
|
-
#
|
132
|
+
# OpenSchema returns compound indexes as multiple rows
|
138
133
|
def indexes(table_name,opts=OPTS)
|
139
134
|
m = output_identifier_meth
|
140
135
|
idxs = ado_schema_indexes(table_name).inject({}) do |memo, idx|
|
@@ -149,7 +144,7 @@ module Sequel
|
|
149
144
|
idxs
|
150
145
|
end
|
151
146
|
|
152
|
-
#
|
147
|
+
# OpenSchema returns compound foreign key relationships as multiple rows
|
153
148
|
def foreign_key_list(table, opts=OPTS)
|
154
149
|
m = output_identifier_meth
|
155
150
|
fks = ado_schema_foreign_keys(table).inject({}) do |memo, fk|
|
@@ -312,7 +307,6 @@ module Sequel
|
|
312
307
|
# This is like execute() in that it yields an ADO RecordSet, except
|
313
308
|
# instead of an SQL interface there's this OpenSchema call
|
314
309
|
# cf. http://msdn.microsoft.com/en-us/library/ee275721(v=bts.10)
|
315
|
-
#
|
316
310
|
def execute_open_ado_schema(type, criteria=[])
|
317
311
|
ado_schema = AdoSchema.new(type, criteria)
|
318
312
|
synchronize(opts[:server]) do |conn|
|