sequel 5.34.0 → 5.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +82 -0
- data/README.rdoc +2 -2
- data/doc/association_basics.rdoc +7 -2
- data/doc/cheat_sheet.rdoc +5 -5
- data/doc/code_order.rdoc +0 -12
- data/doc/dataset_filtering.rdoc +2 -2
- data/doc/fork_safety.rdoc +84 -0
- data/doc/model_plugins.rdoc +1 -1
- data/doc/opening_databases.rdoc +5 -1
- data/doc/postgresql.rdoc +1 -1
- data/doc/querying.rdoc +3 -3
- data/doc/release_notes/5.35.0.txt +56 -0
- data/doc/release_notes/5.36.0.txt +60 -0
- data/doc/release_notes/5.37.0.txt +30 -0
- data/doc/release_notes/5.38.0.txt +28 -0
- data/doc/release_notes/5.39.0.txt +19 -0
- data/doc/transactions.rdoc +0 -8
- data/doc/validations.rdoc +1 -1
- data/lib/sequel/adapters/jdbc.rb +13 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +4 -4
- data/lib/sequel/adapters/odbc.rb +4 -6
- data/lib/sequel/adapters/oracle.rb +2 -1
- data/lib/sequel/adapters/shared/mssql.rb +35 -5
- data/lib/sequel/adapters/shared/oracle.rb +13 -7
- data/lib/sequel/adapters/shared/postgres.rb +40 -2
- data/lib/sequel/adapters/shared/sqlite.rb +8 -2
- data/lib/sequel/adapters/tinytds.rb +1 -0
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -0
- data/lib/sequel/core.rb +5 -6
- data/lib/sequel/database/connecting.rb +0 -1
- data/lib/sequel/database/misc.rb +14 -0
- data/lib/sequel/database/schema_generator.rb +6 -0
- data/lib/sequel/database/schema_methods.rb +16 -6
- data/lib/sequel/database/transactions.rb +2 -2
- data/lib/sequel/dataset/actions.rb +10 -6
- data/lib/sequel/dataset/query.rb +1 -1
- data/lib/sequel/deprecated.rb +1 -1
- data/lib/sequel/extensions/_pretty_table.rb +1 -2
- data/lib/sequel/extensions/columns_introspection.rb +1 -2
- data/lib/sequel/extensions/core_refinements.rb +2 -0
- data/lib/sequel/extensions/duplicate_columns_handler.rb +2 -0
- data/lib/sequel/extensions/migration.rb +8 -2
- data/lib/sequel/extensions/pg_array_ops.rb +4 -0
- data/lib/sequel/extensions/pg_enum.rb +2 -0
- data/lib/sequel/extensions/pg_extended_date_support.rb +1 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +2 -0
- data/lib/sequel/extensions/pg_inet.rb +2 -0
- data/lib/sequel/extensions/pg_json_ops.rb +46 -2
- data/lib/sequel/extensions/pg_range.rb +3 -7
- data/lib/sequel/extensions/pg_range_ops.rb +2 -0
- data/lib/sequel/extensions/pg_row.rb +0 -1
- data/lib/sequel/extensions/pg_row_ops.rb +24 -0
- data/lib/sequel/extensions/query.rb +1 -0
- data/lib/sequel/extensions/run_transaction_hooks.rb +1 -1
- data/lib/sequel/extensions/s.rb +2 -0
- data/lib/sequel/extensions/schema_dumper.rb +3 -3
- data/lib/sequel/extensions/symbol_aref_refinement.rb +2 -0
- data/lib/sequel/extensions/symbol_as_refinement.rb +2 -0
- data/lib/sequel/extensions/to_dot.rb +9 -3
- data/lib/sequel/model.rb +1 -1
- data/lib/sequel/model/associations.rb +24 -7
- data/lib/sequel/model/base.rb +9 -3
- data/lib/sequel/model/plugins.rb +1 -0
- data/lib/sequel/plugins/association_pks.rb +3 -2
- data/lib/sequel/plugins/association_proxies.rb +1 -0
- data/lib/sequel/plugins/blacklist_security.rb +1 -2
- data/lib/sequel/plugins/class_table_inheritance.rb +3 -8
- data/lib/sequel/plugins/csv_serializer.rb +2 -0
- data/lib/sequel/plugins/dirty.rb +44 -0
- data/lib/sequel/plugins/forbid_lazy_load.rb +2 -0
- data/lib/sequel/plugins/instance_specific_default.rb +113 -0
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/pg_array_associations.rb +2 -3
- data/lib/sequel/plugins/prepared_statements.rb +5 -11
- data/lib/sequel/plugins/prepared_statements_safe.rb +1 -3
- data/lib/sequel/plugins/rcte_tree.rb +8 -14
- data/lib/sequel/plugins/single_table_inheritance.rb +7 -0
- data/lib/sequel/plugins/string_stripper.rb +1 -1
- data/lib/sequel/plugins/tree.rb +9 -4
- data/lib/sequel/plugins/validation_class_methods.rb +5 -1
- data/lib/sequel/timezones.rb +8 -3
- data/lib/sequel/version.rb +1 -1
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b995589f8bb51611b490ae4cd1d84c2ecfbb5889cb4f940dd786a841fe9ecf9f
|
4
|
+
data.tar.gz: afa86ae9dfc39cd21138aff35955fb4194c359a1ea56c9a80026f04b85b79a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 553d5c2b92a49d079503c9e8e0f8dfecef1a4abf2ed2fe242c8aec19d53c918912de4f5d1453626a05c1b654c5582c508199df10aa7540ec590331b3ecb355da
|
7
|
+
data.tar.gz: f0fc7bceadccc74651573f82ed957ab91061ecb05f5f30050d0814a0142b915a79175d146b3bcac6f7269cd4f3b3b69eb58a92a4df439a944c081b45f1deaa2c
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,85 @@
|
|
1
|
+
=== 5.39.0 (2020-12-01)
|
2
|
+
|
3
|
+
* Support :clustered option for primary key and unique constraints on Microsoft SQL Server (jeremyevans)
|
4
|
+
|
5
|
+
* Do not modify the size of binary columns when using set_column_allow_null on Microsoft SQL Server (jeremyevans) (#1736)
|
6
|
+
|
7
|
+
* Add a fork safety guide with more detail on how to use Sequel with libraries that fork (janko) (#1733)
|
8
|
+
|
9
|
+
* Make the roots_dataset method in the tree plugin work with queries using joins (jeremyevans) (#1731)
|
10
|
+
|
11
|
+
* Make Database#tables return partitioned tables on PostgreSQL 10+ (epoberezhny) (#1729, #1730)
|
12
|
+
|
13
|
+
=== 5.38.0 (2020-11-01)
|
14
|
+
|
15
|
+
* Do not add new Database instances to Sequel::DATABASES if the test connection fails (jeremyevans) (#1727)
|
16
|
+
|
17
|
+
* Support the newer com.mysql.cj.jdbc.Driver in the jdbc/mysql adapter (jeremyevans)
|
18
|
+
|
19
|
+
* Do not swallow disconnect errors in Database#create_or_replace_view or Database#create_table* on Oracle (jeremyevans)
|
20
|
+
|
21
|
+
* Only rescue non-disconnect Sequel::DatabaseErrors in Postgres::Database#server_version (jeremyevans) (#1724)
|
22
|
+
|
23
|
+
* Make the single_table_inheritance and prepared_statements plugins work if loaded into the same class (jeremyevans) (#1721)
|
24
|
+
|
25
|
+
=== 5.37.0 (2020-10-01)
|
26
|
+
|
27
|
+
* Recognize more unsigned decimal/float types in the schema dumper (akimd, jeremyevans) (#1720)
|
28
|
+
|
29
|
+
* Add Postgres::PGRow::{Array,Hash}Row#op to the pg_row_ops extension if the pg_row extension is loaded (jeremyevans)
|
30
|
+
|
31
|
+
* Add Model#column_previously_was and #column_previously_changed? to the dirty plugin (jeremyevans)
|
32
|
+
|
33
|
+
* Raise Migrator::Error if attempting to migrate down to a version where there are necessary migration files missing (jeremyevans) (#1716)
|
34
|
+
|
35
|
+
=== 5.36.0 (2020-09-01)
|
36
|
+
|
37
|
+
* Handle passing keyword arguments through class methods defined via Plugins.def_dataset_method on Ruby 2.7+ (jeremyevans)
|
38
|
+
|
39
|
+
* Handle passing keyword arguments through when loading plugins on Ruby 2.7+ (jeremyevans)
|
40
|
+
|
41
|
+
* Handle passing keyword arguments through migrations when defining custom Database methods that accept keywords on Ruby 2.7+ (jeremyevans)
|
42
|
+
|
43
|
+
* Handle passing keyword arguments through Dataset#query when using the query extension on Ruby 2.7+ (jeremyevans)
|
44
|
+
|
45
|
+
* Handle passing keyword arguments through the association proxy when using the association_proxies plugin on Ruby 2.7+ (jeremyevans)
|
46
|
+
|
47
|
+
* Handle passing keyword arguments through the class method to a method defined in dataset_module on Ruby 2.7+ (adam12) (#1713)
|
48
|
+
|
49
|
+
* Stream result sets in the odbc adapter for better performance and lower memory usage (sparrovv) (#1711)
|
50
|
+
|
51
|
+
* Add Postgres::JSONBOp#set_lax and #path_*_tz methods to the pg_json_ops extension for new jsonb functions added in PostgreSQL 13 (jeremyevans)
|
52
|
+
|
53
|
+
* Add Dataset#with_ties on PostgreSQL 13+ and Microsoft SQL Server to include rows with same order as final row (jeremyevans)
|
54
|
+
|
55
|
+
* Add a :current_schema option to Database#view_exists? (only defined on Oracle) to look in the current schema instead of non-system schemas (jeremyevans) (#1710)
|
56
|
+
|
57
|
+
* Recognize another disconnect error in the mysql and mysql2 adapters (jeremyevans) (#1706)
|
58
|
+
|
59
|
+
=== 5.35.0 (2020-08-01)
|
60
|
+
|
61
|
+
* Recognize another disconnect error in the oracle adapter (sterlzbd) (#1705)
|
62
|
+
|
63
|
+
* Consider all associations with :dataset options as instance-specific associations (jeremyevans)
|
64
|
+
|
65
|
+
* Make Model.finalize_associations not break with instance-specific associations (jeremyevans)
|
66
|
+
|
67
|
+
* Make association placeholder loader consider block if instance_specific: false association option is used (jeremyevans)
|
68
|
+
|
69
|
+
* Copy composite unique constraints when emulating alter table operations on SQLite (jeremyevans) (#1704)
|
70
|
+
|
71
|
+
* Add instance_specific_default plugin for setting default association :instance_specific value, or warning/raising for cases where it is not specified (jeremyevans)
|
72
|
+
|
73
|
+
* Make Model.plugin issue deprecation warning if loading plugin with arguments and block if plugin does not accept arguments/block (jeremyevans)
|
74
|
+
|
75
|
+
* Make validation_class_methods consider all :if, :allow_missing, :allow_nil, and :allow_blank settings, instead of just the first (jeremyevans)
|
76
|
+
|
77
|
+
* Include hash entries with nil keys in Dataset#to_dot output in to_dot extension (jeremyevans)
|
78
|
+
|
79
|
+
* Remove unneeded conditionals from plugins and extensions (jeremyevans)
|
80
|
+
|
81
|
+
* Fix exception class in run_transaction_hooks extension if calling run_after_{commit,rollback}_hooks outside of a transaction (jeremyevans)
|
82
|
+
|
1
83
|
=== 5.34.0 (2020-07-01)
|
2
84
|
|
3
85
|
* Make eager_graph work correctly if called with no associations (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -172,7 +172,7 @@ Datasets are the primary way records are retrieved and manipulated. They are ge
|
|
172
172
|
posts = DB.from(:posts)
|
173
173
|
posts = DB[:posts] # same
|
174
174
|
|
175
|
-
Datasets will only fetch records when you tell them to. They can be manipulated to filter records, change ordering, join tables, etc
|
175
|
+
Datasets will only fetch records when you tell them to. They can be manipulated to filter records, change ordering, join tables, etc. Datasets are always frozen, and they are safe to use by multiple threads concurrently.
|
176
176
|
|
177
177
|
=== Retrieving Records
|
178
178
|
|
@@ -883,7 +883,7 @@ raise an error by default:
|
|
883
883
|
== Sequel Release Policy
|
884
884
|
|
885
885
|
New major versions of Sequel do not have a defined release policy, but historically have
|
886
|
-
occurred once
|
886
|
+
occurred once every few years.
|
887
887
|
|
888
888
|
New minor versions of Sequel are released around once a month near the start of the month.
|
889
889
|
|
data/doc/association_basics.rdoc
CHANGED
@@ -1676,11 +1676,16 @@ instances.
|
|
1676
1676
|
==== :instance_specific
|
1677
1677
|
|
1678
1678
|
This allows you to override the setting of whether the dataset contains instance
|
1679
|
-
specific code.
|
1679
|
+
specific code. If you are passing a block to the association,
|
1680
1680
|
Sequel sets this to true by default, which disables some optimizations that
|
1681
1681
|
would be invalid if the association is instance specific. If you know that the
|
1682
1682
|
block does not contain instance specific code, you can set this to false to
|
1683
|
-
reenable the optimizations.
|
1683
|
+
reenable the optimizations. Instance specific code is mostly commonly calling
|
1684
|
+
model instance methods inside an association block, but also
|
1685
|
+
includes cases where the association block can return different values based
|
1686
|
+
on the runtime environment, such as calls to <tt>Time.now</tt> in the block.
|
1687
|
+
Associations that use the :dataset option are always considered instance specific,
|
1688
|
+
even if explicitly specified otherwise.
|
1684
1689
|
|
1685
1690
|
==== :cartesian_product_number
|
1686
1691
|
|
data/doc/cheat_sheet.rdoc
CHANGED
@@ -95,18 +95,18 @@ Without a filename argument, the sqlite adapter will setup a new sqlite database
|
|
95
95
|
|
96
96
|
=== AND/OR/NOT
|
97
97
|
|
98
|
-
DB[:items].where{(x > 5) & (y > 10)}
|
98
|
+
DB[:items].where{(x > 5) & (y > 10)}
|
99
99
|
# SELECT * FROM items WHERE ((x > 5) AND (y > 10))
|
100
100
|
|
101
|
-
DB[:items].where(Sequel.or(x: 1, y: 2) & Sequel.~(z: 3))
|
101
|
+
DB[:items].where(Sequel.or(x: 1, y: 2) & Sequel.~(z: 3))
|
102
102
|
# SELECT * FROM items WHERE (((x = 1) OR (y = 2)) AND (z != 3))
|
103
103
|
|
104
104
|
=== Mathematical operators
|
105
105
|
|
106
|
-
DB[:items].where{x + y > z}
|
106
|
+
DB[:items].where{x + y > z}
|
107
107
|
# SELECT * FROM items WHERE ((x + y) > z)
|
108
108
|
|
109
|
-
DB[:items].where{price - 100 < avg(price)}
|
109
|
+
DB[:items].where{price - 100 < avg(price)}
|
110
110
|
# SELECT * FROM items WHERE ((price - 100) < avg(price))
|
111
111
|
|
112
112
|
=== Raw SQL Fragments
|
@@ -130,7 +130,7 @@ Without a filename argument, the sqlite adapter will setup a new sqlite database
|
|
130
130
|
|
131
131
|
== Joins
|
132
132
|
|
133
|
-
DB[:items].left_outer_join(:categories, id: :category_id)
|
133
|
+
DB[:items].left_outer_join(:categories, id: :category_id)
|
134
134
|
# SELECT * FROM items
|
135
135
|
# LEFT OUTER JOIN categories ON categories.id = items.category_id
|
136
136
|
|
data/doc/code_order.rdoc
CHANGED
@@ -100,15 +100,3 @@ and freezing them can easily be achieved through the plugin:
|
|
100
100
|
# ... setup models
|
101
101
|
# Now finalize associations & freeze models by calling the plugin:
|
102
102
|
Sequel::Model.freeze_descendents
|
103
|
-
|
104
|
-
== Disconnect If Using Forking Webserver with Code Preloading
|
105
|
-
|
106
|
-
If you are using a forking webserver such as unicorn or passenger, with
|
107
|
-
a feature that loads your Sequel code before forking connections (code
|
108
|
-
preloading), then you must disconnect your database connections before
|
109
|
-
forking. If you don't do this, you can end up with child processes
|
110
|
-
sharing database connections and all sorts of weird behavior. Sequel
|
111
|
-
will automatically reconnect on an as needed basis in the child
|
112
|
-
processes, so you only need to do the following in the parent process:
|
113
|
-
|
114
|
-
DB.disconnect
|
data/doc/dataset_filtering.rdoc
CHANGED
@@ -36,8 +36,8 @@ Ranges (both inclusive and exclusive) can also be used:
|
|
36
36
|
|
37
37
|
If you need to select multiple items from a dataset, you can supply an array:
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
items.where(id: [1, 38, 47, 99]).sql
|
40
|
+
# "SELECT * FROM items WHERE (id IN (1, 38, 47, 99))"
|
41
41
|
|
42
42
|
== Filtering using expressions
|
43
43
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
= Fork Safety
|
2
|
+
|
3
|
+
If you are forking or using a library that forks after you have created a
|
4
|
+
Sequel::Database instance, then you must disconnect database connections before forking. If you
|
5
|
+
don't do this, you can end up with child processes sharing database connections
|
6
|
+
and all sorts of weird behavior, including crashes. Sequel will automatically create new
|
7
|
+
connections on an as needed basis in the child processes, so you only need to do the following in
|
8
|
+
the parent process:
|
9
|
+
|
10
|
+
DB.disconnect
|
11
|
+
|
12
|
+
Or if you have connections to multiple databases:
|
13
|
+
|
14
|
+
Sequel::DATABASES.each(&:disconnect)
|
15
|
+
|
16
|
+
== Puma
|
17
|
+
|
18
|
+
When using the Puma web server in clustered mode (which is the default behavior in Puma 5+ when
|
19
|
+
using multiple processes), you should disconnect inside the +before_fork+ hook in your
|
20
|
+
Puma config:
|
21
|
+
|
22
|
+
before_fork do
|
23
|
+
Sequel::DATABASES.each(&:disconnect)
|
24
|
+
end
|
25
|
+
|
26
|
+
== Unicorn
|
27
|
+
|
28
|
+
When using the Unicorn web server and preloading the application (+preload_app true+ in the Unicorn
|
29
|
+
config), you should disconnect inside the +before_fork+ hook in the Unicorn config:
|
30
|
+
|
31
|
+
before_fork do
|
32
|
+
Sequel::DATABASES.each(&:disconnect)
|
33
|
+
end
|
34
|
+
|
35
|
+
== Passenger
|
36
|
+
|
37
|
+
In Passenger web server, you should disconnect inside the
|
38
|
+
+starting_worker_process+ event hook:
|
39
|
+
|
40
|
+
if defined?(PhusionPassenger)
|
41
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
42
|
+
Sequel::DATABASES.each(&:disconnect) if forked
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Note that this disconnects after forking instead of before forking. Passenger does not
|
47
|
+
offer a before fork hook.
|
48
|
+
|
49
|
+
== Spring
|
50
|
+
|
51
|
+
In Spring application preloader, you should disconnect inside the +after_fork+ hook:
|
52
|
+
|
53
|
+
if defined?(Spring)
|
54
|
+
Spring.after_fork do
|
55
|
+
Sequel::DATABASES.each(&:disconnect)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
As the method indicates, this disconnects after forking instead of before forking.
|
60
|
+
Spring does not offer a before fork hook.
|
61
|
+
|
62
|
+
== Resque
|
63
|
+
|
64
|
+
In Resque, you should disconnect inside the +before_fork+ hook:
|
65
|
+
|
66
|
+
Resque.before_fork do |job|
|
67
|
+
Sequel::DATABASES.each(&:disconnect)
|
68
|
+
end
|
69
|
+
|
70
|
+
== Parallel
|
71
|
+
|
72
|
+
If you're using the Parallel gem with processes, you should disconnect before
|
73
|
+
calling it:
|
74
|
+
|
75
|
+
Sequel::DATABASES.each(&:disconnect)
|
76
|
+
Parallel.map(['a','b','c'], in_processes: 3) { |one_letter| }
|
77
|
+
|
78
|
+
== Other Libraries Calling fork
|
79
|
+
|
80
|
+
For any other library that calls fork, you should disconnect before calling
|
81
|
+
a method that forks:
|
82
|
+
|
83
|
+
Sequel::DATABASES.each(&:disconnect)
|
84
|
+
SomeLibrary.method_that_forks
|
data/doc/model_plugins.rdoc
CHANGED
@@ -212,7 +212,7 @@ In general you should only require plugin arguments if you absolutely must have
|
|
212
212
|
|
213
213
|
== Handling Subclasses
|
214
214
|
|
215
|
-
Sequel::Model uses a copy-on-subclassing approach to model state. So instead of model
|
215
|
+
Sequel::Model uses a copy-on-subclassing approach to model state. So instead of having a model subclass ask its superclass for a value if the subclass don't have the value defined, the value should be copied from the parent class to the subclass when the subclass is created. While this can be implemented by overriding the +inherited+ class method, there is an available shortcut that handles most cases:
|
216
216
|
|
217
217
|
module Sequel::Plugins::Foo
|
218
218
|
module ClassMethods
|
data/doc/opening_databases.rdoc
CHANGED
@@ -208,7 +208,7 @@ Example connection strings:
|
|
208
208
|
|
209
209
|
jdbc:sqlite::memory:
|
210
210
|
jdbc:postgresql://localhost/database?user=username
|
211
|
-
jdbc:mysql://localhost/test?user=root&password=root
|
211
|
+
jdbc:mysql://localhost/test?user=root&password=root&serverTimezone=UTC
|
212
212
|
jdbc:h2:mem:
|
213
213
|
jdbc:hsqldb:mem:mymemdb
|
214
214
|
jdbc:derby:memory:myDb;create=true
|
@@ -240,6 +240,10 @@ The following additional options are supported:
|
|
240
240
|
There are a few issues with specific jdbc driver gems:
|
241
241
|
|
242
242
|
jdbc-h2 :: jdbc-h2 versions greater than 1.3.175 have issues with ORDER BY not working correctly in some cases.
|
243
|
+
jdbc-mysql :: Depending on the configuration of the MySQL server, jdbc-mysql versions greater 8 may complain
|
244
|
+
about the server time zone being unrecognized. You can either use an older jdbc-mysql version,
|
245
|
+
or you can specify the +serverTimezone+ option in the connection string, as shown in the example
|
246
|
+
jdbc:mysql connection string above.
|
243
247
|
|
244
248
|
=== mysql
|
245
249
|
|
data/doc/postgresql.rdoc
CHANGED
@@ -213,7 +213,7 @@ other tables. Support may be added in the future.
|
|
213
213
|
=== Creating Unlogged Tables
|
214
214
|
|
215
215
|
PostgreSQL allows users to create unlogged tables, which are faster but not crash safe. Sequel
|
216
|
-
allows you
|
216
|
+
allows you to create an unlogged table by specifying the <tt>unlogged: true</tt> option to +create_table+:
|
217
217
|
|
218
218
|
DB.create_table(:table, unlogged: true){Integer :i}
|
219
219
|
# CREATE UNLOGGED TABLE "table" ("i" integer)
|
data/doc/querying.rdoc
CHANGED
@@ -746,7 +746,7 @@ shortcuts for all common (and most uncommon) join types. For example
|
|
746
746
|
|
747
747
|
Album.join(:artists, id: :artist_id)
|
748
748
|
# SELECT * FROM albums
|
749
|
-
# INNER JOIN artists ON (artists.id = albums.artist_id)
|
749
|
+
# INNER JOIN artists ON (artists.id = albums.artist_id)
|
750
750
|
|
751
751
|
And +left_join+ does a LEFT JOIN:
|
752
752
|
|
@@ -870,14 +870,14 @@ In this case, you don't even need to specify any conditions.
|
|
870
870
|
==== Join Blocks
|
871
871
|
|
872
872
|
You can provide a block to any of the join methods that accept
|
873
|
-
conditions. This block should accept 3 arguments
|
873
|
+
conditions. This block should accept 3 arguments: the table alias
|
874
874
|
for the table currently being joined, the table alias for the last
|
875
875
|
table joined (or first table), and an array of previous
|
876
876
|
<tt>Sequel::SQL::JoinClause</tt>s.
|
877
877
|
|
878
878
|
This allows you to qualify columns similar to how the implicit
|
879
879
|
qualification works, without worrying about the specific aliases
|
880
|
-
being used. For example,
|
880
|
+
being used. For example, let's say you wanted to join the albums
|
881
881
|
and artists tables, but only want albums where the artist's name
|
882
882
|
comes before the album's name.
|
883
883
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An instance_specific_default plugin has been added for setting the
|
4
|
+
default for the :instance_specific association option, or
|
5
|
+
warning/raises in cases where it is not specified. This allows
|
6
|
+
you to easily find associations that would be considering instance
|
7
|
+
specific by default, and mark them as not instance specific for
|
8
|
+
better performance.
|
9
|
+
|
10
|
+
= Other Improvements
|
11
|
+
|
12
|
+
* Setting the :instance_specific association option to false now
|
13
|
+
works correctly if the association uses a block. Associations
|
14
|
+
that set the :dataset option are now always considered instance
|
15
|
+
specific, even if the :instance_specific option is explicitly
|
16
|
+
passed.
|
17
|
+
|
18
|
+
* The validation_class_methods plugin now considers all :if,
|
19
|
+
:allow_missing, :allow_nil, and :allow_blank options. Previously,
|
20
|
+
it only considered the first of those options that was set.
|
21
|
+
|
22
|
+
* Model.finalize_associations no longer breaks if you have
|
23
|
+
instance-specific associations.
|
24
|
+
|
25
|
+
* Model.plugin now warns if you load the plugin with arguments or a
|
26
|
+
block if the plugin does not accept arguments or block. This is
|
27
|
+
because a future change to Sequel could break the call.
|
28
|
+
|
29
|
+
* When emulating unsupported alter table operations on SQLite, Sequel
|
30
|
+
now copies composite unique constraints unless the alter table
|
31
|
+
operation is the dropping of a unique constraint.
|
32
|
+
|
33
|
+
* Sequel now recognizes an additional disconnect error in the oracle
|
34
|
+
adapter.
|
35
|
+
|
36
|
+
* In the run_transaction_hooks extension, calling
|
37
|
+
run_after_{commit,rollback}_hooks now raises the correct exception
|
38
|
+
class.
|
39
|
+
|
40
|
+
* In the pg_range extension, conversion procs for the tsrange[] and
|
41
|
+
tstzrange[] types are not added unless the Database uses the
|
42
|
+
pg_array extension.
|
43
|
+
|
44
|
+
* Multiple unnecessary conditionals in plugins and extensions have
|
45
|
+
been removed.
|
46
|
+
|
47
|
+
* Sequel plugin and extension code now have 100% branch coverage.
|
48
|
+
|
49
|
+
* Sequel now avoids a statement not reached verbose warning in
|
50
|
+
Dataset#clone.
|
51
|
+
|
52
|
+
= Backwards Compatibility
|
53
|
+
|
54
|
+
* The output of Dataset#to_dot in the to_dot extension has changed
|
55
|
+
slightly, including hash entries with nil keys. These entries
|
56
|
+
were previously ignored.
|
@@ -0,0 +1,60 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* Dataset#with_ties has been added on PostgreSQL 13+ and Microsoft
|
4
|
+
SQL Server, which will have a limited dataset also return all
|
5
|
+
rows with the same order as the final row.
|
6
|
+
|
7
|
+
* In the pg_json_ops extension, the following methods have been
|
8
|
+
added to Postgres::JSONBOp, all of which require PostgreSQL 13+:
|
9
|
+
|
10
|
+
* #set_lax
|
11
|
+
* #path_exists_tz!
|
12
|
+
* #path_match_tz!
|
13
|
+
* #path_query_tz
|
14
|
+
* #path_query_array_tz
|
15
|
+
* #path_query_first_tz
|
16
|
+
|
17
|
+
* On Oracle, the Database#view_exists? method now accepts a
|
18
|
+
:current_schema option to limit the views returned to the
|
19
|
+
current schema, instead of all non-system schemas.
|
20
|
+
|
21
|
+
= Other Improvements
|
22
|
+
|
23
|
+
* Sequel will now pass keyword arguments through in the following
|
24
|
+
cases:
|
25
|
+
|
26
|
+
* When loading plugins (Model.plugin)
|
27
|
+
|
28
|
+
* Class methods automically defined for methods defined in a
|
29
|
+
Model.dataset_module block
|
30
|
+
|
31
|
+
* Methods defined by Plugins.def_dataset_method
|
32
|
+
|
33
|
+
* Database methods called inside migrations
|
34
|
+
|
35
|
+
* Methods called via an association proxy when using the
|
36
|
+
association_proxies plugin.
|
37
|
+
|
38
|
+
* Dataset methods called inside a Dataset#query block when using
|
39
|
+
the query extension.
|
40
|
+
|
41
|
+
Previously, keywords were not handled in these cases, which would
|
42
|
+
cause deprecation warnings in Ruby 2.7 and ArgumentErrors in Ruby
|
43
|
+
3.0. Note that Sequel itself does not use keyword arguments at
|
44
|
+
all, so all of these changes only affect cases where external
|
45
|
+
methods are defined that accept keywords, and Sequel methods are
|
46
|
+
called with keywords that end up being delegated to the external
|
47
|
+
methods.
|
48
|
+
|
49
|
+
* The odbc adapter will now stream result sets instead of loading
|
50
|
+
the entire result set in memory and then iterating over it.
|
51
|
+
|
52
|
+
* Sequel now recognizes another disconnect error in the mysql and
|
53
|
+
mysql2 adapters.
|
54
|
+
|
55
|
+
= Backwards Compatibility
|
56
|
+
|
57
|
+
* Due to the odbc adapter change to use streaming, issuing queries
|
58
|
+
inside a Dataset#each block will no longer work unless a different
|
59
|
+
shard or thread is used. The behavior of such code is considered
|
60
|
+
undefined on all Sequel adapters.
|