File: columns_limit_1.rb

package info (click to toggle)
ruby-sequel 5.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,408 kB
  • sloc: ruby: 113,747; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen-string-literal: true

module Sequel
  class Dataset
    module ColumnsLimit1
      COLUMNS_CLONE_OPTIONS = {:distinct => nil, :limit => 1, :offset=>nil, :where=>nil, :having=>nil, :order=>nil, :row_proc=>nil, :graph=>nil, :eager_graph=>nil}.freeze

      # Use a limit of 1 instead of a limit of 0 when
      # getting the columns.
      def columns!
        ds = clone(COLUMNS_CLONE_OPTIONS)
        ds.each{break}

        if cols = ds.cache[:_columns]
          self.columns = cols
        else
          []
        end
      end
    end
  end
end