This file is indexed.

/usr/lib/ruby/vendor_ruby/sequel/extensions/current_datetime_timestamp.rb is in ruby-sequel 4.15.0-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
# The current_datetime_timestamp extension makes Dataset#current_datetime
# return an object that operates like Sequel.datetime_class.now, but will
# be literalized as CURRENT_TIMESTAMP.
#
# This allows you to use the defaults_setter, timestamps, and touch
# model plugins and make sure that CURRENT_TIMESTAMP is used instead of
# a literalized timestamp value.
#
# The reason that CURRENT_TIMESTAMP is better than a literalized version
# of the timestamp is that it obeys correct transactional semantics
# (all calls to CURRENT_TIMESTAMP in the same transaction return the
# same timestamp, at least on some databases).
#
# To have current_datetime be literalized as CURRENT_TIMESTAMP for
# a single dataset:
#
#   ds = ds.extension(:current_datetime_timestamp)
#
# To have current_datetime be literalized as CURRENT_TIMESTAMP for all
# datasets of a given database.
#
#   DB.extension(:current_datetime_timestamp)

#
module Sequel
  module CurrentDateTimeTimestamp
    module DatasetMethods
      # Return an instance of Sequel.datetime_class that will be literalized
      # as CURRENT_TIMESTAMP.
      def current_datetime
        MAP.fetch(Sequel.datetime_class).now
      end

      private

      # Literalize custom DateTime subclass objects as CURRENT_TIMESTAMP.
      def literal_datetime_append(sql, v)
        v.is_a?(DateTime) ? literal_append(sql, Sequel::CURRENT_TIMESTAMP) : super
      end

      # Literalize custom Time subclass objects as CURRENT_TIMESTAMP.
      def literal_time_append(sql, v)
        v.is_a?(Time) ? literal_append(sql, Sequel::CURRENT_TIMESTAMP) : super
      end
    end

    # Time subclass literalized as CURRENT_TIMESTAMP
    class Time < ::Time; end

    # DateTime subclass literalized as CURRENT_TIMESTAMP
    class DateTime < ::DateTime; end

    # Mapping of Time/DateTime classes to subclasses literalized as CURRENT_TIMESTAMP
    MAP = {::Time=>Time, ::DateTime=>DateTime}
  end

  Dataset.register_extension(:current_datetime_timestamp, CurrentDateTimeTimestamp::DatasetMethods)
end