sequel 5.48.0 → 5.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +80 -0
- data/README.rdoc +12 -5
- data/doc/migration.rdoc +1 -1
- data/doc/opening_databases.rdoc +1 -1
- data/doc/postgresql.rdoc +8 -0
- data/doc/release_notes/5.49.0.txt +59 -0
- data/doc/release_notes/5.50.0.txt +78 -0
- data/doc/release_notes/5.51.0.txt +47 -0
- data/doc/release_notes/5.52.0.txt +87 -0
- data/doc/testing.rdoc +3 -1
- data/lib/sequel/adapters/ado/access.rb +1 -1
- data/lib/sequel/adapters/ado.rb +1 -1
- data/lib/sequel/adapters/amalgalite.rb +3 -5
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc/derby.rb +3 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +4 -4
- data/lib/sequel/adapters/jdbc.rb +9 -11
- data/lib/sequel/adapters/mysql.rb +80 -67
- data/lib/sequel/adapters/mysql2.rb +42 -44
- data/lib/sequel/adapters/odbc.rb +1 -1
- data/lib/sequel/adapters/oracle.rb +3 -3
- data/lib/sequel/adapters/postgres.rb +27 -29
- data/lib/sequel/adapters/shared/access.rb +2 -0
- data/lib/sequel/adapters/shared/db2.rb +2 -0
- data/lib/sequel/adapters/shared/mysql.rb +4 -2
- data/lib/sequel/adapters/shared/postgres.rb +59 -6
- data/lib/sequel/adapters/shared/sqlanywhere.rb +3 -0
- data/lib/sequel/adapters/shared/sqlite.rb +1 -1
- data/lib/sequel/adapters/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/sqlite.rb +16 -18
- data/lib/sequel/adapters/tinytds.rb +1 -1
- data/lib/sequel/adapters/utils/columns_limit_1.rb +22 -0
- data/lib/sequel/ast_transformer.rb +6 -0
- data/lib/sequel/connection_pool/sharded_single.rb +5 -7
- data/lib/sequel/connection_pool/single.rb +6 -8
- data/lib/sequel/core.rb +17 -18
- data/lib/sequel/database/connecting.rb +2 -2
- data/lib/sequel/database/misc.rb +6 -0
- data/lib/sequel/database/query.rb +1 -1
- data/lib/sequel/dataset/actions.rb +2 -2
- data/lib/sequel/dataset/query.rb +45 -3
- data/lib/sequel/dataset/sql.rb +18 -9
- data/lib/sequel/extensions/any_not_empty.rb +1 -1
- data/lib/sequel/extensions/core_refinements.rb +36 -11
- data/lib/sequel/extensions/date_parse_input_handler.rb +67 -0
- data/lib/sequel/extensions/datetime_parse_to_time.rb +5 -1
- data/lib/sequel/extensions/duplicate_columns_handler.rb +1 -1
- data/lib/sequel/extensions/inflector.rb +1 -1
- data/lib/sequel/extensions/migration.rb +4 -1
- data/lib/sequel/extensions/pagination.rb +1 -1
- data/lib/sequel/extensions/pg_array_ops.rb +1 -1
- data/lib/sequel/extensions/pg_extended_date_support.rb +1 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +53 -3
- data/lib/sequel/extensions/pg_inet_ops.rb +1 -1
- data/lib/sequel/extensions/pg_interval.rb +1 -0
- data/lib/sequel/extensions/pg_json.rb +3 -5
- data/lib/sequel/extensions/pg_json_ops.rb +71 -1
- data/lib/sequel/extensions/pg_multirange.rb +372 -0
- data/lib/sequel/extensions/pg_range.rb +4 -12
- data/lib/sequel/extensions/pg_range_ops.rb +37 -9
- data/lib/sequel/extensions/pg_row_ops.rb +1 -1
- data/lib/sequel/extensions/s.rb +2 -1
- data/lib/sequel/extensions/server_block.rb +8 -12
- data/lib/sequel/extensions/sql_comments.rb +108 -3
- data/lib/sequel/extensions/sql_log_normalizer.rb +108 -0
- data/lib/sequel/extensions/string_agg.rb +1 -1
- data/lib/sequel/extensions/string_date_time.rb +19 -23
- data/lib/sequel/model/associations.rb +3 -1
- data/lib/sequel/model/base.rb +9 -13
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/plugins/auto_validations.rb +25 -5
- data/lib/sequel/plugins/column_encryption.rb +1 -1
- data/lib/sequel/plugins/composition.rb +1 -0
- data/lib/sequel/plugins/json_serializer.rb +2 -2
- data/lib/sequel/plugins/lazy_attributes.rb +3 -0
- data/lib/sequel/plugins/serialization.rb +1 -0
- data/lib/sequel/plugins/serialization_modification_detection.rb +1 -0
- data/lib/sequel/plugins/sql_comments.rb +189 -0
- data/lib/sequel/plugins/static_cache.rb +1 -1
- data/lib/sequel/plugins/subclasses.rb +28 -11
- data/lib/sequel/plugins/tactical_eager_loading.rb +8 -2
- data/lib/sequel/plugins/unused_associations.rb +2 -2
- data/lib/sequel/plugins/update_or_create.rb +1 -1
- data/lib/sequel/plugins/validation_helpers.rb +7 -1
- data/lib/sequel/plugins/xml_serializer.rb +1 -1
- data/lib/sequel/sql.rb +1 -1
- data/lib/sequel/timezones.rb +12 -14
- data/lib/sequel/version.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06302dbd32fc7e13539c83a4cf86fa72d974ffb15d403f30ca13d08af83c0605
|
4
|
+
data.tar.gz: ad8cc158183399ac93c5a44e0e33d0693a92599ccb5092f542ff2993f4701d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0943434af7e097bf7589ec885b6509f40b9677d7e1be56cac17f5093bc2c9a6c1e79918b547a4d04a2623b5562e4e8897247551f1a89ecde5c53339e6c9a48
|
7
|
+
data.tar.gz: a82852fa8dd6b598b7463acafab29bd6d1b5e514b639e3d13ee33855c300d9daa662d4ea1af27525d7557644c2eb8bd1ccceec376aa6b1dc26286658db5b63e7
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,83 @@
|
|
1
|
+
=== 5.52.0 (2022-01-01)
|
2
|
+
|
3
|
+
* Use Class#subclasses if available in the subclasses plugin, instead of a custom Model.subclasses accessor (jeremyevans)
|
4
|
+
|
5
|
+
* Add Model.descendants and .freeze_descendants to subclasses plugin (jeremyevans)
|
6
|
+
|
7
|
+
* Avoid use of deprecated Refinement#include on Ruby 3.1+ (jeremyevans)
|
8
|
+
|
9
|
+
* Add date_parse_input_handler extension for custom handling of input to date parsing methods (jeremyevans)
|
10
|
+
|
11
|
+
* Make postgres adapter respect Database#default_string_column_size (jeremyevans)
|
12
|
+
|
13
|
+
* Make pg_interval extension work with ActiveSupport 7.0 (jeremyevans)
|
14
|
+
|
15
|
+
* Make :ruby_default schema entry for type: :datetime respect Sequel.datetime_class (jeremyevans)
|
16
|
+
|
17
|
+
* Make alter_table drop_constraint have an effect on MySQL 8.0.19+ (jeremyevans)
|
18
|
+
|
19
|
+
* Make mysql adapter support ruby-mysql 3 API (jeremyevans) (#1795)
|
20
|
+
|
21
|
+
* Make mysql adapter no longer use connection's server_version, since it isn't accurate when using the ruby-mysql driver (jeremyevans)
|
22
|
+
|
23
|
+
* Add sql_comments plugin for automatically including comments on queries generated by model class, instance, and dataset methods (jeremyevans)
|
24
|
+
|
25
|
+
* Make sql_comments Database extension support Database#with_comments, for automatically including comments for queries executed inside the block (jeremyevans)
|
26
|
+
|
27
|
+
* Fix sql_comments extension to not modify cached SQL for a dataset (jeremyevans)
|
28
|
+
|
29
|
+
=== 5.51.0 (2021-12-01)
|
30
|
+
|
31
|
+
* Make eager loading via tactical_eager_loading no longer modify objects who already have a cached value for the association (jeremyevans)
|
32
|
+
|
33
|
+
* Make association cloning handle cases where clone association sets different :class option than cloned association (jeremyevans)
|
34
|
+
|
35
|
+
* Make column schema entries on MySQL include an :extra entry for the Extra column in DESCRIBE output (bschmeck) (#1791)
|
36
|
+
|
37
|
+
* Update mock PostgreSQL adapter to default to PostgreSQL 14 instead of PostgreSQL 9.5 (jeremyevans)
|
38
|
+
|
39
|
+
* Support Dataset#with_recursive :search and :cycle options on PostgreSQL 14+ for result ordering and cycle detection (jeremyevans)
|
40
|
+
|
41
|
+
* Avoid method redefined verbose mode warnings in lazy_attributes plugin (jeremyevans)
|
42
|
+
|
43
|
+
=== 5.50.0 (2021-11-01)
|
44
|
+
|
45
|
+
* Make Migrator :allow_missing_migration_files also allow down migrations where the current database version is greater than the last migration file version (francisconeves97) (#1789)
|
46
|
+
|
47
|
+
* Fix Model#freeze in composition, serialization, and serialization_modification_detection plugins to return self (jeremyevans) (#1788)
|
48
|
+
|
49
|
+
* Fix typecasting of lazy columns when using lazy_attributes plugin in model where dataset selects from subquery (jeremyevans)
|
50
|
+
|
51
|
+
* Add :before_preconnect Database option, for configuring extensions loaded via :preconnect_extensions (MarcPer, jeremyevans) (#1786)
|
52
|
+
|
53
|
+
* Change Dataset#columns! to use a LIMIT 0 query instead of a LIMIT 1 query (jeremyevans)
|
54
|
+
|
55
|
+
* Add sql_log_normalizer extension for normalizing logged SQL, helpful for analytics and sensitive data (jeremyevans)
|
56
|
+
|
57
|
+
* Add support for range_merge, multirange, and unnest, and PGMultiRange#op to pg_range_ops extension (jeremyevans)
|
58
|
+
|
59
|
+
* Add pg_multirange extension with support for PostgreSQL 14+ multirange types (jeremyevans)
|
60
|
+
|
61
|
+
=== 5.49.0 (2021-10-01)
|
62
|
+
|
63
|
+
* Switch block_given? usage to defined?(yield) (jeremyevans)
|
64
|
+
|
65
|
+
* Support table aliases for JOIN USING columns on PostgreSQL 14+ (jeremyevans)
|
66
|
+
|
67
|
+
* Support calling PostgreSQL procedures without arguments (jeremyevans)
|
68
|
+
|
69
|
+
* Support hstore subscripts in pg_hstore_ops on PostgreSQL 14+, for updating only part of an hstore value (jeremyevans)
|
70
|
+
|
71
|
+
* Support JSONB subscripts in pg_json_ops on PostgreSQL 14+, for updating only part of a JSONB value (jeremyevans)
|
72
|
+
|
73
|
+
* Support SQL::Expression#sequel_ast_transform for custom AST transforms on arbitrary expressions (jeremyevans)
|
74
|
+
|
75
|
+
* Add Database#create_trigger :replace option on PostgreSQL 14+ for CREATE OR REPLACE TRIGGER (jeremyevans)
|
76
|
+
|
77
|
+
* Make auto_validations plugin automatically setup no_null_byte validations (jeremyevans)
|
78
|
+
|
79
|
+
* Add Model#validates_no_null_byte to validation_helpers plugin (jeremyevans)
|
80
|
+
|
1
81
|
=== 5.48.0 (2021-09-01)
|
2
82
|
|
3
83
|
* Make the unused_associations plugin association reflection tracking work correctly when combining coverage runs (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -17,11 +17,12 @@ toolkit for Ruby.
|
|
17
17
|
|
18
18
|
== Resources
|
19
19
|
|
20
|
-
Website ::
|
21
|
-
RDoc Documentation ::
|
20
|
+
Website :: https://sequel.jeremyevans.net
|
21
|
+
RDoc Documentation :: https://sequel.jeremyevans.net/rdoc
|
22
22
|
Source Code :: https://github.com/jeremyevans/sequel
|
23
|
-
Bug tracking (GitHub Issues) ::
|
24
|
-
Discussion Forum (
|
23
|
+
Bug tracking (GitHub Issues) :: https://github.com/jeremyevans/sequel/issues
|
24
|
+
Discussion Forum (GitHub Discussions) :: https://github.com/jeremyevans/sequel/discussions
|
25
|
+
Alternate Discussion Forum (sequel-talk Google Group) :: http://groups.google.com/group/sequel-talk
|
25
26
|
|
26
27
|
If you have questions about how to use Sequel, please ask on the
|
27
28
|
sequel-talk Google Group. Only use the the bug tracker to report
|
@@ -879,6 +880,11 @@ raise an error by default:
|
|
879
880
|
end
|
880
881
|
end
|
881
882
|
|
883
|
+
== Testing Sequel
|
884
|
+
|
885
|
+
Please see the {testing guide}[rdoc-ref:doc/testing.rdoc] for recommendations on testing
|
886
|
+
applications that use Sequel, as well as the how to run the tests for Sequel itself.
|
887
|
+
|
882
888
|
== Sequel Release Policy
|
883
889
|
|
884
890
|
New major versions of Sequel do not have a defined release policy, but historically have
|
@@ -894,7 +900,8 @@ in the most current release.
|
|
894
900
|
Sequel fully supports the currently supported versions of Ruby (MRI) and JRuby. It may
|
895
901
|
support unsupported versions of Ruby or JRuby, but such support may be dropped in any
|
896
902
|
minor version if keeping it becomes a support issue. The minimum Ruby version
|
897
|
-
required to run the current version of Sequel is 1.9.2
|
903
|
+
required to run the current version of Sequel is 1.9.2, and the minimum JRuby version is
|
904
|
+
9.0.0.0.
|
898
905
|
|
899
906
|
== Maintainer
|
900
907
|
|
data/doc/migration.rdoc
CHANGED
@@ -352,7 +352,7 @@ you should give it some thought before using it.
|
|
352
352
|
|
353
353
|
== Ignoring missing migrations
|
354
354
|
|
355
|
-
In some cases, you may want to allow a migration in the database that does not exist in the filesystem (deploying to an older version of code without running a down migration when deploy auto-migrates, for example). If required, you can pass <tt>allow_missing_migration_files: true</tt> as an option. This will stop errors from being raised if there are migrations in the database that do not exist in the filesystem.
|
355
|
+
In some cases, you may want to allow a migration in the database that does not exist in the filesystem (deploying to an older version of code without running a down migration when deploy auto-migrates, for example). If required, you can pass <tt>allow_missing_migration_files: true</tt> as an option. This will stop errors from being raised if there are migrations in the database that do not exist in the filesystem. Note that the migrations themselves can still raise an error when using this option, if the database schema isn't in the state the migrations expect it to be in. In general, the <tt>allow_missing_migration_files: true</tt> option is very risky to use, and should only be used if it is absolutely necessary.
|
356
356
|
|
357
357
|
== Modifying existing migrations
|
358
358
|
|
data/doc/opening_databases.rdoc
CHANGED
@@ -249,7 +249,7 @@ jdbc-mysql :: Depending on the configuration of the MySQL server, jdbc-mysql ver
|
|
249
249
|
|
250
250
|
Requires: mysql
|
251
251
|
|
252
|
-
|
252
|
+
This should work with the mysql gem (C extension) and the ruby-mysql gem (pure ruby).
|
253
253
|
|
254
254
|
The following additional options are supported:
|
255
255
|
|
data/doc/postgresql.rdoc
CHANGED
@@ -428,6 +428,14 @@ rows that are distinct on just those columns:
|
|
428
428
|
DB[:table].distinct(:id).all
|
429
429
|
# SELECT DISTINCT ON ("id") * FROM "table"
|
430
430
|
|
431
|
+
=== JOIN USING table alias
|
432
|
+
|
433
|
+
Sequel allows passing an SQL::AliasedExpression to join table methods to use a USING
|
434
|
+
join with a table alias for the USING columns:
|
435
|
+
|
436
|
+
DB[:t1].join(:t2, Sequel.as([:c1, :c2], :alias))
|
437
|
+
# SELECT * FROM "t1" INNER JOIN "t2" USING ("c1", "c2") AS "alias"
|
438
|
+
|
431
439
|
=== Calling PostgreSQL 11+ Procedures <tt>postgres only</tt>
|
432
440
|
|
433
441
|
PostgreSQL 11+ added support for procedures, which are different from the user defined
|
@@ -0,0 +1,59 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* Model#validates_no_null_byte has been added to the
|
4
|
+
validation_helpers. It checks that the value being validated does
|
5
|
+
not contain an ASCII NUL ('\0') byte. Some databases will return an
|
6
|
+
error if a string contains a NUL byte.
|
7
|
+
|
8
|
+
The auto_validations plugin will now automatically add no_null_byte
|
9
|
+
validations for all string columns in the model's table. This will
|
10
|
+
change exceptions raised by NUL bytes from database errors to
|
11
|
+
validation failures.
|
12
|
+
|
13
|
+
If you are using auto_validations and would like to have a table
|
14
|
+
accept NUL bytes in string columns, use the following code inside
|
15
|
+
the model:
|
16
|
+
|
17
|
+
skip_auto_validations(:no_null_byte)
|
18
|
+
|
19
|
+
* JSONB subscripts are now supported on PostgreSQL 14+ when using the
|
20
|
+
pg_json_ops extension. You can use JSONB subscripts to more easily
|
21
|
+
update part of a JSONB column:
|
22
|
+
|
23
|
+
DB[:table].update(Sequel.pg_jsonb_op(:column)['key'] => 'value')
|
24
|
+
UPDATE "table" SET "column"['key'] = 'value'
|
25
|
+
|
26
|
+
* hstore subscripts are now supported on PostgreSQL 14+ when using the
|
27
|
+
pg_hstore_ops extension. You can use hstore subscripts to more
|
28
|
+
easily update part of an hstore column:
|
29
|
+
|
30
|
+
DB[:table].update(Sequel.hstore_op(:column)['key'] => 'value')
|
31
|
+
UPDATE "table" SET "column"['key'] = 'value'
|
32
|
+
|
33
|
+
* Sequel now supports table aliases for JOIN USING columns on
|
34
|
+
PostgreSQL 14+. These allow you to reference the USING columns in
|
35
|
+
the query using a qualified identifier. To use this support, pass an
|
36
|
+
SQL::AliasedExpression as the expression to join on:
|
37
|
+
|
38
|
+
DB[:t1].join(:t2, Sequel.as([:c1, :c2], :alias))
|
39
|
+
# SELECT * FROM "t1" INNER JOIN "t2" USING ("c1", "c2") AS "alias"
|
40
|
+
|
41
|
+
* Database#create_trigger on PostgreSQL now supports a :replace option
|
42
|
+
for CREATE OR REPLACE TRIGGER (supported in PostgreSQL 14+).
|
43
|
+
|
44
|
+
* SQL::Expression#sequel_ast_transform has been added to support
|
45
|
+
AST transforms of custom expression classes.
|
46
|
+
|
47
|
+
= Other Improvements
|
48
|
+
|
49
|
+
* Sequel now supports calling PostgreSQL procedures without arguments
|
50
|
+
when using Database#call_procedure. Previously, attempts to call
|
51
|
+
procuredures without arguments would call the procedure with a
|
52
|
+
single NULL argument.
|
53
|
+
|
54
|
+
* Sequel now uses defined?(yield) instead of block_given? internally
|
55
|
+
for better performance on CRuby. defined?(yield) is faster as it is
|
56
|
+
built into the VM, while block_given? is a regular method and has
|
57
|
+
the overhead of calling a regular method. Note that defined?(yield)
|
58
|
+
is not implemented correctly on JRuby before 9.0.0.0, so this
|
59
|
+
release of Sequel drops support for JRuby versions before 9.0.0.0.
|
@@ -0,0 +1,78 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A pg_multirange extension has been added with support for PostgreSQL
|
4
|
+
14+ multirange types. Multirange types are similar to an array of
|
5
|
+
ranges, where a value is in the multirange if it is in any of the
|
6
|
+
ranges contained in the multirange. Multiranges are useful when you
|
7
|
+
need to check against multiple ranges that do not overlap.
|
8
|
+
|
9
|
+
You can create multiranges using Sequel.pg_multirange, passing
|
10
|
+
an array of ranges and a multirange type:
|
11
|
+
|
12
|
+
DB.extension :pg_multirange
|
13
|
+
multirange = Sequel.pg_multirange(array_of_date_ranges, :datemultirange)
|
14
|
+
|
15
|
+
Sequel.pg_multirange returns a PGMultiRange, which operates as a
|
16
|
+
delegate to an array of PGRange objects. Behavior of the object
|
17
|
+
is similar to an array, except that cover? is supported, which will
|
18
|
+
test if any of the included ranges covers the argument:
|
19
|
+
|
20
|
+
multirange.cover?(Date.today)
|
21
|
+
|
22
|
+
Like the pg_range extension, this also supports registering custom
|
23
|
+
multirange types, and using multirange types as bound variables.
|
24
|
+
|
25
|
+
The pg_range_ops extension now supports both ranges and multiranges,
|
26
|
+
with a few new methods added to Postgres::RangeOp for converting
|
27
|
+
between them:
|
28
|
+
|
29
|
+
* range_merge
|
30
|
+
* multirange
|
31
|
+
* and unnest
|
32
|
+
|
33
|
+
* An sql_log_normalizer extension has been added for normalizing
|
34
|
+
logged SQL, replacing numbers and strings inside the SQL string
|
35
|
+
with question marks. This is useful for analytics and sensitive
|
36
|
+
data.
|
37
|
+
|
38
|
+
DB[:table].first(a: 1, b: 'something')
|
39
|
+
# Without sql_log_normalizer extension, logged SQL is:
|
40
|
+
# SELECT * FROM "table" WHERE (("a" = 1) AND ("b" = 'something')) LIMIT 1
|
41
|
+
|
42
|
+
DB.extension :sql_log_normalizer
|
43
|
+
DB[:table].first(a: 1, b: 'something')
|
44
|
+
# With sql_log_normalizer_extension, logged SQL is:
|
45
|
+
# SELECT * FROM "table" WHERE (("a" = ?) AND ("b" = ?)) LIMIT ?
|
46
|
+
|
47
|
+
This extension scans the logged SQL for numbers and strings,
|
48
|
+
attempting to support the database's rules for string quoting. This
|
49
|
+
means it should work with SQL that Sequel didn't itself create.
|
50
|
+
However, there are corner cases that the extension doesn't handle,
|
51
|
+
such as the use of apostrophes inside quoted identifiers, and
|
52
|
+
potentially other cases of database specific SQL where the normal
|
53
|
+
string quoting rules are changed, such as the use of escape strings
|
54
|
+
on PostgreSQL (E'escape string').
|
55
|
+
|
56
|
+
* A :before_preconnect Database option has been added. This is useful
|
57
|
+
for configuring extensions added via :preconnect_extensions before
|
58
|
+
the connection takes place.
|
59
|
+
|
60
|
+
= Other Improvements
|
61
|
+
|
62
|
+
* Dataset#columns! now uses a LIMIT 0 query instead of a LIMIT 1 query
|
63
|
+
by default. This can improve performance in cases where the row
|
64
|
+
returned would be large. Some databases do not support a LIMIT 0
|
65
|
+
query, and some adapters that ship with Sequel have been updated to
|
66
|
+
continue using LIMIT 1. Custom adapters should be updated to use
|
67
|
+
LIMIT 1 if the database does not support LIMIT 0.
|
68
|
+
|
69
|
+
* The lazy_attributes plugin no longer modifies the database schema.
|
70
|
+
Previously, it could modify the database schema indirectly,
|
71
|
+
resulting in the loss of typecasting for models that were not
|
72
|
+
based on a single table or view, such as usage with the
|
73
|
+
class_table_inheritance plugin.
|
74
|
+
|
75
|
+
* Model#freeze in the composition, serialization, and
|
76
|
+
serialization_modification_detection plugins now returns self. In
|
77
|
+
addition to being more correct, this fixes usage of these plugins
|
78
|
+
with the static_cache plugin.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* On PostgreSQL 14+, Dataset#with_recursive now supports :search and
|
4
|
+
:cycle options for result ordering and cycle detection. These use
|
5
|
+
the SEARCH and CYCLE clauses added in PostgreSQL 14:
|
6
|
+
|
7
|
+
DB[:t].with_recursive(:t,
|
8
|
+
DB[:i1].where(parent_id: nil),
|
9
|
+
DB[:i1].join(:t, id: :parent_id).select_all(:i1),
|
10
|
+
search: {by: :id, type: :breadth},
|
11
|
+
cycle: {columns: :id, cycle_value: 1, noncycle_value: 2})
|
12
|
+
|
13
|
+
# WITH RECURSIVE t AS (
|
14
|
+
# SELECT * FROM i1 WHERE (parent_id IS NULL)
|
15
|
+
# UNION ALL
|
16
|
+
# (SELECT i1.* FROM i1 INNER JOIN t ON (t.id = i1.parent_id))
|
17
|
+
# )
|
18
|
+
# SEARCH BREADTH FIRST BY id SET ordercol
|
19
|
+
# CYCLE id SET is_cycle TO 1 DEFAULT 2 USING path
|
20
|
+
|
21
|
+
* On MySQL, column schema hashes now contain an :extra entry, which
|
22
|
+
contains the Extra string returned in MySQL's DESCRIBE results
|
23
|
+
for the column.
|
24
|
+
|
25
|
+
= Other Improvements
|
26
|
+
|
27
|
+
* When eager loading via the tactical_eager_loading plugin, objects
|
28
|
+
that already have an association loaded will not have it reloaded
|
29
|
+
unless the :eager_reload option is given.
|
30
|
+
|
31
|
+
* When cloning an association and using a different :class option
|
32
|
+
than the cloned association, the :class option given when cloning
|
33
|
+
will now take precedence over the :class option for the cloned
|
34
|
+
association.
|
35
|
+
|
36
|
+
* When using the mock postgres adapter, the adapter defaults to
|
37
|
+
supporting PostgreSQL 14 (previously, it defaulted to supporting
|
38
|
+
PostgreSQL 9.5).
|
39
|
+
|
40
|
+
* Sequel now avoids a method redefined warning in the lazy attributes
|
41
|
+
plugin in verbose warnings mode.
|
42
|
+
|
43
|
+
= Other
|
44
|
+
|
45
|
+
* Sequel's primary discussion forum is now GitHub Discussions. The
|
46
|
+
sequel-talk Google Group is still available for users who would
|
47
|
+
prefer to use that instead.
|
@@ -0,0 +1,87 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* When the sql_comments Database extension is used,
|
4
|
+
Database#with_comments is now added, which can be used for including
|
5
|
+
comments for all queries executed inside a given block. This can
|
6
|
+
be useful if you want to analyze database query logs, and want to
|
7
|
+
group all related queries:
|
8
|
+
|
9
|
+
DB.with_comments(model: Album, action: :all) do
|
10
|
+
DB[:albums].all
|
11
|
+
# SELECT * FROM albums -- model:Album,action:all
|
12
|
+
end
|
13
|
+
|
14
|
+
* An sql_comments plugin has been added, which will automatically
|
15
|
+
add SQL comments for all queries generated by model class, instance
|
16
|
+
and dataset methods:
|
17
|
+
|
18
|
+
Album.plugin :sql_comments
|
19
|
+
|
20
|
+
album = Album[1]
|
21
|
+
# SELECT * FROM albums WHERE (id = 1) LIMIT 1
|
22
|
+
# -- model:Album,method_type:class,method:[]
|
23
|
+
|
24
|
+
album.update(:name=>'A')
|
25
|
+
# UPDATE albums SET name = 'baz' WHERE (id = 1)
|
26
|
+
# -- model:Album,method_type:instance,method:update
|
27
|
+
|
28
|
+
Album.where(id: 1).delete
|
29
|
+
# DELETE FROM albums WHERE (id = 1)
|
30
|
+
# -- model:Album,method_type:dataset,method:delete
|
31
|
+
|
32
|
+
This plugin requires you have loaded the sql_comments Database
|
33
|
+
extension into the related Database before use.
|
34
|
+
|
35
|
+
* A date_parse_input_handler extension has been added to support
|
36
|
+
custom handling of input to date parsing methods. Among other
|
37
|
+
things, you can use this to limit the length of strings that
|
38
|
+
will be parsed, which can prevent ArgumentErrors in newer Ruby
|
39
|
+
versions:
|
40
|
+
|
41
|
+
Sequel.extension :date_parse_input_handler
|
42
|
+
Sequel.date_parse_input_handler do |string|
|
43
|
+
string.b[0, 128]
|
44
|
+
end
|
45
|
+
|
46
|
+
= Other Improvements
|
47
|
+
|
48
|
+
* On Ruby 3.1, the core_refinements extension now avoids the
|
49
|
+
deprecated Refinement#include, switching to
|
50
|
+
Refinement#import_methods.
|
51
|
+
|
52
|
+
* On Ruby 3.1, the subclasses plugin will use Ruby's native support
|
53
|
+
for Class#subclasses.
|
54
|
+
|
55
|
+
* The subclasses plugin has renamed descendents to descendants and
|
56
|
+
freeze_descendents to freeze_descendants. The previous method
|
57
|
+
names are still available as aliases.
|
58
|
+
|
59
|
+
* The :ruby_default schema entry for datetime/timestamp columns now
|
60
|
+
respects Sequel.datetime_class. Previously, the value for the
|
61
|
+
:ruby_default schema entry would always be a DateTime value for
|
62
|
+
such columns.
|
63
|
+
|
64
|
+
* The pg_interval extension now works with ActiveSupport 7.0.
|
65
|
+
|
66
|
+
* The shared postgres adapter now respects
|
67
|
+
Database#default_string_column_size for setting the size of string
|
68
|
+
columns that don't use text as the database type.
|
69
|
+
|
70
|
+
* Database#supports_check_constraints? now returns true on MySQL
|
71
|
+
8.0.19+. This fixes drop_constraint in certain cases when combining
|
72
|
+
the constraint dropping with other changes in the same alter_table
|
73
|
+
block.
|
74
|
+
|
75
|
+
* The mysql adapter now supports the ruby-mysql 3 API (ruby-mysql
|
76
|
+
is a pure-ruby MySQL driver).
|
77
|
+
|
78
|
+
* The mysql adapter no longer uses the connection's server_version
|
79
|
+
method if it is defined, as the method does not return the
|
80
|
+
correct value when using the ruby-mysql driver with MariaDB.
|
81
|
+
|
82
|
+
* Comments added by the sql_comments extension no longer modify
|
83
|
+
cached SQL for a dataset.
|
84
|
+
|
85
|
+
= Other
|
86
|
+
|
87
|
+
* This is Sequel's 250th release!
|
data/doc/testing.rdoc
CHANGED
@@ -113,7 +113,7 @@ The order in which you delete/truncate the tables is important if you are using
|
|
113
113
|
|
114
114
|
= Testing Sequel Itself
|
115
115
|
|
116
|
-
Sequel has multiple separate test suites. All test suites use minitest/spec, with the minitest-hooks and minitest-shared_description extensions.
|
116
|
+
Sequel has multiple separate test suites. All test suites use minitest/spec, with the minitest-hooks, minitest-global_expectations, and minitest-shared_description extensions. To install the dependencies necessary to test Sequel, run <tt>gem install --development sequel</tt>.
|
117
117
|
|
118
118
|
== rake
|
119
119
|
|
@@ -145,6 +145,8 @@ The <tt>spec_<i>adapter</i></tt> specs run against a real database connection wi
|
|
145
145
|
|
146
146
|
These specs are broken down into two parts. For each database, there are specific specs that only apply to that database, and these are called the adapter specs. There are also shared specs that apply to all (or almost all) databases, these are called the integration specs. For database types that don't have specific adapter tests, you can use <tt>rake spec_integration</tt> to just run the shared integration tests.
|
147
147
|
|
148
|
+
Each adapter needs a specific gem installed in order to run. Please see the {connecting to a database guide}[rdoc-ref:doc/opening_databases.rdoc] for which gem you need to install for the adapter you are testing.
|
149
|
+
|
148
150
|
== Environment variables
|
149
151
|
|
150
152
|
Sequel uses environment variables when testing to specify either the database to be tested or specify how testing should be done. You can also specify the databases to test by copying <tt>spec/spec_config.rb.example</tt> to <tt>spec/spec_config.rb</tt> and modifying it. See that file for details. It may be necessary to use +spec_config.rb+ as opposed to an environment variable if your database connection cannot be specified by a connection string.
|
data/lib/sequel/adapters/ado.rb
CHANGED
@@ -118,11 +118,9 @@ module Sequel
|
|
118
118
|
# Yield an available connection. Rescue
|
119
119
|
# any Amalgalite::Errors and turn them into DatabaseErrors.
|
120
120
|
def _execute(sql, opts)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
raise_error(e)
|
125
|
-
end
|
121
|
+
synchronize(opts[:server]){|conn| yield conn}
|
122
|
+
rescue ::Amalgalite::Error, ::Amalgalite::SQLite3::Error => e
|
123
|
+
raise_error(e)
|
126
124
|
end
|
127
125
|
|
128
126
|
# The Amagalite adapter does not need the pool to convert exceptions.
|
@@ -246,7 +246,7 @@ module Sequel
|
|
246
246
|
end
|
247
247
|
begin
|
248
248
|
stmt = log_connection_yield(log_sql, conn, args){conn.execute_prepared(ps_name, *args)}
|
249
|
-
if
|
249
|
+
if defined?(yield)
|
250
250
|
yield(stmt)
|
251
251
|
else
|
252
252
|
stmt.affected
|
@@ -268,7 +268,7 @@ module Sequel
|
|
268
268
|
# is given or returning the number of affected rows if not, and ensuring the statement is freed.
|
269
269
|
def _execute(conn, sql, opts)
|
270
270
|
stmt = log_connection_yield(sql, conn){conn.execute(sql)}
|
271
|
-
if
|
271
|
+
if defined?(yield)
|
272
272
|
yield(stmt)
|
273
273
|
else
|
274
274
|
stmt.affected
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
Sequel::JDBC.load_driver('org.apache.derby.jdbc.EmbeddedDriver', :Derby)
|
4
4
|
require_relative 'transactions'
|
5
|
+
require_relative '../utils/columns_limit_1'
|
5
6
|
|
6
7
|
module Sequel
|
7
8
|
module JDBC
|
@@ -182,6 +183,8 @@ module Sequel
|
|
182
183
|
end
|
183
184
|
|
184
185
|
class Dataset < JDBC::Dataset
|
186
|
+
include ::Sequel::Dataset::ColumnsLimit1
|
187
|
+
|
185
188
|
# Derby doesn't support an expression between CASE and WHEN,
|
186
189
|
# so remove conditions.
|
187
190
|
def case_expression_sql_append(sql, ce)
|
@@ -35,9 +35,9 @@ module Sequel
|
|
35
35
|
data = opts[:data]
|
36
36
|
data = Array(data) if data.is_a?(String)
|
37
37
|
|
38
|
-
if
|
38
|
+
if defined?(yield) && data
|
39
39
|
raise Error, "Cannot provide both a :data option and a block to copy_into"
|
40
|
-
elsif !
|
40
|
+
elsif !defined?(yield) && !data
|
41
41
|
raise Error, "Must provide either a :data option or a block to copy_into"
|
42
42
|
end
|
43
43
|
|
@@ -45,7 +45,7 @@ module Sequel
|
|
45
45
|
begin
|
46
46
|
copy_manager = org.postgresql.copy.CopyManager.new(conn)
|
47
47
|
copier = copy_manager.copy_in(copy_into_sql(table, opts))
|
48
|
-
if
|
48
|
+
if defined?(yield)
|
49
49
|
while buf = yield
|
50
50
|
java_bytes = buf.to_java_bytes
|
51
51
|
copier.writeToCopy(java_bytes, 0, java_bytes.length)
|
@@ -77,7 +77,7 @@ module Sequel
|
|
77
77
|
copy_manager = org.postgresql.copy.CopyManager.new(conn)
|
78
78
|
copier = copy_manager.copy_out(copy_table_sql(table, opts))
|
79
79
|
begin
|
80
|
-
if
|
80
|
+
if defined?(yield)
|
81
81
|
while buf = copier.readFromCopy
|
82
82
|
yield(String.from_java_bytes(buf))
|
83
83
|
end
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -32,15 +32,13 @@ module Sequel
|
|
32
32
|
|
33
33
|
# Allow loading the necessary JDBC support via a gem.
|
34
34
|
def self.load_gem(name)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
jdbc_module.load_driver if jdbc_module.respond_to?(:load_driver)
|
43
|
-
end
|
35
|
+
require "jdbc/#{name.to_s.downcase}"
|
36
|
+
rescue LoadError
|
37
|
+
# jdbc gem not used, hopefully the user has the .jar in their CLASSPATH
|
38
|
+
else
|
39
|
+
if defined?(::Jdbc) && ( ::Jdbc.const_defined?(name) rescue nil )
|
40
|
+
jdbc_module = ::Jdbc.const_get(name) # e.g. Jdbc::SQLite3
|
41
|
+
jdbc_module.load_driver if jdbc_module.respond_to?(:load_driver)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -196,7 +194,7 @@ module Sequel
|
|
196
194
|
args.each{|arg| set_ps_arg(cps, arg, i+=1)}
|
197
195
|
|
198
196
|
begin
|
199
|
-
if
|
197
|
+
if defined?(yield)
|
200
198
|
yield log_connection_yield(sql, conn){cps.executeQuery}
|
201
199
|
else
|
202
200
|
log_connection_yield(sql, conn){cps.executeUpdate}
|
@@ -461,7 +459,7 @@ module Sequel
|
|
461
459
|
msg << ")"
|
462
460
|
end
|
463
461
|
begin
|
464
|
-
if
|
462
|
+
if defined?(yield)
|
465
463
|
yield log_connection_yield(msg, conn, args){cps.executeQuery}
|
466
464
|
else
|
467
465
|
case opts[:type]
|