Skip to content
Alex edited this page Jul 29, 2018 · 3 revisions

Possible structures:

  • String, Symbol just insert it in "ORDER BY #{structure} "
  • SQL operator
  • Hash
    • key - previsious possible structures.
    • value - options representation
      • Symbol - :last || :first || :asc || :desc
      • String - '<' || '>' or smthng else that passed in to USING
      • Array - with symbols inside
  • Array - any possible structures
order: 'z.amount DESC' || :name
# => 'ORDER BY z.amount DESC ' || 'ORDER BY name '
order: [:name, [:_case ...], { amount: [:first, :desc] }]
# => 'ORDER BY name, CASE ..., amount DESC NULLS FIRST '
Clone this wiki locally