Class: Supabase::Postgrest::SelectRequestBuilder

Inherits:
FilterRequestBuilder show all
Includes:
SelectMixin
Defined in:
lib/supabase/postgrest/request_builder.rb

Overview

Returned by select() — filters + select modifiers + result-shape switchers.

Instance Attribute Summary

Attributes inherited from QueryRequestBuilder

#request

Instance Method Summary collapse

Methods included from SelectMixin

#limit, #offset, #order, #range

Methods included from FilterMixin

#adj, #cd, #contained_by, #contains, #cs, #eq, #filter, #fts, #gt, #gte, #ilike, #ilike_all_of, #ilike_any_of, #in_, #is_, #like, #like_all_of, #like_any_of, #lt, #lte, #match, #max_affected, #neq, #not_, #nxl, #nxr, #or_, #ov, #overlaps, #phfts, #plfts, #range_adjacent, #range_gt, #range_gte, #range_lt, #range_lte, #sl, #sr, #wfts

Methods inherited from QueryRequestBuilder

#execute, #initialize, #retry, #select

Constructor Details

This class inherits a constructor from Supabase::Postgrest::QueryRequestBuilder

Instance Method Details

#csvObject



523
524
525
526
# File 'lib/supabase/postgrest/request_builder.rb', line 523

def csv
  @request.headers["Accept"] = "text/csv"
  SingleRequestBuilder.new(@request)
end

#explain(analyze: false, verbose: false, settings: false, buffers: false, wal: false, format: "text") ⇒ Object



541
542
543
544
545
546
547
548
549
550
# File 'lib/supabase/postgrest/request_builder.rb', line 541

def explain(analyze: false, verbose: false, settings: false, buffers: false, wal: false, format: "text")
  options = []
  options << "analyze" if analyze
  options << "verbose" if verbose
  options << "settings" if settings
  options << "buffers" if buffers
  options << "wal" if wal
  @request.headers["Accept"] = "application/vnd.pgrst.plan+#{format}; options=#{options.join('|')}"
  format == "text" ? ExplainRequestBuilder.new(@request) : SingleRequestBuilder.new(@request)
end

#maybe_singleObject



519
520
521
# File 'lib/supabase/postgrest/request_builder.rb', line 519

def maybe_single
  MaybeSingleRequestBuilder.new(@request)
end

#singleObject



514
515
516
517
# File 'lib/supabase/postgrest/request_builder.rb', line 514

def single
  @request.headers["Accept"] = "application/vnd.pgrst.object+json"
  SingleRequestBuilder.new(@request)
end

#text_search(column, query, options = {}) ⇒ Object



528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/supabase/postgrest/request_builder.rb', line 528

def text_search(column, query, options = {})
  type_part = case options[:type] || options["type"]
              when "plain" then "pl"
              when "phrase" then "ph"
              when "web_search" then "w"
              else ""
              end
  config = options[:config] || options["config"]
  config_part = config ? "(#{config})" : ""
  @request.params[column.to_s] = "#{type_part}fts#{config_part}.#{query}"
  QueryRequestBuilder.new(@request)
end