Module: Supabase::Postgrest::Utils

Defined in:
lib/supabase/postgrest/utils.rb

Constant Summary collapse

RESERVED_CHARS =
",:()"

Class Method Summary collapse

Class Method Details

.sanitize_param(param) ⇒ Object

Quote values that contain PostgREST reserved characters so they aren’t interpreted as operator separators. Mirrors supabase-py’s sanitize_param.



12
13
14
15
16
17
# File 'lib/supabase/postgrest/utils.rb', line 12

def sanitize_param(param)
  s = param.to_s
  return %("#{s}") if s.chars.any? { |c| RESERVED_CHARS.include?(c) }

  s
end

.sanitize_pattern_param(pattern) ⇒ Object



19
20
21
# File 'lib/supabase/postgrest/utils.rb', line 19

def sanitize_pattern_param(pattern)
  sanitize_param(pattern.to_s.gsub("%", "*"))
end