sequel 5.50.0 → 5.51.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '088fd20b772371a3a765e7f8c24103c940fdc4f9a33828fee9e3e2f04dc38768'
4
- data.tar.gz: 46daff6f4e927d98035fdf6f967a5c8020aefd4278308e788fa5f640877bda24
3
+ metadata.gz: ebee8a266be02f6ba3c1d5d340b606336dbb0fb74beb4b4333eb3c930cd59b5c
4
+ data.tar.gz: f657a1aaedf3e0ef8f644097ee94760dfb04381730dd0c6f0a53c57e3f2bc742
5
5
  SHA512:
6
- metadata.gz: 84b5d7b1dc1689c55da14e745de590f62a9052df9171043d9232b7817751a3c045d1021429fb05f2663a6754958a2c3935426b85e5f1ff4f8895fc57aa6049f3
7
- data.tar.gz: 458d85e4f05fd97f4c74a0af4a324b6ee47207d8afb00aee4fb8c1b6b1854175e50162a3b5ad0bac4e35498620cd4b4d3531ad7a71e7e65c3604f0a1677a53d5
6
+ metadata.gz: 9a0aac448e73636a0c20e5e4d87d65ac648a56bb4267034c5b92fdf2cf297aeeaff408dc4e79c6fe05bdd113e22824a5d7bc7a5b236b44346cda6ed427a377c1
7
+ data.tar.gz: d99a2b488a0735ba9012e4dfcaae30bec76fce1e7d3c34a14be9395241432a3d00ec5fa7a22df371810adf734e0c39230d212934f10a7d39c5839e58231d6625
data/CHANGELOG CHANGED
@@ -1,3 +1,17 @@
1
+ === 5.51.0 (2021-12-01)
2
+
3
+ * Make eager loading via tactical_eager_loading no longer modify objects who already have a cached value for the association (jeremyevans)
4
+
5
+ * Make association cloning handle cases where clone association sets different :class option than cloned association (jeremyevans)
6
+
7
+ * Make column schema entries on MySQL include an :extra entry for the Extra column in DESCRIBE output (bschmeck) (#1791)
8
+
9
+ * Update mock PostgreSQL adapter to default to PostgreSQL 14 instead of PostgreSQL 9.5 (jeremyevans)
10
+
11
+ * Support Dataset#with_recursive :search and :cycle options on PostgreSQL 14+ for result ordering and cycle detection (jeremyevans)
12
+
13
+ * Avoid method redefined verbose mode warnings in lazy_attributes plugin (jeremyevans)
14
+
1
15
  === 5.50.0 (2021-11-01)
2
16
 
3
17
  * 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)
data/README.rdoc CHANGED
@@ -17,11 +17,12 @@ toolkit for Ruby.
17
17
 
18
18
  == Resources
19
19
 
20
- Website :: http://sequel.jeremyevans.net
21
- RDoc Documentation :: http://sequel.jeremyevans.net/rdoc
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) :: http://github.com/jeremyevans/sequel/issues
24
- Discussion Forum (sequel-talk Google Group) :: http://groups.google.com/group/sequel-talk
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
@@ -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.
@@ -533,6 +533,7 @@ module Sequel
533
533
  row[:default] = row.delete(:Default)
534
534
  row[:db_type] = row.delete(:Type)
535
535
  row[:type] = schema_column_type(row[:db_type])
536
+ row[:extra] = extra
536
537
  [m.call(row.delete(:Field)), row]
537
538
  end
538
539
  end
@@ -87,7 +87,7 @@ module Sequel
87
87
 
88
88
  def self.mock_adapter_setup(db)
89
89
  db.instance_exec do
90
- @server_version = 90500
90
+ @server_version = 140000
91
91
  initialize_postgres_adapter
92
92
  extend(MockAdapterDatabaseMethods)
93
93
  end
@@ -2162,6 +2162,38 @@ module Sequel
2162
2162
  opts[:with].any?{|w| w[:recursive]} ? "WITH RECURSIVE " : super
2163
2163
  end
2164
2164
 
2165
+ # Support PostgreSQL 14+ CTE SEARCH/CYCLE clauses
2166
+ def select_with_sql_cte(sql, cte)
2167
+ super
2168
+
2169
+ if search_opts = cte[:search]
2170
+ sql << if search_opts[:type] == :breadth
2171
+ " SEARCH BREADTH FIRST BY "
2172
+ else
2173
+ " SEARCH DEPTH FIRST BY "
2174
+ end
2175
+
2176
+ identifier_list_append(sql, Array(search_opts[:by]))
2177
+ sql << " SET "
2178
+ identifier_append(sql, search_opts[:set] || :ordercol)
2179
+ end
2180
+
2181
+ if cycle_opts = cte[:cycle]
2182
+ sql << " CYCLE "
2183
+ identifier_list_append(sql, Array(cycle_opts[:columns]))
2184
+ sql << " SET "
2185
+ identifier_append(sql, cycle_opts[:cycle_column] || :is_cycle)
2186
+ if cycle_opts.has_key?(:cycle_value)
2187
+ sql << " TO "
2188
+ literal_append(sql, cycle_opts[:cycle_value])
2189
+ sql << " DEFAULT "
2190
+ literal_append(sql, cycle_opts.fetch(:noncycle_value, false))
2191
+ end
2192
+ sql << " USING "
2193
+ identifier_append(sql, cycle_opts[:path_column] || :path)
2194
+ end
2195
+ end
2196
+
2165
2197
  # The version of the database server
2166
2198
  def server_version
2167
2199
  db.server_version(@opts[:server])
@@ -1060,6 +1060,7 @@ module Sequel
1060
1060
 
1061
1061
  # Add a common table expression (CTE) with the given name and a dataset that defines the CTE.
1062
1062
  # A common table expression acts as an inline view for the query.
1063
+ #
1063
1064
  # Options:
1064
1065
  # :args :: Specify the arguments/columns for the CTE, should be an array of symbols.
1065
1066
  # :recursive :: Specify that this is a recursive CTE
@@ -1080,10 +1081,35 @@ module Sequel
1080
1081
 
1081
1082
  # Add a recursive common table expression (CTE) with the given name, a dataset that
1082
1083
  # defines the nonrecursive part of the CTE, and a dataset that defines the recursive part
1083
- # of the CTE. Options:
1084
+ # of the CTE.
1085
+ #
1086
+ # Options:
1084
1087
  # :args :: Specify the arguments/columns for the CTE, should be an array of symbols.
1085
1088
  # :union_all :: Set to false to use UNION instead of UNION ALL combining the nonrecursive and recursive parts.
1086
1089
  #
1090
+ # PostgreSQL 14+ Options:
1091
+ # :cycle :: Stop recursive searching when a cycle is detected. Includes two columns in the
1092
+ # result of the CTE, a cycle column indicating whether a cycle was detected for
1093
+ # the current row, and a path column for the path traversed to get to the current
1094
+ # row. If given, must be a hash with the following keys:
1095
+ # :columns :: (required) The column or array of columns to use to detect a cycle.
1096
+ # If the value of these columns match columns already traversed, then
1097
+ # a cycle is detected, and recursive searching will not traverse beyond
1098
+ # the cycle (the CTE will include the row where the cycle was detected).
1099
+ # :cycle_column :: The name of the cycle column in the output, defaults to :is_cycle.
1100
+ # :cycle_value :: The value of the cycle column in the output if the current row was
1101
+ # detected as a cycle, defaults to true.
1102
+ # :noncycle_value :: The value of the cycle column in the output if the current row
1103
+ # was not detected as a cycle, defaults to false. Only respected
1104
+ # if :cycle_value is given.
1105
+ # :path_column :: The name of the path column in the output, defaults to :path.
1106
+ # :search :: Include an order column in the result of the CTE that allows for breadth or
1107
+ # depth first searching. If given, must be a hash with the following keys:
1108
+ # :by :: (required) The column or array of columns to search by.
1109
+ # :order_column :: The name of the order column in the output, defaults to :ordercol.
1110
+ # :type :: Set to :breadth to use breadth-first searching (depth-first searching
1111
+ # is the default).
1112
+ #
1087
1113
  # DB[:t].with_recursive(:t,
1088
1114
  # DB[:i1].select(:id, :parent_id).where(parent_id: nil),
1089
1115
  # DB[:i1].join(:t, id: :parent_id).select(Sequel[:i1][:id], Sequel[:i1][:parent_id]),
@@ -1094,6 +1120,21 @@ module Sequel
1094
1120
  # # UNION ALL
1095
1121
  # # SELECT i1.id, i1.parent_id FROM i1 INNER JOIN t ON (t.id = i1.parent_id)
1096
1122
  # # ) SELECT * FROM t
1123
+ #
1124
+ # DB[:t].with_recursive(:t,
1125
+ # DB[:i1].where(parent_id: nil),
1126
+ # DB[:i1].join(:t, id: :parent_id).select_all(:i1),
1127
+ # search: {by: :id, type: :breadth},
1128
+ # cycle: {columns: :id, cycle_value: 1, noncycle_value: 2})
1129
+ #
1130
+ # # WITH RECURSIVE t AS (
1131
+ # # SELECT * FROM i1 WHERE (parent_id IS NULL)
1132
+ # # UNION ALL
1133
+ # # (SELECT i1.* FROM i1 INNER JOIN t ON (t.id = i1.parent_id))
1134
+ # # )
1135
+ # # SEARCH BREADTH FIRST BY id SET ordercol
1136
+ # # CYCLE id SET is_cycle TO 1 DEFAULT 2 USING path
1137
+ # # SELECT * FROM t
1097
1138
  def with_recursive(name, nonrecursive, recursive, opts=OPTS)
1098
1139
  raise(Error, 'This dataset does not support common table expressions') unless supports_cte?
1099
1140
  if hoist_cte?(nonrecursive)
@@ -1543,15 +1543,14 @@ module Sequel
1543
1543
 
1544
1544
  def select_with_sql(sql)
1545
1545
  return unless supports_cte?
1546
- ws = opts[:with]
1547
- return if !ws || ws.empty?
1546
+ ctes = opts[:with]
1547
+ return if !ctes || ctes.empty?
1548
1548
  sql << select_with_sql_base
1549
1549
  c = false
1550
1550
  comma = ', '
1551
- ws.each do |w|
1551
+ ctes.each do |cte|
1552
1552
  sql << comma if c
1553
- select_with_sql_prefix(sql, w)
1554
- literal_dataset_append(sql, w[:dataset])
1553
+ select_with_sql_cte(sql, cte)
1555
1554
  c ||= true
1556
1555
  end
1557
1556
  sql << ' '
@@ -1564,6 +1563,11 @@ module Sequel
1564
1563
  "WITH "
1565
1564
  end
1566
1565
 
1566
+ def select_with_sql_cte(sql, cte)
1567
+ select_with_sql_prefix(sql, cte)
1568
+ literal_dataset_append(sql, cte[:dataset])
1569
+ end
1570
+
1567
1571
  def select_with_sql_prefix(sql, w)
1568
1572
  quote_identifier_append(sql, w[:name])
1569
1573
  if args = w[:args]
@@ -1836,7 +1836,9 @@ module Sequel
1836
1836
 
1837
1837
  if opts[:clone]
1838
1838
  cloned_assoc = association_reflection(opts[:clone])
1839
+ remove_class_name = orig_opts[:class] && !orig_opts[:class_name]
1839
1840
  orig_opts = cloned_assoc[:orig_opts].merge(orig_opts)
1841
+ orig_opts.delete(:class_name) if remove_class_name
1840
1842
  end
1841
1843
 
1842
1844
  opts = Hash[default_association_options]
@@ -73,6 +73,7 @@ module Sequel
73
73
  super()
74
74
  end
75
75
  end
76
+ alias_method(a, a)
76
77
  end
77
78
  end
78
79
  end
@@ -143,9 +143,15 @@ module Sequel
143
143
  def load_associated_objects(opts, dynamic_opts=OPTS, &block)
144
144
  dynamic_opts = load_association_objects_options(dynamic_opts, &block)
145
145
  name = opts[:name]
146
- if (!associations.include?(name) || dynamic_opts[:eager_reload]) && opts[:allow_eager] != false && retrieved_by && !frozen? && !dynamic_opts[:callback] && !dynamic_opts[:reload]
146
+ eager_reload = dynamic_opts[:eager_reload]
147
+ if (!associations.include?(name) || eager_reload) && opts[:allow_eager] != false && retrieved_by && !frozen? && !dynamic_opts[:callback] && !dynamic_opts[:reload]
147
148
  begin
148
- retrieved_by.send(:eager_load, retrieved_with.reject(&:frozen?), name=>dynamic_opts[:eager] || OPTS)
149
+ objects = if eager_reload
150
+ retrieved_with.reject(&:frozen?)
151
+ else
152
+ retrieved_with.reject{|x| x.frozen? || x.associations.include?(name)}
153
+ end
154
+ retrieved_by.send(:eager_load, objects, name=>dynamic_opts[:eager] || OPTS)
149
155
  rescue Sequel::UndefinedAssociation
150
156
  # This can happen if class table inheritance is used and the association
151
157
  # is only defined in a subclass. This particular instance can use the
@@ -6,7 +6,7 @@ module Sequel
6
6
 
7
7
  # The minor version of Sequel. Bumped for every non-patch level
8
8
  # release, generally around once a month.
9
- MINOR = 50
9
+ MINOR = 51
10
10
 
11
11
  # The tiny version of Sequel. Usually 0, only bumped for bugfix
12
12
  # releases that fix regressions from previous versions.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.50.0
4
+ version: 5.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-01 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -195,6 +195,7 @@ extra_rdoc_files:
195
195
  - doc/release_notes/5.49.0.txt
196
196
  - doc/release_notes/5.5.0.txt
197
197
  - doc/release_notes/5.50.0.txt
198
+ - doc/release_notes/5.51.0.txt
198
199
  - doc/release_notes/5.6.0.txt
199
200
  - doc/release_notes/5.7.0.txt
200
201
  - doc/release_notes/5.8.0.txt
@@ -273,6 +274,7 @@ files:
273
274
  - doc/release_notes/5.49.0.txt
274
275
  - doc/release_notes/5.5.0.txt
275
276
  - doc/release_notes/5.50.0.txt
277
+ - doc/release_notes/5.51.0.txt
276
278
  - doc/release_notes/5.6.0.txt
277
279
  - doc/release_notes/5.7.0.txt
278
280
  - doc/release_notes/5.8.0.txt
@@ -562,7 +564,7 @@ metadata:
562
564
  bug_tracker_uri: https://github.com/jeremyevans/sequel/issues
563
565
  changelog_uri: http://sequel.jeremyevans.net/rdoc/files/CHANGELOG.html
564
566
  documentation_uri: http://sequel.jeremyevans.net/documentation.html
565
- mailing_list_uri: https://groups.google.com/forum/#!forum/sequel-talk
567
+ mailing_list_uri: https://github.com/jeremyevans/sequel/discussions
566
568
  source_code_uri: https://github.com/jeremyevans/sequel
567
569
  post_install_message:
568
570
  rdoc_options:
@@ -586,7 +588,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
586
588
  - !ruby/object:Gem::Version
587
589
  version: '0'
588
590
  requirements: []
589
- rubygems_version: 3.2.22
591
+ rubygems_version: 3.2.32
590
592
  signing_key:
591
593
  specification_version: 4
592
594
  summary: The Database Toolkit for Ruby