Module: ROM::SQL::SequelAPI

Defined in:
lib/rom/sql/relation/sequel_api.rb

Overview

Query API for SQL::Relation

Instance Method Summary collapse

Instance Method Details

#having(*args, &block) ⇒ Relation

Restrict a relation to match grouping criteria

Examples:

users.with_task_count.having( task_count: 2 )

users.with_task_count.having { task_count > 3 }

Parameters:

  • *args (Hash)

    An optional hash with conditions for HAVING clause

Returns:

See Also:



70
71
72
# File 'lib/rom/sql/relation/sequel_api.rb', line 70

def having(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end

#inner_join(*args, &block) ⇒ Relation

Join with another relation using INNER JOIN

Examples:

users.inner_join(:tasks, id: :user_id)

Parameters:

  • relation (Symbol)

    name

  • join (Hash)

    keys

Returns:



99
100
101
# File 'lib/rom/sql/relation/sequel_api.rb', line 99

def inner_join(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end

#left_join(*args, &block) ⇒ Relation

Join other relation using LEFT OUTER JOIN

Examples:

users.left_join(:tasks, id: :user_id)

Parameters:

  • relation (Symbol)

    name

  • join (Hash)

    keys

Returns:



114
115
116
# File 'lib/rom/sql/relation/sequel_api.rb', line 114

def left_join(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end

#order(*args, &block) ⇒ Relation

Set order for the relation

Examples:

users.order(:name)

Parameters:

  • *args (Array<Symbol>)

    A list with column names

Returns:



84
85
86
# File 'lib/rom/sql/relation/sequel_api.rb', line 84

def order(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end

#select(*args, &block) ⇒ Relation

Select specific columns for select clause

Examples:

users.select(:id, :name).first
# {:id => 1, :name => "Jane" }

Returns:



16
17
18
# File 'lib/rom/sql/relation/sequel_api.rb', line 16

def select(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end

#select_append(*args, &block) ⇒ Relation

Append specific columns to select clause

Examples:

users.select(:id, :name).select_append(:email)
# {:id => 1, :name => "Jane", :email => "[email protected]"}

Parameters:

  • *args (Array<Symbol>)

    A list with column names

Returns:



31
32
33
# File 'lib/rom/sql/relation/sequel_api.rb', line 31

def select_append(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end

#where(*args, &block) ⇒ Relation

Restrict a relation to match criteria

If block is passed it’ll be executed in the context of a condition builder object.

Examples:

users.where(name: 'Jane')

users.where { age >= 18 }

Parameters:

  • *args (Hash)

    An optional hash with conditions for WHERE clause

Returns:

See Also:



52
53
54
# File 'lib/rom/sql/relation/sequel_api.rb', line 52

def where(*args, &block)
  new(dataset.__send__(__method__, *args, &block))
end