File: columns_limit_1.rb

package info (click to toggle)
ruby-sequel 5.97.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,188 kB
  • sloc: ruby: 123,115; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (3)
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