This file is indexed.

/usr/lib/ruby/vendor_ruby/sequel/plugins/update_primary_key.rb is in ruby-sequel 4.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module Sequel
  module Plugins
    # The update_primary_key plugin allows you to modify an object's
    # primary key and then save the record.  Sequel does not work
    # correctly with primary key modifications by default.  Sequel
    # is designed to work with surrogate primary keys that never need to be
    # modified, but this plugin makes it work correctly with natural
    # primary keys that may need to be modified. Example:
    #
    #   album = Album[1]
    #   album.id = 2
    #   album.save
    # 
    # Usage:
    #
    #   # Make all model subclasses support primary key updates
    #   # (called before loading subclasses)
    #   Sequel::Model.plugin :update_primary_key
    #
    #   # Make the Album class support primary key updates
    #   Album.plugin :update_primary_key
    module UpdatePrimaryKey
      module InstanceMethods
        # Clear the cached primary key.
        def after_update
          super
          @pk_hash = nil
        end

        # Use the cached primary key if one is present.
        def pk_hash
          @pk_hash || super
        end

        private

        # If the primary key column changes, clear related associations and cache
        # the previous primary key values.
        def change_column_value(column, value)
          pk = primary_key
          if (pk.is_a?(Array) ? pk.include?(column) : pk == column)
            @pk_hash ||= pk_hash unless new?
            clear_associations_using_primary_key
          end
          super
        end

        # Clear associations that are likely to be tied to the primary key.
        # Note that this currently can clear additional options that don't reference
        # the primary key (such as one_to_many columns referencing a column other than the
        # primary key).
        def clear_associations_using_primary_key
          associations.keys.each do |k|
            associations.delete(k) if model.association_reflection(k)[:type] != :many_to_one
          end
        end

        # Do not use prepared statements for update queries, since they don't work
        # in the case where the primary key has changed.
        def use_prepared_statements_for?(type)
          if type == :update
            false
          else
            super
          end
        end
      end
    end
  end
end