sequel 5.99.0 → 5.100.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e5d22a32d8c5f27e15e00203d0c2ce2a2fb3f5352d7b7c25c82389f4947882c
4
- data.tar.gz: 81909dc070cc8d48def396ae76e953a1f31dc478b45d3a5fa8b69646bc7df094
3
+ metadata.gz: 1e8ed38ad86fbbbd643eb1a2579b799025ff77400d250abe807f41e19a533d9e
4
+ data.tar.gz: 2a4e5b271a96b87d1b2e78f073c4d9a3e91d5147297e555a23c75ac0537b918d
5
5
  SHA512:
6
- metadata.gz: c24ae48ece66511a09b2d8a5ad8b5b82e7486a4446bcb66108140b8afe449cd9c9e7645a29ca0bbe0c994d5c060a52f1ab4c41434dc068175751b1d6bd57b5dc
7
- data.tar.gz: e8acd2e5cb4272bd47aed87e3077018dfc5ba9673856b871c8222eec6b2de1be0843840969e046efc459b52902753e9e0f0e35b95dcdcf31914d98b5f487d78a
6
+ metadata.gz: f1c4b4be8a1b1ce7537799d882e0cde6bd3967a414c8beb60c3ccfff08eb0ed2a84125bca68754510d4c6b80743a49c5c9ca784b1004b3d074e9674760c2e06c
7
+ data.tar.gz: 4e9386540fa22fd976b2ea915d0536225b0d5d231cd3d820e916c7dcc636bcda5a4fabda8604d3848aa183443d0c84d1f951b5ba0bef94cd79cf69526866c014
@@ -657,9 +657,11 @@ module Sequel
657
657
  nil
658
658
  end
659
659
 
660
- # Modify the type of one of the table's column.
660
+ # Modify the type of one of the table's column. The given options are considered when
661
+ # determining the new type.
661
662
  #
662
663
  # set_column_type(:artist_name, 'char(10)') # ALTER COLUMN artist_name TYPE char(10)
664
+ # set_column_type(:artist_name, String, size: 10) # ALTER COLUMN artist_name TYPE varchar(10)
663
665
  #
664
666
  # PostgreSQL specific options:
665
667
  #
@@ -486,7 +486,9 @@ module Sequel
486
486
  end
487
487
 
488
488
  def alter_table_set_column_type_sql(table, op)
489
- "ALTER COLUMN #{quote_identifier(op[:name])} TYPE #{type_literal(op)}"
489
+ sql = "ALTER COLUMN #{quote_identifier(op[:name])} TYPE #{type_literal(op)}".dup
490
+ column_definition_collate_sql(sql, op)
491
+ sql
490
492
  end
491
493
 
492
494
  def alter_table_set_column_default_sql(table, op)
@@ -638,12 +638,11 @@ module Sequel
638
638
  if args.empty?
639
639
  sql << str
640
640
  else
641
- re = /:(#{args.keys.map{|k| Regexp.escape(k.to_s)}.join('|')})\b/
642
- while true
641
+ re = /:(#{Regexp.union(args.keys.map(&:to_s))})\b/
642
+ until str.empty?
643
643
  previous, q, str = str.partition(re)
644
644
  sql << previous
645
- literal_append(sql, args[($1||q[1..-1].to_s).to_sym]) unless q.empty?
646
- break if str.empty?
645
+ literal_append(sql, args[$1.to_sym]) unless q.empty?
647
646
  end
648
647
  end
649
648
  elsif str.is_a?(Array)
@@ -431,6 +431,7 @@ module Sequel
431
431
 
432
432
  "#<#{self.class.name} #{range}#{"::#{@db_type}" if @db_type}>"
433
433
  end
434
+ alias to_s inspect
434
435
 
435
436
  # Append a literalize version of the receiver to the sql.
436
437
  def sql_literal_append(ds, sql)
@@ -0,0 +1,49 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Sequel
4
+ module Plugins
5
+ # The single_statement_dataset_destroy plugin makes the
6
+ # model dataset.destroy method delete all rows in a
7
+ # single DELETE statement. It runs all before_destroy
8
+ # hooks before the DELETE, and all after_destroy hooks
9
+ # after the delete.
10
+ #
11
+ # This is not compatible with around_destroy hooks,
12
+ # so if the model is using custom around_destroy hooks,
13
+ # dataset.destroy falls back to a separate DELETE statement
14
+ # per row.
15
+ #
16
+ # Usage:
17
+ #
18
+ # # Make all model subclasses use a single DELETE
19
+ # # statement for dataset.destroy
20
+ # Sequel::Model.plugin :single_statement_dataset_destroy
21
+ #
22
+ # # Make the Album class use a single DELETE
23
+ # # statement for dataset.destroy
24
+ # Album.plugin :single_statement_dataset_destroy
25
+ module SingleStatementDatasetDestroy
26
+ module DatasetMethods
27
+ # Destroy all rows in a single DELETE statement. Run the before_destroy
28
+ # hooks for all rows before the DELETE, and all after_destroy hooks
29
+ # for all rows after the DELETE. If the model uses an around_destroy
30
+ # hook, fallback to using a separate DELETE statement per row.
31
+ def destroy
32
+ return super unless model.instance_method(:around_destroy).owner == Sequel::Model::InstanceMethods
33
+
34
+ db.transaction do
35
+ rows = all
36
+ rows.each(&:before_destroy)
37
+ expected_rows = rows.length
38
+ n = delete
39
+ unless n == expected_rows
40
+ raise Error, "dataset changed during destroy, expected rows: #{expected_rows}, actual rows: #{n}"
41
+ end
42
+ rows.each(&:after_destroy)
43
+ n
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -198,7 +198,8 @@ module Sequel
198
198
  #
199
199
  # Since this plugin is based on coverage information, if you do
200
200
  # not have tests that cover all usage of associations in your
201
- # application, you can end up with coverage that shows the
201
+ # application, or you are mocking the related association methods
202
+ # and not calling them, you can end up with coverage that shows the
202
203
  # association is not used, when it is used in code that is not
203
204
  # covered. The output of plugin can still be useful in such cases,
204
205
  # as long as you are manually checking it. However, you should
@@ -208,6 +209,8 @@ module Sequel
208
209
  # option for any association that you know is used. If an
209
210
  # association uses the :is_used association option, this plugin
210
211
  # will not modify it if the :modify_associations option is used.
212
+ # It will also not report the association as unused if the :is_used
213
+ # association option is present.
211
214
  #
212
215
  # This plugin does not handle anonymous classes. Any unused
213
216
  # associations defined in anonymous classes will not be
@@ -362,6 +365,9 @@ module Sequel
362
365
  # looks in the class's overridable_methods_module
363
366
  next if ref[:methods_module]
364
367
 
368
+ # Do not report associations if they are explicitly marked as used.
369
+ next if ref[:is_used]
370
+
365
371
  info = {}
366
372
  if reflection_data.include?(assoc.to_s)
367
373
  info[:used] = [:reflection]
@@ -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 = 99
9
+ MINOR = 100
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.99.0
4
+ version: 5.100.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -386,6 +386,7 @@ files:
386
386
  - lib/sequel/plugins/serialization.rb
387
387
  - lib/sequel/plugins/serialization_modification_detection.rb
388
388
  - lib/sequel/plugins/sharding.rb
389
+ - lib/sequel/plugins/single_statement_dataset_destroy.rb
389
390
  - lib/sequel/plugins/single_table_inheritance.rb
390
391
  - lib/sequel/plugins/singular_table_names.rb
391
392
  - lib/sequel/plugins/skip_create_refresh.rb
@@ -451,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
451
452
  - !ruby/object:Gem::Version
452
453
  version: '0'
453
454
  requirements: []
454
- rubygems_version: 3.6.9
455
+ rubygems_version: 4.0.3
455
456
  specification_version: 4
456
457
  summary: The Database Toolkit for Ruby
457
458
  test_files: []