sequel 3.21.0 → 3.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +1131 -3
- data/MIT-LICENSE +1 -1
- data/README.rdoc +106 -65
- data/Rakefile +59 -27
- data/bin/sequel +50 -26
- data/doc/active_record.rdoc +68 -52
- data/doc/advanced_associations.rdoc +201 -75
- data/doc/association_basics.rdoc +327 -79
- data/doc/bin_sequel.rdoc +144 -0
- data/doc/cheat_sheet.rdoc +21 -21
- data/doc/core_extensions.rdoc +374 -0
- data/doc/dataset_basics.rdoc +10 -10
- data/doc/dataset_filtering.rdoc +54 -42
- data/doc/mass_assignment.rdoc +56 -0
- data/doc/migration.rdoc +89 -557
- data/doc/model_hooks.rdoc +80 -29
- data/doc/object_model.rdoc +576 -0
- data/doc/opening_databases.rdoc +121 -53
- data/doc/prepared_statements.rdoc +41 -15
- data/doc/querying.rdoc +137 -56
- data/doc/reflection.rdoc +36 -10
- data/doc/release_notes/3.22.0.txt +39 -0
- data/doc/release_notes/3.23.0.txt +172 -0
- data/doc/release_notes/3.24.0.txt +420 -0
- data/doc/release_notes/3.25.0.txt +88 -0
- data/doc/release_notes/3.26.0.txt +88 -0
- data/doc/release_notes/3.27.0.txt +82 -0
- data/doc/release_notes/3.28.0.txt +304 -0
- data/doc/release_notes/3.29.0.txt +459 -0
- data/doc/release_notes/3.30.0.txt +135 -0
- data/doc/release_notes/3.31.0.txt +146 -0
- data/doc/release_notes/3.32.0.txt +202 -0
- data/doc/release_notes/3.33.0.txt +157 -0
- data/doc/release_notes/3.34.0.txt +671 -0
- data/doc/release_notes/3.35.0.txt +144 -0
- data/doc/release_notes/3.36.0.txt +245 -0
- data/doc/release_notes/3.37.0.txt +338 -0
- data/doc/release_notes/3.38.0.txt +234 -0
- data/doc/release_notes/3.39.0.txt +237 -0
- data/doc/release_notes/3.40.0.txt +73 -0
- data/doc/release_notes/3.41.0.txt +155 -0
- data/doc/schema_modification.rdoc +585 -0
- data/doc/sharding.rdoc +99 -8
- data/doc/sql.rdoc +154 -112
- data/doc/testing.rdoc +169 -0
- data/doc/thread_safety.rdoc +17 -0
- data/doc/transactions.rdoc +137 -0
- data/doc/validations.rdoc +1 -1
- data/doc/virtual_rows.rdoc +78 -43
- data/lib/sequel/adapters/ado/access.rb +334 -0
- data/lib/sequel/adapters/ado/mssql.rb +18 -12
- data/lib/sequel/adapters/ado.rb +69 -21
- data/lib/sequel/adapters/amalgalite.rb +17 -14
- data/lib/sequel/adapters/cubrid.rb +143 -0
- data/lib/sequel/adapters/db2.rb +178 -85
- data/lib/sequel/adapters/dbi.rb +19 -21
- data/lib/sequel/adapters/do/mysql.rb +17 -11
- data/lib/sequel/adapters/do/postgres.rb +2 -61
- data/lib/sequel/adapters/do/sqlite.rb +0 -10
- data/lib/sequel/adapters/do.rb +20 -39
- data/lib/sequel/adapters/firebird.rb +33 -210
- data/lib/sequel/adapters/ibmdb.rb +452 -0
- data/lib/sequel/adapters/informix.rb +6 -29
- data/lib/sequel/adapters/jdbc/as400.rb +16 -34
- data/lib/sequel/adapters/jdbc/cubrid.rb +52 -0
- data/lib/sequel/adapters/jdbc/db2.rb +78 -0
- data/lib/sequel/adapters/jdbc/derby.rb +325 -0
- data/lib/sequel/adapters/jdbc/firebird.rb +24 -0
- data/lib/sequel/adapters/jdbc/h2.rb +68 -31
- data/lib/sequel/adapters/jdbc/hsqldb.rb +189 -0
- data/lib/sequel/adapters/jdbc/informix.rb +21 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +40 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +3 -33
- data/lib/sequel/adapters/jdbc/mysql.rb +16 -28
- data/lib/sequel/adapters/jdbc/oracle.rb +88 -25
- data/lib/sequel/adapters/jdbc/postgresql.rb +77 -52
- data/lib/sequel/adapters/jdbc/progress.rb +21 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +20 -10
- data/lib/sequel/adapters/jdbc/sqlserver.rb +72 -0
- data/lib/sequel/adapters/jdbc/transactions.rb +83 -0
- data/lib/sequel/adapters/jdbc.rb +308 -114
- data/lib/sequel/adapters/mock.rb +372 -0
- data/lib/sequel/adapters/mysql.rb +130 -230
- data/lib/sequel/adapters/mysql2.rb +64 -63
- data/lib/sequel/adapters/odbc/mssql.rb +17 -9
- data/lib/sequel/adapters/odbc.rb +29 -10
- data/lib/sequel/adapters/openbase.rb +7 -11
- data/lib/sequel/adapters/oracle.rb +364 -57
- data/lib/sequel/adapters/postgres.rb +379 -145
- data/lib/sequel/adapters/shared/access.rb +236 -11
- data/lib/sequel/adapters/shared/cubrid.rb +216 -0
- data/lib/sequel/adapters/shared/db2.rb +353 -0
- data/lib/sequel/adapters/shared/firebird.rb +231 -0
- data/lib/sequel/adapters/shared/informix.rb +53 -0
- data/lib/sequel/adapters/shared/mssql.rb +412 -116
- data/lib/sequel/adapters/shared/mysql.rb +396 -89
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +166 -0
- data/lib/sequel/adapters/shared/oracle.rb +262 -45
- data/lib/sequel/adapters/shared/postgres.rb +688 -279
- data/lib/sequel/adapters/shared/progress.rb +5 -8
- data/lib/sequel/adapters/shared/sqlite.rb +317 -96
- data/lib/sequel/adapters/sqlite.rb +109 -46
- data/lib/sequel/adapters/swift/mysql.rb +10 -12
- data/lib/sequel/adapters/swift/postgres.rb +13 -79
- data/lib/sequel/adapters/swift/sqlite.rb +9 -6
- data/lib/sequel/adapters/swift.rb +31 -27
- data/lib/sequel/adapters/tinytds.rb +177 -25
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +77 -0
- data/lib/sequel/adapters/utils/pg_types.rb +81 -0
- data/lib/sequel/adapters/utils/split_alter_table.rb +36 -0
- data/lib/sequel/adapters/utils/stored_procedures.rb +1 -11
- data/lib/sequel/ast_transformer.rb +194 -0
- data/lib/sequel/connection_pool/sharded_single.rb +23 -13
- data/lib/sequel/connection_pool/sharded_threaded.rb +64 -13
- data/lib/sequel/connection_pool/single.rb +11 -3
- data/lib/sequel/connection_pool/threaded.rb +69 -20
- data/lib/sequel/connection_pool.rb +20 -18
- data/lib/sequel/core.rb +143 -11
- data/lib/sequel/database/connecting.rb +66 -29
- data/lib/sequel/database/dataset.rb +4 -4
- data/lib/sequel/database/dataset_defaults.rb +63 -2
- data/lib/sequel/database/logging.rb +7 -2
- data/lib/sequel/database/misc.rb +192 -51
- data/lib/sequel/database/query.rb +299 -114
- data/lib/sequel/database/schema_generator.rb +103 -36
- data/lib/sequel/database/schema_methods.rb +310 -69
- data/lib/sequel/dataset/actions.rb +344 -90
- data/lib/sequel/dataset/features.rb +101 -8
- data/lib/sequel/dataset/graph.rb +42 -15
- data/lib/sequel/dataset/misc.rb +52 -25
- data/lib/sequel/dataset/mutation.rb +12 -7
- data/lib/sequel/dataset/prepared_statements.rb +68 -30
- data/lib/sequel/dataset/query.rb +322 -68
- data/lib/sequel/dataset/sql.rb +716 -293
- data/lib/sequel/dataset.rb +8 -0
- data/lib/sequel/exceptions.rb +4 -0
- data/lib/sequel/extensions/_pretty_table.rb +83 -0
- data/lib/sequel/extensions/arbitrary_servers.rb +109 -0
- data/lib/sequel/extensions/blank.rb +4 -0
- data/lib/sequel/extensions/columns_introspection.rb +72 -0
- data/lib/sequel/extensions/connection_validator.rb +109 -0
- data/lib/sequel/extensions/constraint_validations.rb +451 -0
- data/lib/sequel/{core_sql.rb → extensions/core_extensions.rb} +30 -46
- data/lib/sequel/extensions/eval_inspect.rb +173 -0
- data/lib/sequel/extensions/inflector.rb +4 -0
- data/lib/sequel/extensions/looser_typecasting.rb +5 -4
- data/lib/sequel/extensions/migration.rb +100 -11
- data/lib/sequel/extensions/named_timezones.rb +9 -0
- data/lib/sequel/extensions/null_dataset.rb +94 -0
- data/lib/sequel/extensions/pagination.rb +4 -0
- data/lib/sequel/extensions/pg_array.rb +539 -0
- data/lib/sequel/extensions/pg_array_ops.rb +263 -0
- data/lib/sequel/extensions/pg_auto_parameterize.rb +175 -0
- data/lib/sequel/extensions/pg_hstore.rb +334 -0
- data/lib/sequel/extensions/pg_hstore_ops.rb +293 -0
- data/lib/sequel/extensions/pg_inet.rb +113 -0
- data/lib/sequel/extensions/pg_interval.rb +191 -0
- data/lib/sequel/extensions/pg_json.rb +212 -0
- data/lib/sequel/extensions/pg_range.rb +513 -0
- data/lib/sequel/extensions/pg_range_ops.rb +150 -0
- data/lib/sequel/extensions/pg_row.rb +576 -0
- data/lib/sequel/extensions/pg_row_ops.rb +182 -0
- data/lib/sequel/extensions/pg_statement_cache.rb +317 -0
- data/lib/sequel/extensions/pretty_table.rb +17 -72
- data/lib/sequel/extensions/query.rb +8 -4
- data/lib/sequel/extensions/query_literals.rb +79 -0
- data/lib/sequel/extensions/schema_caching.rb +76 -0
- data/lib/sequel/extensions/schema_dumper.rb +282 -76
- data/lib/sequel/extensions/select_remove.rb +39 -0
- data/lib/sequel/extensions/server_block.rb +140 -0
- data/lib/sequel/extensions/split_array_nil.rb +65 -0
- data/lib/sequel/extensions/sql_expr.rb +8 -110
- data/lib/sequel/extensions/string_date_time.rb +4 -0
- data/lib/sequel/extensions/thread_local_timezones.rb +10 -4
- data/lib/sequel/extensions/to_dot.rb +99 -83
- data/lib/sequel/model/associations.rb +1263 -409
- data/lib/sequel/model/base.rb +624 -171
- data/lib/sequel/model/errors.rb +1 -1
- data/lib/sequel/model/exceptions.rb +24 -2
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/model.rb +30 -11
- data/lib/sequel/no_core_ext.rb +2 -0
- data/lib/sequel/plugins/active_model.rb +13 -1
- data/lib/sequel/plugins/association_pks.rb +137 -16
- data/lib/sequel/plugins/caching.rb +25 -18
- data/lib/sequel/plugins/class_table_inheritance.rb +4 -4
- data/lib/sequel/plugins/composition.rb +44 -12
- data/lib/sequel/plugins/constraint_validations.rb +198 -0
- data/lib/sequel/plugins/dataset_associations.rb +100 -0
- data/lib/sequel/plugins/defaults_setter.rb +72 -0
- data/lib/sequel/plugins/dirty.rb +214 -0
- data/lib/sequel/plugins/eager_each.rb +59 -0
- data/lib/sequel/plugins/force_encoding.rb +6 -6
- data/lib/sequel/plugins/hook_class_methods.rb +1 -1
- data/lib/sequel/plugins/identity_map.rb +134 -15
- data/lib/sequel/plugins/instance_filters.rb +10 -0
- data/lib/sequel/plugins/instance_hooks.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +77 -6
- data/lib/sequel/plugins/list.rb +13 -2
- data/lib/sequel/plugins/many_through_many.rb +103 -51
- data/lib/sequel/plugins/many_to_one_pk_lookup.rb +71 -0
- data/lib/sequel/plugins/nested_attributes.rb +150 -66
- data/lib/sequel/plugins/optimistic_locking.rb +8 -0
- data/lib/sequel/plugins/pg_row.rb +121 -0
- data/lib/sequel/plugins/pg_typecast_on_load.rb +65 -0
- data/lib/sequel/plugins/prepared_statements.rb +168 -0
- data/lib/sequel/plugins/prepared_statements_associations.rb +87 -0
- data/lib/sequel/plugins/prepared_statements_safe.rb +82 -0
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +59 -0
- data/lib/sequel/plugins/rcte_tree.rb +31 -17
- data/lib/sequel/plugins/schema.rb +8 -3
- data/lib/sequel/plugins/serialization.rb +98 -49
- data/lib/sequel/plugins/serialization_modification_detection.rb +63 -0
- data/lib/sequel/plugins/sharding.rb +21 -54
- data/lib/sequel/plugins/single_table_inheritance.rb +57 -12
- data/lib/sequel/plugins/static_cache.rb +99 -0
- data/lib/sequel/plugins/subclasses.rb +29 -3
- data/lib/sequel/plugins/tactical_eager_loading.rb +7 -7
- data/lib/sequel/plugins/timestamps.rb +1 -1
- data/lib/sequel/plugins/touch.rb +18 -6
- data/lib/sequel/plugins/tree.rb +3 -3
- data/lib/sequel/plugins/typecast_on_load.rb +9 -12
- data/lib/sequel/plugins/update_primary_key.rb +2 -2
- data/lib/sequel/plugins/validation_class_methods.rb +2 -1
- data/lib/sequel/plugins/validation_helpers.rb +57 -4
- data/lib/sequel/plugins/xml_serializer.rb +15 -4
- data/lib/sequel/sql.rb +721 -141
- data/lib/sequel/timezones.rb +67 -40
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +146 -0
- data/spec/adapters/firebird_spec.rb +53 -39
- data/spec/adapters/mssql_spec.rb +261 -66
- data/spec/adapters/mysql_spec.rb +597 -352
- data/spec/adapters/oracle_spec.rb +92 -117
- data/spec/adapters/postgres_spec.rb +2103 -341
- data/spec/adapters/spec_helper.rb +16 -6
- data/spec/adapters/sqlite_spec.rb +237 -76
- data/spec/core/connection_pool_spec.rb +270 -141
- data/spec/core/database_spec.rb +980 -524
- data/spec/core/dataset_spec.rb +1658 -1243
- data/spec/core/expression_filters_spec.rb +741 -334
- data/spec/core/mock_adapter_spec.rb +453 -0
- data/spec/core/object_graph_spec.rb +88 -129
- data/spec/core/schema_generator_spec.rb +4 -4
- data/spec/core/schema_spec.rb +556 -53
- data/spec/core/spec_helper.rb +7 -48
- data/spec/core_extensions_spec.rb +626 -0
- data/spec/extensions/active_model_spec.rb +13 -0
- data/spec/extensions/arbitrary_servers_spec.rb +110 -0
- data/spec/extensions/association_autoreloading_spec.rb +18 -10
- data/spec/extensions/association_dependencies_spec.rb +15 -25
- data/spec/extensions/association_pks_spec.rb +227 -33
- data/spec/extensions/association_proxies_spec.rb +4 -4
- data/spec/extensions/boolean_readers_spec.rb +25 -25
- data/spec/extensions/caching_spec.rb +47 -51
- data/spec/extensions/class_table_inheritance_spec.rb +31 -83
- data/spec/extensions/columns_introspection_spec.rb +91 -0
- data/spec/extensions/composition_spec.rb +18 -13
- data/spec/extensions/connection_validator_spec.rb +118 -0
- data/spec/extensions/constraint_validations_plugin_spec.rb +196 -0
- data/spec/extensions/constraint_validations_spec.rb +316 -0
- data/spec/extensions/dataset_associations_spec.rb +199 -0
- data/spec/extensions/defaults_setter_spec.rb +88 -0
- data/spec/extensions/dirty_spec.rb +155 -0
- data/spec/extensions/eager_each_spec.rb +34 -0
- data/spec/extensions/eval_inspect_spec.rb +67 -0
- data/spec/extensions/force_encoding_spec.rb +4 -2
- data/spec/extensions/hook_class_methods_spec.rb +97 -128
- data/spec/extensions/identity_map_spec.rb +142 -24
- data/spec/extensions/inflector_spec.rb +0 -4
- data/spec/extensions/instance_filters_spec.rb +11 -21
- data/spec/extensions/instance_hooks_spec.rb +72 -0
- data/spec/extensions/json_serializer_spec.rb +49 -12
- data/spec/extensions/lazy_attributes_spec.rb +16 -20
- data/spec/extensions/list_spec.rb +49 -40
- data/spec/extensions/looser_typecasting_spec.rb +7 -7
- data/spec/extensions/many_through_many_spec.rb +368 -254
- data/spec/extensions/many_to_one_pk_lookup_spec.rb +140 -0
- data/spec/extensions/migration_spec.rb +140 -35
- data/spec/extensions/named_timezones_spec.rb +29 -11
- data/spec/extensions/nested_attributes_spec.rb +268 -89
- data/spec/extensions/null_dataset_spec.rb +85 -0
- data/spec/extensions/optimistic_locking_spec.rb +24 -21
- data/spec/extensions/pg_array_ops_spec.rb +112 -0
- data/spec/extensions/pg_array_spec.rb +324 -0
- data/spec/extensions/pg_auto_parameterize_spec.rb +65 -0
- data/spec/extensions/pg_hstore_ops_spec.rb +140 -0
- data/spec/extensions/pg_hstore_spec.rb +200 -0
- data/spec/extensions/pg_inet_spec.rb +47 -0
- data/spec/extensions/pg_interval_spec.rb +72 -0
- data/spec/extensions/pg_json_spec.rb +99 -0
- data/spec/extensions/pg_range_ops_spec.rb +56 -0
- data/spec/extensions/pg_range_spec.rb +395 -0
- data/spec/extensions/pg_row_ops_spec.rb +58 -0
- data/spec/extensions/pg_row_plugin_spec.rb +49 -0
- data/spec/extensions/pg_row_spec.rb +340 -0
- data/spec/extensions/pg_statement_cache_spec.rb +208 -0
- data/spec/extensions/pg_typecast_on_load_spec.rb +58 -0
- data/spec/extensions/prepared_statements_associations_spec.rb +111 -0
- data/spec/extensions/prepared_statements_safe_spec.rb +61 -0
- data/spec/extensions/prepared_statements_spec.rb +87 -0
- data/spec/extensions/prepared_statements_with_pk_spec.rb +31 -0
- data/spec/extensions/pretty_table_spec.rb +7 -6
- data/spec/extensions/query_literals_spec.rb +167 -0
- data/spec/extensions/query_spec.rb +9 -3
- data/spec/extensions/rcte_tree_spec.rb +50 -43
- data/spec/extensions/schema_caching_spec.rb +41 -0
- data/spec/extensions/schema_dumper_spec.rb +434 -49
- data/spec/extensions/schema_spec.rb +30 -49
- data/spec/extensions/select_remove_spec.rb +38 -0
- data/spec/extensions/serialization_modification_detection_spec.rb +72 -0
- data/spec/extensions/serialization_spec.rb +86 -48
- data/spec/extensions/server_block_spec.rb +90 -0
- data/spec/extensions/sharding_spec.rb +69 -143
- data/spec/extensions/single_table_inheritance_spec.rb +65 -29
- data/spec/extensions/skip_create_refresh_spec.rb +1 -1
- data/spec/extensions/spec_helper.rb +34 -67
- data/spec/extensions/split_array_nil_spec.rb +24 -0
- data/spec/extensions/sql_expr_spec.rb +29 -60
- data/spec/extensions/static_cache_spec.rb +145 -0
- data/spec/extensions/subclasses_spec.rb +14 -0
- data/spec/extensions/tactical_eager_loading_spec.rb +17 -19
- data/spec/extensions/thread_local_timezones_spec.rb +22 -2
- data/spec/extensions/timestamps_spec.rb +6 -6
- data/spec/extensions/to_dot_spec.rb +8 -11
- data/spec/extensions/touch_spec.rb +53 -14
- data/spec/extensions/tree_spec.rb +11 -26
- data/spec/extensions/typecast_on_load_spec.rb +9 -6
- data/spec/extensions/update_primary_key_spec.rb +30 -24
- data/spec/extensions/validation_class_methods_spec.rb +77 -68
- data/spec/extensions/validation_helpers_spec.rb +48 -37
- data/spec/extensions/xml_serializer_spec.rb +29 -4
- data/spec/files/transaction_specified_migrations/001_create_alt_basic.rb +4 -0
- data/spec/files/transaction_specified_migrations/002_create_basic.rb +4 -0
- data/spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb +3 -0
- data/spec/files/transaction_unspecified_migrations/002_create_basic.rb +3 -0
- data/spec/integration/associations_test.rb +659 -21
- data/spec/integration/database_test.rb +25 -5
- data/spec/integration/dataset_test.rb +729 -141
- data/spec/integration/eager_loader_test.rb +38 -54
- data/spec/integration/migrator_test.rb +2 -3
- data/spec/integration/model_test.rb +81 -2
- data/spec/integration/plugin_test.rb +871 -160
- data/spec/integration/prepared_statement_test.rb +272 -128
- data/spec/integration/schema_test.rb +377 -57
- data/spec/integration/spec_helper.rb +49 -32
- data/spec/integration/timezone_test.rb +38 -12
- data/spec/integration/transaction_test.rb +183 -8
- data/spec/integration/type_test.rb +40 -8
- data/spec/model/association_reflection_spec.rb +207 -8
- data/spec/model/associations_spec.rb +1206 -693
- data/spec/model/base_spec.rb +334 -100
- data/spec/model/dataset_methods_spec.rb +45 -27
- data/spec/model/eager_loading_spec.rb +828 -692
- data/spec/model/hooks_spec.rb +355 -67
- data/spec/model/model_spec.rb +251 -179
- data/spec/model/plugins_spec.rb +24 -13
- data/spec/model/record_spec.rb +506 -232
- data/spec/model/spec_helper.rb +16 -77
- data/spec/model/validations_spec.rb +38 -2
- data/spec/rcov.opts +2 -0
- metadata +223 -81
- data/spec/core/core_sql_spec.rb +0 -451
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
= New Features
|
|
2
|
+
|
|
3
|
+
* A constraint_validations extension and plugin have been added,
|
|
4
|
+
which allow you to define validations when creating tables,
|
|
5
|
+
which are enforced by database constraints, and have those
|
|
6
|
+
validations be automatically discovered and used by your
|
|
7
|
+
Sequel::Model classes.
|
|
8
|
+
|
|
9
|
+
The extension is designed to be used in your migrations/schema
|
|
10
|
+
modification code:
|
|
11
|
+
|
|
12
|
+
DB.extension(:constraint_validations)
|
|
13
|
+
DB.create_constraint_validations_table
|
|
14
|
+
DB.create_table(:foos) do
|
|
15
|
+
primary_key :id
|
|
16
|
+
String :name
|
|
17
|
+
|
|
18
|
+
validate do
|
|
19
|
+
min_length 5, :name
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
This creates a database CHECK constraint that ensures that the
|
|
24
|
+
minimum length for the column is 5 characters. It also adds
|
|
25
|
+
metadata about the validation to the
|
|
26
|
+
sequel_constraint_validations table.
|
|
27
|
+
|
|
28
|
+
To have the model class automatically create validations, just
|
|
29
|
+
include the plugin in the model:
|
|
30
|
+
|
|
31
|
+
class Foo < Sequel::Model
|
|
32
|
+
plugin :constraint_validations
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Note that MySQL does not enforce CHECK constraints (it parses
|
|
36
|
+
but ignores them), so using the extension on MySQL does not
|
|
37
|
+
actually enforce constraints at the database level, though it
|
|
38
|
+
still does support the automatic model validations if the plugin
|
|
39
|
+
is used.
|
|
40
|
+
|
|
41
|
+
* Dataset#count now takes an argument or a virtual row block,
|
|
42
|
+
allowing you to do:
|
|
43
|
+
|
|
44
|
+
DB[:table].count(:column_name)
|
|
45
|
+
DB[:table].count{function_name(column1, column2)}
|
|
46
|
+
|
|
47
|
+
When count is given an argument, instead of returning the total
|
|
48
|
+
number of rows, it returns the number of rows where the
|
|
49
|
+
argument has a non-NULL value.
|
|
50
|
+
|
|
51
|
+
* Database#copy_into has been added to the postgres adapter when
|
|
52
|
+
the pg driver is being used, and can be used for very fast
|
|
53
|
+
inserts into tables if you already have the input preformatted
|
|
54
|
+
in PostgreSQL text or CSV format.
|
|
55
|
+
|
|
56
|
+
* set_table_not_null has been added to the alter table generator,
|
|
57
|
+
for a nicer API:
|
|
58
|
+
|
|
59
|
+
alter_table(:t){set_column_not_null :col}
|
|
60
|
+
# instead of
|
|
61
|
+
alter_table(:t){set_column_allow_null :col, false}
|
|
62
|
+
|
|
63
|
+
Additionally, set_column_allow_null now defaults the second
|
|
64
|
+
argument to true for a nicer API:
|
|
65
|
+
|
|
66
|
+
alter_table(:t){set_column_allow_null :col}
|
|
67
|
+
# instead of
|
|
68
|
+
alter_table(:t){set_column_allow_null :col, true}
|
|
69
|
+
|
|
70
|
+
* Database#supports_regexp? has been added for checking if the
|
|
71
|
+
database supports Regexp in filters. Currently, only MySQL and
|
|
72
|
+
PostgreSQL support Regexps.
|
|
73
|
+
|
|
74
|
+
Attempting to use a Regexp on a database that doesn't support it
|
|
75
|
+
now raises an error when attempting to generate the SQL, instead
|
|
76
|
+
of sending invalid SQL to the database.
|
|
77
|
+
|
|
78
|
+
* Sequel.char_length has been added for a cross platform
|
|
79
|
+
char_length function (emulated when char_length is not supported
|
|
80
|
+
natively by the database).
|
|
81
|
+
|
|
82
|
+
* Sequel.trim has been added for a cross platform trim function
|
|
83
|
+
(emulated when trim is not supported natively by the database).
|
|
84
|
+
|
|
85
|
+
* ValidationFailed and HookFailed exceptions now have a model method
|
|
86
|
+
that returns the model instance related to the exception. This
|
|
87
|
+
makes it possible to use Model.create inside a begin/rescue block
|
|
88
|
+
and get access to the underlying instance if there is a validation
|
|
89
|
+
or before/around hook error.
|
|
90
|
+
|
|
91
|
+
* The subclasses plugin now accepts a block, which is called with
|
|
92
|
+
each model class created. This is useful if you want to apply
|
|
93
|
+
changes to classes created in the future instead of just existing
|
|
94
|
+
classes.
|
|
95
|
+
|
|
96
|
+
* The validates_unique validation in the validation_helpers plugin
|
|
97
|
+
now accepts a :where option for a custom uniqueness filter. Among
|
|
98
|
+
other things this makes it easy to implement a case insensitive
|
|
99
|
+
uniqueness validation on a case sensitive column.
|
|
100
|
+
|
|
101
|
+
* The threaded connection pools now support a
|
|
102
|
+
:connection_handling=>:disconnect option, which makes them disconnect
|
|
103
|
+
connections after use instead of returning them to the pool. This
|
|
104
|
+
makes it possible to completely control connection lifetime using
|
|
105
|
+
Database#synchronize.
|
|
106
|
+
|
|
107
|
+
* The pg_row_op extension now has support for PGRowOp#*, for referencing
|
|
108
|
+
the members of the composite type as separate columns.
|
|
109
|
+
|
|
110
|
+
* MySQL's set type and default value are now recognized.
|
|
111
|
+
|
|
112
|
+
* bin/sequel now accepts a -c argument for running an arbitrary
|
|
113
|
+
code string instead of using an IRB prompt.
|
|
114
|
+
|
|
115
|
+
= Other Improvements
|
|
116
|
+
|
|
117
|
+
* Sequel now parses current date/timestamp column defaults when
|
|
118
|
+
parsing the schema for a table. The values will be returned
|
|
119
|
+
as Sequel::CURRENT_DATE for date columns and
|
|
120
|
+
Sequel::CURRENT_TIMESTAMP for timestamp columns.
|
|
121
|
+
|
|
122
|
+
The schema_dumper extension will work with these defaults, so
|
|
123
|
+
if you dump the schema for a table with a column that uses
|
|
124
|
+
a current timestamp default, the dumped schema will include
|
|
125
|
+
the default.
|
|
126
|
+
|
|
127
|
+
The defaults setter plugin also works with these changes, so
|
|
128
|
+
that when new model objects are instantiated, they get the
|
|
129
|
+
current Date/Time/DateTime values set.
|
|
130
|
+
|
|
131
|
+
* On MySQL and PostgreSQL, Sequel will now by default attempt
|
|
132
|
+
to combine multiple alter_table operations into a single
|
|
133
|
+
query where it believes it can do so correctly. This can
|
|
134
|
+
potentially improve performance ~N times, where N is the number
|
|
135
|
+
of alter table operations.
|
|
136
|
+
|
|
137
|
+
This can change the SQL used for old migrations (though it
|
|
138
|
+
shouldn't change the result), and is a potentially risky
|
|
139
|
+
change. This may be disabled by default in future versions
|
|
140
|
+
if it causes problems.
|
|
141
|
+
|
|
142
|
+
* The defaults_setter plugin now correctly sets false default
|
|
143
|
+
values.
|
|
144
|
+
|
|
145
|
+
* The schema_dumper plugin now preserves fractional seconds
|
|
146
|
+
in timestamp column defaults when dumping.
|
|
147
|
+
|
|
148
|
+
* Time->DateTime and DateTime->Time typecasts now retain
|
|
149
|
+
fractional seconds on ruby 1.8.
|
|
150
|
+
|
|
151
|
+
* Array arguments passed to most PGArrayOp methods are now
|
|
152
|
+
automatically wrapped in a PGArray. If you want to use this
|
|
153
|
+
support, you need to make sure to load both the pg_array
|
|
154
|
+
and pg_array_op extensions.
|
|
155
|
+
|
|
156
|
+
* Sequel now does a better job of finding the sequence for a
|
|
157
|
+
given table on PostgreSQL, handling more corner cases. A small
|
|
158
|
+
side effect of this is sometimes sequence names will be quoted.
|
|
159
|
+
|
|
160
|
+
* Some potential thread-safety issues when using Sequel with
|
|
161
|
+
PostgreSQL on a non-GVL ruby implementation have been fixed.
|
|
162
|
+
|
|
163
|
+
* Sequel now correctly caches the server version query on MySQL.
|
|
164
|
+
|
|
165
|
+
* Sets of alter_table operations on MySQL and Microsoft SQL Server
|
|
166
|
+
that require parsing the current database schema, where later
|
|
167
|
+
alter_table operations depend on earlier ones, should now work
|
|
168
|
+
correctly.
|
|
169
|
+
|
|
170
|
+
* You can now drop check constraints on tables on SQLite, though
|
|
171
|
+
doing so drops all check constraints on the table, not only the
|
|
172
|
+
specific check constraint given.
|
|
173
|
+
|
|
174
|
+
* The identity_map plugin no longer breaks if used with a model
|
|
175
|
+
without a primary key.
|
|
176
|
+
|
|
177
|
+
* Sequel::SQL::NegativeBooleanConstant now inherits from Constant
|
|
178
|
+
instead of BooleanConstant. This means that
|
|
179
|
+
|
|
180
|
+
Sequel::NULL == Sequel::NOTNULL
|
|
181
|
+
|
|
182
|
+
is now false instead of true.
|
|
183
|
+
|
|
184
|
+
* You can now override the convert_tinyint_to_bool settings on a
|
|
185
|
+
per-Dataset basis in the mysql and mysql2 adapters, though
|
|
186
|
+
the overriding is different depending on the adapter. Check the
|
|
187
|
+
commit log for details.
|
|
188
|
+
|
|
189
|
+
* timestamp(N) types are now recognized as datetime, which should
|
|
190
|
+
fix certain cases on Oracle.
|
|
191
|
+
|
|
192
|
+
* Dataset#insert now handles a single model instance argument
|
|
193
|
+
as a single value if the model uses the pg_row plugin.
|
|
194
|
+
|
|
195
|
+
* When joining a model dataset using a model class as the table
|
|
196
|
+
argument, a subselect is used unless the model is a simple select
|
|
197
|
+
from the underlying table.
|
|
198
|
+
|
|
199
|
+
* The specs now cleanup after themselves, dropping the tables that
|
|
200
|
+
they create for testing.
|
|
201
|
+
|
|
202
|
+
= Backwards Compatibility
|
|
203
|
+
|
|
204
|
+
* The defaults_setter plugin's behavior changed due to the
|
|
205
|
+
current date/timestamp support. Previously, it would not set
|
|
206
|
+
a value for the column, since the default wasn't recognized.
|
|
207
|
+
Therefore, the database would use the default value on insert,
|
|
208
|
+
which would be the database's current timestamp.
|
|
209
|
+
|
|
210
|
+
Now, the value is set to the current Date/Time/DateTime on
|
|
211
|
+
model object instantiation, so the database wouldn't use the
|
|
212
|
+
column default. Instead of the database's current timestamp
|
|
213
|
+
on insert, the column value will be the application's
|
|
214
|
+
current timestamp on model instantiation.
|
|
215
|
+
|
|
216
|
+
Users who don't want this behavior can remove the default values
|
|
217
|
+
in the model:
|
|
218
|
+
|
|
219
|
+
Model.default_values.delete(:column_name)
|
|
220
|
+
|
|
221
|
+
* Plain (non-model) datasets no longer allow insert to accept
|
|
222
|
+
a single model instance argument. Also, they no longer call
|
|
223
|
+
values on a single argument if the object responds to it.
|
|
224
|
+
|
|
225
|
+
* Plain (non-model) datasets no longer accept model classes as
|
|
226
|
+
tables in the join/graph methods. Also, they no longer call
|
|
227
|
+
table_name on the argument if the object responds to it.
|
|
228
|
+
|
|
229
|
+
* The schema_dumper extension now requires the eval_inspect
|
|
230
|
+
extension, which changes inspect output for
|
|
231
|
+
Sequel::SQL::Expression objects.
|
|
232
|
+
|
|
233
|
+
* Custom adapters that override Database#alter_table_sql_list now
|
|
234
|
+
need to make sure it returns an already flattened array.
|
|
235
|
+
|
|
236
|
+
* The identity_map_key method in the identity_map plugin now returns
|
|
237
|
+
nil instead of a random string if the given pk is nil.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
= New Features
|
|
2
|
+
|
|
3
|
+
* Sequel now has vastly improved support for Microsoft Access.
|
|
4
|
+
|
|
5
|
+
* Sequel now supports the CUBRID database, with a cubrid adapter
|
|
6
|
+
that uses the cubrid gem, and a jdbc/cubrid adapter for accessing
|
|
7
|
+
CUBRID via JDBC on JRuby.
|
|
8
|
+
|
|
9
|
+
* The association_pks plugin now supports composite keys.
|
|
10
|
+
|
|
11
|
+
* Database#transaction now accepts a :disconnect=>:retry option,
|
|
12
|
+
in which case it will automatically retry the block if it
|
|
13
|
+
detects a disconnection. This is potentially dangerous, and
|
|
14
|
+
should only be used if the entire block is idempotent. There
|
|
15
|
+
is also no checking against an infinite retry loop.
|
|
16
|
+
|
|
17
|
+
* SQL::CaseExpression#with_merged_expression has been added, for
|
|
18
|
+
converting a CaseExpression with an associated expression to
|
|
19
|
+
one without an associated expression, by merging the expression
|
|
20
|
+
into each condition.
|
|
21
|
+
|
|
22
|
+
= Other Improvements
|
|
23
|
+
|
|
24
|
+
* Sequel now quotes arguments/columns in common table expressions.
|
|
25
|
+
|
|
26
|
+
* Sequel now handles nil values correctly in the pg_row extension.
|
|
27
|
+
|
|
28
|
+
* Sequel::Postgres::HStore instances can now be marshalled.
|
|
29
|
+
|
|
30
|
+
* Sequel now uses clob for String :text=>true types on databases that
|
|
31
|
+
don't support a text type.
|
|
32
|
+
|
|
33
|
+
* On PostgreSQL, Sequel now quotes channel identifier names when using
|
|
34
|
+
LISTEN/NOTIFY.
|
|
35
|
+
|
|
36
|
+
* On PostgreSQL, Sequel now correctly handles the case where named
|
|
37
|
+
type conversion procs have been added before the Database object is
|
|
38
|
+
instantiated.
|
|
39
|
+
|
|
40
|
+
* On DB2, Sequel now explicitly sets NOT NULL for unique constraint
|
|
41
|
+
columns instead of foreign key columns. DB2 does not allow columns
|
|
42
|
+
in unique constraints to be NULL, but does allow foreign key columns
|
|
43
|
+
to be NULL.
|
|
44
|
+
|
|
45
|
+
* In the oracle adapter, clob values are now returned as ruby strings
|
|
46
|
+
upon retrieval.
|
|
47
|
+
|
|
48
|
+
* Sequel now detects more types of disconnections in the postgres,
|
|
49
|
+
mysql, and mysql2 adapters.
|
|
50
|
+
|
|
51
|
+
* If a database provides a default column value that isn't a ruby
|
|
52
|
+
string, it is used directly as the ruby default, instead of causing
|
|
53
|
+
the schema parsing to fail.
|
|
54
|
+
|
|
55
|
+
= Backwards Compatibility
|
|
56
|
+
|
|
57
|
+
* Code using Sequel's oracle adapter that expected clob values to be
|
|
58
|
+
returned as OCI8::CLOB instances needs to be modified to work with
|
|
59
|
+
ruby strings.
|
|
60
|
+
|
|
61
|
+
* Because Sequel now quotes column names in common table expressions,
|
|
62
|
+
those names are now case sensitive, which could break certain poorly
|
|
63
|
+
coded queries. Similar issues exist with the quoting of channel
|
|
64
|
+
identifier names in LISTEN/NOTIFY on PostgreSQL.
|
|
65
|
+
|
|
66
|
+
* The private Database#requires_return_generated_keys? method
|
|
67
|
+
has been removed from the jdbc adapter. Custom jdbc subadapters
|
|
68
|
+
relying on this method should override the private
|
|
69
|
+
Database#execute_statement_insert method instead to ensure that
|
|
70
|
+
RETURN_GENERATED_KEYS is used for insert statements.
|
|
71
|
+
|
|
72
|
+
* The private Dataset#argument_list and #argument_list_append methods
|
|
73
|
+
have been removed.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
= New Features
|
|
2
|
+
|
|
3
|
+
* A connection_validator extension has been added, which
|
|
4
|
+
automatically determines if connections checked out from the pool
|
|
5
|
+
are still valid. If they are not valid, the connection is
|
|
6
|
+
disconnected and another connection is used automatically,
|
|
7
|
+
transparent to user code.
|
|
8
|
+
|
|
9
|
+
Checking if connections are valid requires a query, so this
|
|
10
|
+
extension causes a performance hit. For that reason, connections
|
|
11
|
+
are only checked by default if they have been inactive for more than
|
|
12
|
+
a configured amount of time (1 hour by default). You can choose to
|
|
13
|
+
validate connections on every checkout via:
|
|
14
|
+
|
|
15
|
+
DB.pool.connection_validation_timeout = -1
|
|
16
|
+
|
|
17
|
+
However, this can cause a substantial performance hit unless you are
|
|
18
|
+
purposely using coarse connection checkouts via manual calls to
|
|
19
|
+
Database#synchronize (for example, in a Rack middleware). Using
|
|
20
|
+
coarse checkouts can greatly reduce the amount of concurrency that
|
|
21
|
+
Sequel supports (for example, limiting the number of concurrent
|
|
22
|
+
requests to the number of database connections), so this method is
|
|
23
|
+
not without its tradeoffs.
|
|
24
|
+
|
|
25
|
+
* Sequel.delay has been added for a generic form of delayed
|
|
26
|
+
evaluation. This method takes a block and delays evaluating it
|
|
27
|
+
until query literalization. By default, Sequel evaluates most
|
|
28
|
+
arguments immediately:
|
|
29
|
+
|
|
30
|
+
foo = 1
|
|
31
|
+
ds = DB[:bar].where(:baz=>foo)
|
|
32
|
+
# SELECT * FROM bar WHERE (baz = 1)
|
|
33
|
+
foo = 2
|
|
34
|
+
ds
|
|
35
|
+
# SELECT * FROM bar WHERE (baz = 1)
|
|
36
|
+
|
|
37
|
+
Using Sequel.delay, you can delay the evaluation:
|
|
38
|
+
|
|
39
|
+
foo = 1
|
|
40
|
+
ds = DB[:bar].where(:baz=>Sequel.delay{foo})
|
|
41
|
+
# SELECT * FROM bar WHERE (baz = 1)
|
|
42
|
+
foo = 2
|
|
43
|
+
ds
|
|
44
|
+
# SELECT * FROM bar WHERE (baz = 2)
|
|
45
|
+
|
|
46
|
+
* Sequel now supports the :unlogged option when creating tables on
|
|
47
|
+
PostgreSQL, to create an UNLOGGED table.
|
|
48
|
+
|
|
49
|
+
* On SQLite, Database#transaction now supports a :mode option for
|
|
50
|
+
setting up IMMEDIATE/EXCLUSIVE SQLite transactions. Sequel also
|
|
51
|
+
supports a Database#transaction_mode accessor for setting the
|
|
52
|
+
default transaction mode on SQLite.
|
|
53
|
+
|
|
54
|
+
* Most pg_* extension objects (e.g. PGArray) now support the #as
|
|
55
|
+
method for creating an SQL::AliasedExpression object.
|
|
56
|
+
|
|
57
|
+
* The single_table_inheritance plugin now supports non-bijective
|
|
58
|
+
mappings. In lay terms, this means that a one-to-one mapping
|
|
59
|
+
of column values to classes is no longer required. You can now
|
|
60
|
+
have multiple column values that map to a single class in the
|
|
61
|
+
:model_map option, and specify a :key_chooser option to choose
|
|
62
|
+
which column value to use for the given model class.
|
|
63
|
+
|
|
64
|
+
* The touch plugin now handles the touching of many_to_many
|
|
65
|
+
associations, and other associations that use joined datasets.
|
|
66
|
+
|
|
67
|
+
* ConnectionPool#pool_type has been added. It returns a symbol
|
|
68
|
+
representing the type of connection pool in use (similar to
|
|
69
|
+
Database#database_type).
|
|
70
|
+
|
|
71
|
+
* Database#valid_connection? has been added for checking if a given
|
|
72
|
+
connection is still valid.
|
|
73
|
+
|
|
74
|
+
* Database#disconnect_connection is now part of the public API, and
|
|
75
|
+
can be used to disconnect a given connection.
|
|
76
|
+
|
|
77
|
+
= Other Improvements
|
|
78
|
+
|
|
79
|
+
* Uniqueness validation now correctly handles nil values.
|
|
80
|
+
Previously, it checked the underlying table for other rows where
|
|
81
|
+
the column IS NULL, but that is incorrect behavior. Sequel's new
|
|
82
|
+
(correct) behavior is to skip the uniqueness check if the column
|
|
83
|
+
is nil.
|
|
84
|
+
|
|
85
|
+
* Foreign key parsing is now supported on Microsoft SQL Server.
|
|
86
|
+
|
|
87
|
+
* Dataset#reverse and #reverse_order now accept virtual row blocks.
|
|
88
|
+
|
|
89
|
+
* Changing the name of the primary key column, and possibly other
|
|
90
|
+
schema changes on the primary key column, are now supported on
|
|
91
|
+
MySQL.
|
|
92
|
+
|
|
93
|
+
* Primary key columns are now specifically marked as NOT NULL on
|
|
94
|
+
SQLite, as non-integer primary keys on SQLite are not considered
|
|
95
|
+
NOT NULL by default.
|
|
96
|
+
|
|
97
|
+
* Failure to create a native prepared statement is now handled
|
|
98
|
+
better in the postgres, mysql, and mysql2 adapters.
|
|
99
|
+
|
|
100
|
+
* Firebird now emulates selecting data without an underlying table
|
|
101
|
+
(e.g. DB.get(1)).
|
|
102
|
+
|
|
103
|
+
* Finding the name of the constraint that sets column defaults on
|
|
104
|
+
Microsoft SQL Server now works correctly on JRuby 1.7.
|
|
105
|
+
|
|
106
|
+
* An additional type of disconnect error is now recognized in the
|
|
107
|
+
jdbc/sqlserver adapter.
|
|
108
|
+
|
|
109
|
+
* Many adapters have been fixed so that they don't raise an exception
|
|
110
|
+
if trying to disconnect an already disconnected connection.
|
|
111
|
+
|
|
112
|
+
* Many adapters have been fixed so that
|
|
113
|
+
Database#log_connection_execute logs and executes the given SQL
|
|
114
|
+
on the connection.
|
|
115
|
+
|
|
116
|
+
* Many adapters have been fixed so that
|
|
117
|
+
Database#database_error_classes returns an array of database
|
|
118
|
+
exception classes for that adapter.
|
|
119
|
+
|
|
120
|
+
* Database#log_exception now handles a nil exception message.
|
|
121
|
+
|
|
122
|
+
* Dataset#limit(nil, nil) now resets offset in addition to limit, but
|
|
123
|
+
you should still use Dataset#unlimited instead.
|
|
124
|
+
|
|
125
|
+
* A bin/sequel usage quide has been added to the documentation.
|
|
126
|
+
|
|
127
|
+
= Backwards Compatibility
|
|
128
|
+
|
|
129
|
+
* Sequel now treats clob columns as strings instead of blobs
|
|
130
|
+
(except on DB2 when use_clob_as_blob = true). This can make it
|
|
131
|
+
so the values are returned as strings instead of SQL::Blob values.
|
|
132
|
+
Since SQL::Blob is a String subclass, this generally will
|
|
133
|
+
not affect user code unless you are passing the values as input
|
|
134
|
+
to a separate blob column.
|
|
135
|
+
|
|
136
|
+
* The Database <-> ConnectionPool interface was completely changed.
|
|
137
|
+
Sequel no longer supports custom connection procs or disconnection
|
|
138
|
+
procs in the connection pools. The :disconnection_proc Database
|
|
139
|
+
option is no longer respected, and blocks passed to Database.new
|
|
140
|
+
are now ignored.
|
|
141
|
+
|
|
142
|
+
This change should not be user-visible, but if you had any code
|
|
143
|
+
that was monkeying with the connection pool internals, you may
|
|
144
|
+
need to modify it.
|
|
145
|
+
|
|
146
|
+
* Code that was using the uniqueness check to also check for presence
|
|
147
|
+
should add a separate check for presence. Such code was broken,
|
|
148
|
+
as it only worked if there was already a NULL column value in the
|
|
149
|
+
table. If you were relying on this broken behavior, you should
|
|
150
|
+
clean up the NULL data in the column and then mark the database
|
|
151
|
+
column as NOT NULL.
|
|
152
|
+
|
|
153
|
+
* If you have code that specifically abuses the fact that non-integer
|
|
154
|
+
primary keys on SQLite allow NULL values by default, it will no
|
|
155
|
+
longer work.
|