sequel 5.60.1 → 5.81.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.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +280 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +27 -24
  5. data/doc/advanced_associations.rdoc +16 -14
  6. data/doc/association_basics.rdoc +53 -17
  7. data/doc/cheat_sheet.rdoc +3 -3
  8. data/doc/code_order.rdoc +5 -3
  9. data/doc/dataset_basics.rdoc +1 -1
  10. data/doc/mass_assignment.rdoc +1 -1
  11. data/doc/migration.rdoc +15 -0
  12. data/doc/model_hooks.rdoc +1 -1
  13. data/doc/object_model.rdoc +8 -8
  14. data/doc/opening_databases.rdoc +18 -7
  15. data/doc/postgresql.rdoc +8 -8
  16. data/doc/querying.rdoc +7 -2
  17. data/doc/release_notes/5.61.0.txt +43 -0
  18. data/doc/release_notes/5.62.0.txt +132 -0
  19. data/doc/release_notes/5.63.0.txt +33 -0
  20. data/doc/release_notes/5.64.0.txt +50 -0
  21. data/doc/release_notes/5.65.0.txt +21 -0
  22. data/doc/release_notes/5.66.0.txt +24 -0
  23. data/doc/release_notes/5.67.0.txt +32 -0
  24. data/doc/release_notes/5.68.0.txt +61 -0
  25. data/doc/release_notes/5.69.0.txt +26 -0
  26. data/doc/release_notes/5.70.0.txt +35 -0
  27. data/doc/release_notes/5.71.0.txt +21 -0
  28. data/doc/release_notes/5.72.0.txt +33 -0
  29. data/doc/release_notes/5.73.0.txt +66 -0
  30. data/doc/release_notes/5.74.0.txt +45 -0
  31. data/doc/release_notes/5.75.0.txt +35 -0
  32. data/doc/release_notes/5.76.0.txt +86 -0
  33. data/doc/release_notes/5.77.0.txt +63 -0
  34. data/doc/release_notes/5.78.0.txt +67 -0
  35. data/doc/release_notes/5.79.0.txt +28 -0
  36. data/doc/release_notes/5.80.0.txt +40 -0
  37. data/doc/release_notes/5.81.0.txt +31 -0
  38. data/doc/schema_modification.rdoc +3 -3
  39. data/doc/security.rdoc +9 -9
  40. data/doc/sharding.rdoc +3 -1
  41. data/doc/sql.rdoc +14 -14
  42. data/doc/testing.rdoc +16 -12
  43. data/doc/transactions.rdoc +6 -6
  44. data/doc/virtual_rows.rdoc +1 -1
  45. data/lib/sequel/adapters/ibmdb.rb +1 -1
  46. data/lib/sequel/adapters/jdbc/h2.rb +3 -0
  47. data/lib/sequel/adapters/jdbc/hsqldb.rb +2 -0
  48. data/lib/sequel/adapters/jdbc/postgresql.rb +3 -0
  49. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +15 -0
  50. data/lib/sequel/adapters/jdbc/sqlserver.rb +4 -0
  51. data/lib/sequel/adapters/jdbc.rb +10 -6
  52. data/lib/sequel/adapters/mysql.rb +19 -7
  53. data/lib/sequel/adapters/mysql2.rb +2 -2
  54. data/lib/sequel/adapters/odbc/mssql.rb +1 -1
  55. data/lib/sequel/adapters/oracle.rb +1 -0
  56. data/lib/sequel/adapters/postgres.rb +10 -5
  57. data/lib/sequel/adapters/shared/access.rb +9 -1
  58. data/lib/sequel/adapters/shared/db2.rb +12 -0
  59. data/lib/sequel/adapters/shared/mssql.rb +71 -9
  60. data/lib/sequel/adapters/shared/mysql.rb +82 -3
  61. data/lib/sequel/adapters/shared/oracle.rb +17 -7
  62. data/lib/sequel/adapters/shared/postgres.rb +469 -160
  63. data/lib/sequel/adapters/shared/sqlanywhere.rb +18 -5
  64. data/lib/sequel/adapters/shared/sqlite.rb +39 -3
  65. data/lib/sequel/adapters/sqlite.rb +42 -3
  66. data/lib/sequel/adapters/trilogy.rb +117 -0
  67. data/lib/sequel/connection_pool/sharded_threaded.rb +16 -11
  68. data/lib/sequel/connection_pool/sharded_timed_queue.rb +374 -0
  69. data/lib/sequel/connection_pool/threaded.rb +14 -8
  70. data/lib/sequel/connection_pool/timed_queue.rb +270 -0
  71. data/lib/sequel/connection_pool.rb +57 -31
  72. data/lib/sequel/database/connecting.rb +25 -1
  73. data/lib/sequel/database/dataset.rb +16 -6
  74. data/lib/sequel/database/misc.rb +65 -14
  75. data/lib/sequel/database/query.rb +72 -1
  76. data/lib/sequel/database/schema_generator.rb +1 -1
  77. data/lib/sequel/database/schema_methods.rb +12 -5
  78. data/lib/sequel/database/transactions.rb +6 -0
  79. data/lib/sequel/dataset/actions.rb +60 -13
  80. data/lib/sequel/dataset/dataset_module.rb +1 -1
  81. data/lib/sequel/dataset/deprecated_singleton_class_methods.rb +42 -0
  82. data/lib/sequel/dataset/features.rb +15 -1
  83. data/lib/sequel/dataset/graph.rb +1 -0
  84. data/lib/sequel/dataset/misc.rb +12 -2
  85. data/lib/sequel/dataset/placeholder_literalizer.rb +20 -9
  86. data/lib/sequel/dataset/query.rb +119 -45
  87. data/lib/sequel/dataset/sql.rb +58 -36
  88. data/lib/sequel/dataset.rb +4 -0
  89. data/lib/sequel/exceptions.rb +5 -0
  90. data/lib/sequel/extensions/_model_pg_row.rb +0 -12
  91. data/lib/sequel/extensions/_pretty_table.rb +1 -1
  92. data/lib/sequel/extensions/any_not_empty.rb +2 -2
  93. data/lib/sequel/extensions/async_thread_pool.rb +21 -13
  94. data/lib/sequel/extensions/auto_cast_date_and_time.rb +94 -0
  95. data/lib/sequel/extensions/auto_literal_strings.rb +1 -1
  96. data/lib/sequel/extensions/caller_logging.rb +4 -1
  97. data/lib/sequel/extensions/connection_expiration.rb +15 -9
  98. data/lib/sequel/extensions/connection_validator.rb +16 -11
  99. data/lib/sequel/extensions/constraint_validations.rb +1 -1
  100. data/lib/sequel/extensions/date_arithmetic.rb +1 -1
  101. data/lib/sequel/extensions/duplicate_columns_handler.rb +10 -9
  102. data/lib/sequel/extensions/index_caching.rb +5 -1
  103. data/lib/sequel/extensions/looser_typecasting.rb +3 -0
  104. data/lib/sequel/extensions/migration.rb +65 -15
  105. data/lib/sequel/extensions/named_timezones.rb +22 -6
  106. data/lib/sequel/extensions/pg_array.rb +33 -4
  107. data/lib/sequel/extensions/pg_auto_parameterize.rb +509 -0
  108. data/lib/sequel/extensions/pg_auto_parameterize_in_array.rb +110 -0
  109. data/lib/sequel/extensions/pg_enum.rb +1 -2
  110. data/lib/sequel/extensions/pg_extended_date_support.rb +38 -27
  111. data/lib/sequel/extensions/pg_extended_integer_support.rb +116 -0
  112. data/lib/sequel/extensions/pg_hstore.rb +5 -0
  113. data/lib/sequel/extensions/pg_inet.rb +10 -11
  114. data/lib/sequel/extensions/pg_interval.rb +10 -11
  115. data/lib/sequel/extensions/pg_json.rb +10 -10
  116. data/lib/sequel/extensions/pg_json_ops.rb +3 -3
  117. data/lib/sequel/extensions/pg_multirange.rb +6 -11
  118. data/lib/sequel/extensions/pg_range.rb +9 -14
  119. data/lib/sequel/extensions/pg_row.rb +20 -19
  120. data/lib/sequel/extensions/pg_timestamptz.rb +27 -3
  121. data/lib/sequel/extensions/provenance.rb +110 -0
  122. data/lib/sequel/extensions/round_timestamps.rb +1 -1
  123. data/lib/sequel/extensions/schema_caching.rb +1 -1
  124. data/lib/sequel/extensions/schema_dumper.rb +32 -9
  125. data/lib/sequel/extensions/server_block.rb +2 -1
  126. data/lib/sequel/extensions/set_literalizer.rb +58 -0
  127. data/lib/sequel/extensions/sqlite_json_ops.rb +76 -18
  128. data/lib/sequel/extensions/temporarily_release_connection.rb +178 -0
  129. data/lib/sequel/extensions/transaction_connection_validator.rb +78 -0
  130. data/lib/sequel/model/associations.rb +38 -11
  131. data/lib/sequel/model/base.rb +32 -18
  132. data/lib/sequel/model/dataset_module.rb +3 -0
  133. data/lib/sequel/model/exceptions.rb +15 -3
  134. data/lib/sequel/plugins/auto_validations.rb +53 -15
  135. data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
  136. data/lib/sequel/plugins/column_encryption.rb +28 -7
  137. data/lib/sequel/plugins/composition.rb +2 -2
  138. data/lib/sequel/plugins/concurrent_eager_loading.rb +4 -4
  139. data/lib/sequel/plugins/constraint_validations.rb +8 -5
  140. data/lib/sequel/plugins/defaults_setter.rb +16 -0
  141. data/lib/sequel/plugins/dirty.rb +1 -1
  142. data/lib/sequel/plugins/finder.rb +4 -2
  143. data/lib/sequel/plugins/input_transformer.rb +1 -1
  144. data/lib/sequel/plugins/list.rb +5 -2
  145. data/lib/sequel/plugins/many_through_many.rb +1 -1
  146. data/lib/sequel/plugins/mssql_optimistic_locking.rb +8 -38
  147. data/lib/sequel/plugins/nested_attributes.rb +4 -4
  148. data/lib/sequel/plugins/optimistic_locking.rb +9 -42
  149. data/lib/sequel/plugins/optimistic_locking_base.rb +55 -0
  150. data/lib/sequel/plugins/paged_operations.rb +181 -0
  151. data/lib/sequel/plugins/pg_auto_constraint_validations.rb +9 -3
  152. data/lib/sequel/plugins/pg_xmin_optimistic_locking.rb +109 -0
  153. data/lib/sequel/plugins/prepared_statements.rb +2 -1
  154. data/lib/sequel/plugins/prepared_statements_safe.rb +2 -1
  155. data/lib/sequel/plugins/primary_key_lookup_check_values.rb +154 -0
  156. data/lib/sequel/plugins/rcte_tree.rb +7 -4
  157. data/lib/sequel/plugins/single_table_inheritance.rb +8 -0
  158. data/lib/sequel/plugins/sql_comments.rb +1 -1
  159. data/lib/sequel/plugins/static_cache.rb +38 -0
  160. data/lib/sequel/plugins/static_cache_cache.rb +5 -1
  161. data/lib/sequel/plugins/tactical_eager_loading.rb +14 -14
  162. data/lib/sequel/plugins/validate_associated.rb +22 -12
  163. data/lib/sequel/plugins/validation_helpers.rb +29 -2
  164. data/lib/sequel/plugins/validation_helpers_generic_type_messages.rb +73 -0
  165. data/lib/sequel/version.rb +2 -2
  166. metadata +79 -6
@@ -0,0 +1,33 @@
1
+ = New Features
2
+
3
+ * On Ruby 3.2, the pool_class: :timed_queue Database option can now
4
+ be used to use an alternative connection pool that stores
5
+ connections in a queue, and uses the new Queue#pop :timeout option
6
+ in Ruby 3.2 to implement the pool timeout. This new connection
7
+ pool is simpler than the default connection pool. It is not yet
8
+ the default connection pool on Ruby 3.2, but it may become the
9
+ default in a later version. Users of Ruby 3.2 are encouraged to
10
+ try out the pool_class: :timed_queue Database option and provide
11
+ feedback on how it works in their application.
12
+
13
+ = Other Improvements
14
+
15
+ * The tactical_eager_loading plugin now works in combination with the
16
+ single_table_inheritance and class_table_inheritance plugins, when
17
+ loading an association only defined in a specific subclass.
18
+ Previously, eager loading would be skipped in such a case. Now,
19
+ an eager load will be attempted for all instances supporting the
20
+ association.
21
+
22
+ * The validate_associated plugin now avoids database type errors for
23
+ non-integer association keys. In cases where the associated object
24
+ doesn't have a value for the associated key, and the current object
25
+ does not have a key value that can be set in the associated object,
26
+ validation errors in the associated object related to the associated
27
+ key will be ignored.
28
+
29
+ * Thread-keyed connection pool hashes now use compare_by_identity for
30
+ better performance.
31
+
32
+ * The JRuby workaround in the named_timezones extension is no longer
33
+ used on JRuby 9.3.9.0+, as JRuby fixed the related bug.
@@ -0,0 +1,50 @@
1
+ = New Features
2
+
3
+ * A :graph_use_association_block association option has been added,
4
+ which makes eager_graph use the association block (as eager does),
5
+ generally resulting in a JOIN to a subquery:
6
+
7
+ Artist.one_to_many :tracks, graph_use_association_block: true do |ds|
8
+ ds.where(foo: 3)
9
+ end
10
+ Artist.eager_graph(:tracks)
11
+ # SELECT albums.id, tracks.id AS tracks_id, tracks.album_id
12
+ # FROM albums
13
+ # LEFT OUTER JOIN (SELECT * FROM tracks WHERE (foo = 3)) AS tracks
14
+ # ON (tracks.album_id = albums.id)
15
+
16
+ Assuming that the database can optimize the query correctly, using
17
+ the :graph_use_association_block option is probably simpler than
18
+ than using other :graph_* options to duplicate the conditions added
19
+ by the association block.
20
+
21
+ * Numeric/Decimal column schema entries now include :min_value and
22
+ :max_value entries on most databases, indicating the minimum and
23
+ maximum values supported for the column. Similar to the support
24
+ for integer columns added in 5.62.0, this allows the
25
+ auto_validations plugin to automatically validate the values of
26
+ the columns are in the allowed range.
27
+
28
+ = Other Improvements
29
+
30
+ * many_through_{one,many} associations now support eager_graph
31
+ callbacks.
32
+
33
+ * The :db_type column schema entries on SQLAnywhere now include
34
+ precision/scale information, to work with the numeric/decimal
35
+ column min_value/max_value support.
36
+
37
+ * The oracle adapter now includes a :column_size column schema
38
+ entry containing the precision of the columns, to work with the
39
+ numeric/decimal column min_value/max_value support.
40
+
41
+ = Backwards Compatibility
42
+
43
+ * The private Database#column_schema_integer_min_max_values method
44
+ added in 5.62.0 now takes a column schema hash instead of a
45
+ database type string.
46
+
47
+ * Code that previously looked at the :db_type column schema entry on
48
+ SQLAnywhere should be updated to look at the :domain_name entry, and
49
+ code that looked at the :domain_name_with_size entry should be
50
+ updated to look at the :db_type entry.
@@ -0,0 +1,21 @@
1
+ = Improvements
2
+
3
+ * The pg_auto_parameterize extension now uses a modified placeholder
4
+ literalizer for speeding up the generation of SQL queries in the same
5
+ cases where a standard dataset would use a placeholder literalizer.
6
+ This can provide a 4% speedup for simple queries, with greater
7
+ speedups for more complex queries.
8
+
9
+ * Database#indexes now returns indexes for partitioned tables on
10
+ PostgreSQL 11+.
11
+
12
+ * MySQL versions not supporting CHECK constraints no longer include
13
+ :min_value/:max_value schema entries for decimal/numeric columns.
14
+
15
+ = Backwards Compatibility
16
+
17
+ * The Dataset::PlaceholderLiterlizer::Record.loader API has changed,
18
+ it now accepts the Dataset::PlaceholderLiterlizer class to use as
19
+ the first argument. This makes it easier to create
20
+ Dataset::PlaceholderLiterlizer subclasses, such as the one now used
21
+ by the pg_auto_parameterize extension.
@@ -0,0 +1,24 @@
1
+ = Improvements
2
+
3
+ * Dataset#empty? now correctly handles datasets using custom SQL or
4
+ Dataset#values where the first value in the first row is NULL.
5
+
6
+ * Dataset#count without an argument or block now works correctly on
7
+ Microsoft SQL Server when using custom SQL that uses ORDER BY.
8
+
9
+ * Dataset#count now works correctly for datasets using Dataset#values.
10
+
11
+ * Sequel now recognizes an additional SQLite constraint violation
12
+ error that occurs with recent versions of amalgalite.
13
+
14
+ * Dataset#values will now raise an exception when called with an empty
15
+ array. Previously, an exception would not be raised until the query
16
+ was sent to the database.
17
+
18
+ = Backwards Compatibility
19
+
20
+ * The changes to make Dataset#empty? and #count work with custom SQL
21
+ on Microsoft SQL Server now result in running the custom SQL, which
22
+ could result in worse performance than in previous versions. You can
23
+ wrap such datasets with Dataset#from_self manually to restore the
24
+ previous behavior.
@@ -0,0 +1,32 @@
1
+ = New Features
2
+
3
+ * A set_literalizer extension has been added, for treating Set
4
+ instances in datasets similar to Array instances:
5
+
6
+ DB.extension :set_literalizer
7
+ DB[:table].where(column: Set.new([1, 2, 3]))
8
+ # SELECT FROM table WHERE (column IN (1, 2, 3))
9
+
10
+ = Improvements
11
+
12
+ * Sequel now avoids the use of singleton classes for datasets on Ruby
13
+ 2.4+, instead creating a regular subclass whenever a dataset would
14
+ be extended via #extension or #with_extend. This significantly
15
+ improves performance, up to 20-40% for common dataset usage,
16
+ because it avoids creating new singleton classes for every dataset
17
+ clone, and it allows for cached method lookup.
18
+
19
+ * Database#tables and #views now support a :qualify option on Microsoft
20
+ SQL Server to returned qualified identifiers.
21
+
22
+ * The schema_dumper extension can now dump tables in non-default schemas
23
+ when using Microsoft SQL Server.
24
+
25
+ * The schema_dumper extension now correctly dumps string column sizes
26
+ when using Microsoft SQL Server.
27
+
28
+ = Backwards Compatibility
29
+
30
+ * Calling Sequel::Dataset.register_extension where the second argument
31
+ is not a module now issues a deprecation warning. Support for this
32
+ will be removed in Sequel 6.
@@ -0,0 +1,61 @@
1
+ = New Features
2
+
3
+ * On PostgreSQL 9.6+, date, timestamp, and timestamptz columns now
4
+ have min_value and max_value column schema entries, allowing the
5
+ auto_validations plugin to automatically enforce minimum and
6
+ maximum values for these column types, raising a validation error
7
+ before saving, instead of database error when the query is sent
8
+ to the database.
9
+
10
+ * A validation_helpers_generic_type_messages plugin has been added,
11
+ which improves the default type validation error messages in
12
+ validation_helpers. This change was not made directly to
13
+ validation_helpers for backwards compatibility reasons, but will
14
+ probably become the default behavior in Sequel 6. Some examples
15
+ of the improvements:
16
+
17
+ # :blob type
18
+ # validation_helpers default: "value is not a valid sequel::sql::blob"
19
+ # with this plugin: "value is not a blob"
20
+
21
+ # :boolean type
22
+ # validation_helpers default: "value is not a valid trueclass or falseclass"
23
+ # with this plugin: "value is not true or false"
24
+
25
+ # :datetime type
26
+ # validation_helpers default: "value is not a valid time or datetime"
27
+ # with this plugin: "value is not a valid timestamp"
28
+
29
+ # custom/database-specific types
30
+ # validation_helpers default: "value is not a valid sequel::class_name"
31
+ # with this plugin: "value is not the expected type"
32
+
33
+ = Improvements
34
+
35
+ * The constraint_validations plugin no longer raises validation
36
+ errors for missing columns that have a default value. If a column
37
+ is missing but has a default value, we can assume the default
38
+ value is valid. Additionally, the constraint validations are now
39
+ based on the underlying column value and not any deserialized
40
+ value, so that the validation matches the constraint.
41
+
42
+ * On PostgreSQL, normal type name parsing is skipped for enum,
43
+ array, composite, range, and multirange types, ensuring that
44
+ such types will not be treated incorrectly based on their
45
+ type name.
46
+
47
+ * The pg_extended_date_support extension now works correctly with
48
+ the jdbc/postgresql adapter if there is already an entry in the
49
+ oid_convertor_map for the timestamp and timestamptz types.
50
+
51
+ = Backwards Compatibility
52
+
53
+ * Database#schema_column_type is no longer called for all columns
54
+ on PostgreSQL when parsing schema. Enum, array, composite, range,
55
+ and multirange types each have their own separate type parsing
56
+ method. So if you were overriding Database#schema_column_type to
57
+ implement custom column schema parsing, you may need to adjust
58
+ your code.
59
+
60
+ * The Sequel::Postgres::ExtendedDateSupport::DATE_YEAR_1 constant
61
+ has been removed.
@@ -0,0 +1,26 @@
1
+ = New Features
2
+
3
+ * An adapter has been added for the trilogy MySQL driver. One large
4
+ advantage over mysql2 is that trilogy does not require any MySQL
5
+ client libraries installed on the machine. The trilogy adapter
6
+ has basically the same issues/skipped specs as the mysql2 adapter,
7
+ but it also does not support an application_timezone different
8
+ than the database_timezone.
9
+
10
+ * Model dataset modules now have a model accessor, allowing for
11
+ code such as:
12
+
13
+ class Foo < Sequel::Model
14
+ dataset_module do
15
+ where :kept, Sequel[model.table_name][:discarded_at] => nil
16
+ end
17
+ end
18
+
19
+ = Improvements
20
+
21
+ * The mysql adapter now works with ruby-mysql 4 (the pure-ruby
22
+ MySQL driver). Note that multi-results support does not work
23
+ with ruby-mysql 4 (it doesn't work with mysql2, trilogy, or
24
+ other Sequel adapters in general).
25
+
26
+ * Warnings for unsupported flags are now avoided on ruby-mysql 3.
@@ -0,0 +1,35 @@
1
+ = New Features
2
+
3
+ * A sharded_timed_queue connection pool has been added. This offers
4
+ most of the same features as the sharded_threaded connection pool,
5
+ but uses the new Queue#pop :timeout features added in Ruby 3.2 to
6
+ allow for a simpler and possibly faster and more robust
7
+ implementation.
8
+
9
+ * If a :pool_class option is not specified when creating a Database,
10
+ Sequel will now look at the SEQUEL_DEFAULT_CONNECTION_POOL
11
+ environment variable to determine the connection pool class to use.
12
+ This allows you to set SEQUEL_DEFAULT_CONNECTION_POOL=timed_queue
13
+ on Ruby 3.2 to test with the timed_queue connection pool without
14
+ making any code changes. If the :servers Database option is given,
15
+ Sequel will automatically use the sharded version of the connection
16
+ pool specified by SEQUEL_DEFAULT_CONNECTION_POOL.
17
+
18
+ = Other Improvements
19
+
20
+ * The connection_validator, connection_expiration, and
21
+ async_thread_pool extensions now work with the timed_queue and
22
+ sharded_timed_queue connection pools.
23
+
24
+ * The sharded_threaded connection pool now disconnects connections
25
+ for all specified servers instead of just the last specified server
26
+ when using remove_server.
27
+
28
+ * The static_cache plugin now recognizes when the forbid_lazy_load
29
+ plugin is already loaded, and does not return instances that
30
+ forbid lazy load for methods that return a single object, such as
31
+ Database.{[],cache_get_pk,first}.
32
+
33
+ * Sequel now displays an informative error message if attempting to
34
+ load the connection_validator or connection_expiration extensions
35
+ when using the single threaded connection pool.
@@ -0,0 +1,21 @@
1
+ = New Features
2
+
3
+ * A pg_xmin_optimistic_locking plugin has been added. This plugin
4
+ uses PostgreSQL's xmin system column to implement optimistic
5
+ locking. The xmin system column is automatically updated whenever
6
+ the database row is updated. You can load this plugin into a
7
+ base model and have all models that subclass from it use optimistic
8
+ locking, without needing any user-defined lock columns.
9
+
10
+ = Other Improvements
11
+
12
+ * set_column_allow_null is now a reversible migration method inside
13
+ alter_table blocks.
14
+
15
+ * The use of ILIKE no longer forces the ESCAPE clause on PostgreSQL,
16
+ which allows the use of ILIKE ANY and other constructions. There
17
+ is no need to use the ESCAPE clause with ILIKE, because the value
18
+ Sequel uses is PostgreSQL's default.
19
+
20
+ * The xid PostgreSQL type is now recognized as an integer type in the
21
+ jdbc/postgresql adapter.
@@ -0,0 +1,33 @@
1
+ = New Features
2
+
3
+ * A pg_auto_parameterize_in_array extension has been added, which
4
+ handles conversion of IN/NOT IN to = ANY or != ALL for more types.
5
+ The pg_auto_parameterize extension only handles integer types by
6
+ default, because other types require the pg_array extension. This
7
+ new extension adds handling for Float, BigDecimal, Date, Time,
8
+ DateTime, Sequel::SQLTime, and Sequel::SQL::Blob types. It can
9
+ also handle String types if the :treat_string_list_as_text_array
10
+ Database option is present, using the text type for that. Handling
11
+ String values as text is not the default because that may cause
12
+ issues for some queries.
13
+
14
+ = Other Improvements
15
+
16
+ * The defaults_setter plugin now does a deep copy of database
17
+ default values that are hash/array or delegates to hash/array.
18
+ This fixes cases where the database default values are mutated.
19
+
20
+ * Sequel now correctly handles infinite and NaN float values used
21
+ inside PostgreSQL array bound variables.
22
+
23
+ * The data in the cache files used by the schema_caching and
24
+ index_caching extensions and static_cache_cache and
25
+ pg_auto_constraint_validations plugins are now sorted before the
26
+ cache file is saved, increasing consistency between runs.
27
+
28
+ * bigdecimal has been added as a dependency. bigdecimal is currently
29
+ a default gem in Ruby from 1.9 to 3.2, but it will move to a
30
+ bundled gem in Ruby 3.4, and there will be warnings in Ruby 3.3
31
+ for cases that will break in Ruby 3.4. Adding bigdecimal as a
32
+ dependency should avoid warnings when using bundler in Ruby 3.3,
33
+ and should avoid errors in Ruby 3.4.
@@ -0,0 +1,66 @@
1
+ = New Features
2
+
3
+ * A paged_operations plugin has been added, which adds support for
4
+ paged_datasets, paged_update, and paged_delete dataset methods.
5
+ This methods are designed to be used on large datasets, to split
6
+ a large query into separate smaller queries, to avoid locking the
7
+ related database table for a long period of time.
8
+ paged_update and paged_delete operate the same as update and delete,
9
+ returning the number of rows updated or deleted. paged_datasets yields
10
+ one or more datasets representing subsets of the receiver, with the
11
+ union of all of those datasets comprising all records in the receiver:
12
+
13
+ Album.plugin :paged_operations
14
+
15
+ Album.where{name > 'M'}.paged_datasets{|ds| puts ds.sql}
16
+ # Runs: SELECT id FROM albums WHERE (name <= 'M') ORDER BY id LIMIT 1 OFFSET 1000
17
+ # Prints: SELECT * FROM albums WHERE ((name <= 'M') AND ("id" < 1002))
18
+ # Runs: SELECT id FROM albums WHERE ((name <= 'M') AND (id >= 1002)) ORDER BY id LIMIT 1 OFFSET 1000
19
+ # Prints: SELECT * FROM albums WHERE ((name <= 'M') AND ("id" < 2002) AND (id >= 1002))
20
+ # ...
21
+ # Runs: SELECT id FROM albums WHERE ((name <= 'M') AND (id >= 10002)) ORDER BY id LIMIT 1 OFFSET 1000
22
+ # Prints: SELECT * FROM albums WHERE ((name <= 'M') AND (id >= 10002))
23
+
24
+ Album.where{name <= 'M'}.paged_update(:updated_at=>Sequel::CURRENT_TIMESTAMP)
25
+ # SELECT id FROM albums WHERE (name <= 'M') ORDER BY id LIMIT 1 OFFSET 1000
26
+ # UPDATE albums SET updated_at = CURRENT_TIMESTAMP WHERE ((name <= 'M') AND ("id" < 1002))
27
+ # SELECT id FROM albums WHERE ((name <= 'M') AND (id >= 1002)) ORDER BY id LIMIT 1 OFFSET 1000
28
+ # UPDATE albums SET updated_at = CURRENT_TIMESTAMP WHERE ((name <= 'M') AND ("id" < 2002) AND (id >= 1002))
29
+ # ...
30
+ # SELECT id FROM albums WHERE ((name <= 'M') AND (id >= 10002)) ORDER BY id LIMIT 1 OFFSET 1000
31
+ # UPDATE albums SET updated_at = CURRENT_TIMESTAMP WHERE ((name <= 'M') AND (id >= 10002))
32
+
33
+ Album.where{name > 'M'}.paged_delete
34
+ # SELECT id FROM albums WHERE (name > 'M') ORDER BY id LIMIT 1 OFFSET 1000
35
+ # DELETE FROM albums WHERE ((name > 'M') AND (id < 1002))
36
+ # SELECT id FROM albums WHERE (name > 'M') ORDER BY id LIMIT 1 OFFSET 1000
37
+ # DELETE FROM albums WHERE ((name > 'M') AND (id < 2002))
38
+ # ...
39
+ # SELECT id FROM albums WHERE (name > 'M') ORDER BY id LIMIT 1 OFFSET 1000
40
+ # DELETE FROM albums WHERE (name > 'M')
41
+
42
+ * A Dataset#transaction :skip_transaction option is now support to
43
+ checkout a connection from the pool without opening a transaction. This
44
+ makes it easier to handle cases where a transaction may or not be used
45
+ based on configuration/options. Dataset#import and Dataset#paged_each
46
+ now both support the :skip_transaction option to skip transactions.
47
+
48
+ * Dataset#full_text_search now supports the to_tsquery: :websearch option
49
+ on PostgreSQL 11+, to use the websearch_to_tsquery database function.
50
+
51
+ * The Sequel::MassAssignmentRestriction exception now supports model
52
+ and column methods to get provide additional information about the
53
+ exception. Additionally, the exception message now includes information
54
+ about the model class.
55
+
56
+ = Other Improvements
57
+
58
+ * The ibmdb and jdbc/db2 adapter now both handle disconnect errors
59
+ correctly, removing the related connection from the pool.
60
+
61
+ * Dataset#import no longer uses an explicit transaction if given a dataset
62
+ value, as in that case, only a single query is used.
63
+
64
+ * The column_encryption plugin no longer uses the base64 library. The
65
+ base64 library is moving from the standard library to a bundled gem
66
+ in Ruby 3.4, and this avoids having a dependency on it.
@@ -0,0 +1,45 @@
1
+ = New Features
2
+
3
+ * Sequel.migration blocks now support a revert method, which reverts
4
+ the changes in the block on up, and applies them on down. So if
5
+ you have a migration such as:
6
+
7
+ Sequel.migration do
8
+ change do
9
+ create_table :table do
10
+ # ...
11
+ end
12
+ end
13
+ end
14
+
15
+ and you later want to add a migration that drops the table, you
16
+ can use:
17
+
18
+ Sequel.migration do
19
+ revert do
20
+ create_table :table do
21
+ # ...
22
+ end
23
+ end
24
+ end
25
+
26
+ This will drop the table when migrating up, and create a table
27
+ with the given schema when migrating down.
28
+
29
+ * is_json and is_not_json methods have been added to the pg_json_ops
30
+ extension, for the IS [NOT] JSON operator supported in PostgreSQL
31
+ 16+. These were previously added in Sequel 5.59.0, and removed
32
+ in Sequel 5.61.0 as support was removed in PostgreSQL 15 beta 4.
33
+ PostgreSQL 16 shipped with support for them, so support has been
34
+ recommitted to Sequel.
35
+
36
+ = Other Improvements
37
+
38
+ * SQLite generated columns now show up in Database#schema when using
39
+ SQLite 3.37+.
40
+
41
+ * Sequel now attempts to avoid an infinite loop in pathlogical cases
42
+ in the jdbc adapter, where the exception cause chain has a loop.
43
+ Additionally, if an exception is already recognized as a disconnect,
44
+ or an exception already responds to a getSQLState method, Sequel no
45
+ longer looks at the causes of the exception.
@@ -0,0 +1,35 @@
1
+ = New Features
2
+
3
+ * Database#{defer,immediate}_constraints methods have been added on
4
+ PostgreSQL for changing handling of deferrable constraints inside
5
+ a transaction. defer_constraints sets deferrable constraints to
6
+ be deferred (not checked until transaction commit), and
7
+ immediate_constraints sets deferrable constraints to be checked
8
+ as part of the related query, and any already deferred constraint
9
+ checks to be applied immediately. You can pass the :constraints
10
+ option to only apply the changes to specific constraints.
11
+
12
+ * TimestampMigrator.run_single has been added, to migrate a single
13
+ migration up or down.
14
+
15
+ = Other Improvements
16
+
17
+ * INSERT RETURNING is now supported on MariaDB 10.5+, and used
18
+ automatically when saving new model objects. Note that this
19
+ is not supported when using the jdbc adapter, because the
20
+ jdbc-mysql driver doesn't support it. A jdbc/mariadb adapter
21
+ could be added, as it's likely recent versions of the
22
+ jdbc-mariadb driver would support it, but the jdbc-mariadb gem
23
+ hasn't been updated in over 4 years. Talk to the jdbc-mariadb
24
+ gem maintainers if you want to use this feature with the jdbc
25
+ adapter.
26
+
27
+ * The Dataset#paged_each optimization in the postgres adapter
28
+ now respects the :skip_transaction option, making it the
29
+ same as the :hold option. Note that this has effects beyond
30
+ just skipping the transaction, but non-HOLD cursors are only
31
+ supported inside transactions.
32
+
33
+ * The any_not_empty? extension's Dataset#any? method now supports
34
+ an argument, passing it to Enumerable#any? (which has supported
35
+ an argument since Ruby 2.5).
@@ -0,0 +1,86 @@
1
+ = New Features
2
+
3
+ * An auto_cast_date_and_time extension has been added, which will
4
+ automatically cast date and time values using SQL standard functions.
5
+ This makes sure the database will treat the value as a date, time,
6
+ or timestamp, instead of treating it as a string or unknown type:
7
+
8
+ DB.get(Date.today).class
9
+ # SELECT '2024-01-01' AS v LIMIT 1
10
+ String
11
+
12
+ DB.extension(:auto_cast_date_and_time)
13
+ DB.get(Date.today).class
14
+ # SELECT DATE '2024-01-01' AS v LIMIT 1
15
+ Date
16
+
17
+ This was already Sequel's default behavior on adapters that required
18
+ it. This extension is usable on PostgreSQL and MySQL. It is not
19
+ usable on SQLite (no date/time types) or Microsoft SQL Server (no
20
+ support for the SQL standard conversion syntax).
21
+
22
+ This extension can break code that currently works. If using it on
23
+ PostgreSQL, it will cast the values to TIMESTAMP, not TIMESTAMP
24
+ WITH TIME ZONE, which can break code that depended on an implicit
25
+ conversion to TIMESTAMP WITH TIME ZONE. The pg_timestamptz
26
+ extension integrates with the the auto_cast_date_and_time extension
27
+ and will implicitly cast Time/DateTime to TIMESTAMP WITH TIME ZONE.
28
+
29
+ * The sqlite adapter now supports a :cached value for the
30
+ :setup_regexp_function Database option, which will cache regexp
31
+ values instead of creating a new regexp per value to compare. This
32
+ is much faster when using a regexp comparison on a large dataset,
33
+ but can result in a memory leak if using dynamic regexps. You can
34
+ also provide a Proc value for the :setup_regexp_function option,
35
+ which will be passed both the regexp source string and the database
36
+ string to compare, and should return whether the database string
37
+ matches the regexp string.
38
+
39
+ * The rcte_tree plugin now supports a :union_all option, which can
40
+ be set to false to use UNION instead of UNION ALL in the recursive
41
+ common table expression.
42
+
43
+ = Other Improvements
44
+
45
+ * Time/DateTime/SQLTime literalization speed has more than doubled
46
+ compared to the previous version. The internal code is also much
47
+ simpler, as the speedup resulted from removing multiple abstraction
48
+ layers that mostly existed for Ruby 1.8 support.
49
+
50
+ * Database#table_exists? on PostgreSQL now handles lock or statement
51
+ timeout errors as evidence the table exists.
52
+
53
+ * The round_timestamps extension now correctly rounds SQLTime values
54
+ on Microsoft SQL Server (the only database Sequel supports where
55
+ time precision is different than timestamp precision).
56
+
57
+ * Fractional times and timestamps are now supported on SQLAnywhere,
58
+ except for time values when using the jdbc adapter due to a
59
+ limitation in the JDBC sqlanywhere driver.
60
+
61
+ * Database#tables and #views on PostgreSQL now supports
62
+ SQL::Identifier values for the :schema option.
63
+
64
+ * The named_timezones extension now works around a bug in DateTime.jd
65
+ on JRuby.
66
+
67
+ = Backwards Compatibility
68
+
69
+ * Time/DateTime/SQLTime literalization internals have changed.
70
+ If you are using an external adapter and the external adapter
71
+ overrides or calls any of the following methods:
72
+
73
+ * requires_sql_standard_datetimes?
74
+ * supports_timestamp_usecs?
75
+ * supports_timestamp_timezones?
76
+ * timestamp_precision
77
+ * sqltime_precision
78
+
79
+ then the adapter may need to be updated to support Sequel 5.76.0.
80
+ Additionally, if the adapter uses %N or %z in
81
+ default_timestamp_format, it may need to be updated. Adapters
82
+ should now just override default_timestamp_format and/or
83
+ default_time_format methods as appropriate for the database.
84
+
85
+ * The Dataset#format_timestamp_offset private method has been
86
+ removed.
@@ -0,0 +1,63 @@
1
+ = New Features
2
+
3
+ * A transaction_connection_validator extension has been added. This
4
+ extension allows for transparently switching to a new connection if
5
+ a disconnect error is raised while trying to start a transaction, as
6
+ long as a connection was not already checked out from the pool
7
+ when the transaction method was called. Transparent reconnection
8
+ is safe in this case, since no user code is retried.
9
+
10
+ This extension can have lower overhead than the
11
+ connection_validator extension if that is configured to check for
12
+ validity more often than the default of one hour. However, it
13
+ only handles cases where transactions are used. It can detect
14
+ disconnects that would not be detected by default with the
15
+ connection_validator extension, since that extension defaults to
16
+ only checking validity if the connection has not been used in the
17
+ last hour.
18
+
19
+ * Sequel now supports a create_table :without_rowid option on SQLite,
20
+ to create a table WITHOUT ROWID, for better performance in some
21
+ cases. Users are encouraged to read the SQLite documentation on
22
+ WITHOUT ROWID before using this option.
23
+
24
+ * The sqlite adapter now supports a :regexp_function_cache option, if
25
+ the :setup_regexp_function option is set to :cached. The
26
+ :regexp_function_cache option should be a Proc (returning a cache
27
+ object to use), or a class. It's possible to use
28
+ ObjectSpace::WeakKeyMap as the value of the option on Ruby 3.3+
29
+ to avoid the memory leaks that are possible when using
30
+ :setup_regexp_function option :cached value with dynamic regexps.
31
+
32
+ * The duplicate_columns_handler extension now supports specifying
33
+ the on_duplicate_columns option as a connection string parameter.
34
+
35
+ = Other Improvements
36
+
37
+ * The list plugin now honors the :top option for the position when
38
+ adding the first item to the list, instead of always using 1.
39
+
40
+ * Regexp matches on SQLite are now faster on Ruby 2.4+, using
41
+ Regexp#match?.
42
+
43
+ * The uniqueness validation in the validation_helpers plugin now
44
+ uses empty? instead of count == 0, for better performance.
45
+
46
+ * On Ruby 3.4+, Sequel uses the timed_queue connection pool instead
47
+ of the threaded connection pool by default. This should make it
48
+ so no existing applications are affected by the default switch.
49
+ This should hopefully allow ample testing of the timed_queue
50
+ connection pool. At some point in the future, if no problems
51
+ are repoted, Sequel will likely switch to using the timed_queue
52
+ connection pool by default on Ruby 3.2+.
53
+
54
+ = Backwards Compatibility
55
+
56
+ * Sequel now warns by default if using eager_graph/association_join
57
+ with an association that uses a block, in the cases where the
58
+ block would be ignored and there are no appropriate graph options
59
+ set. In Sequel 6, this warning will be turned into an exception.
60
+ It is recommended that users use the auto_restrict_eager_graph
61
+ plugin to turn this into an exception now, or use the
62
+ :graph_use_association_block option so that the block is not
63
+ ignored when graphing.