Module: ViewData::PG::Controls::Row::Get::CompositePrimaryKey

Defined in:
lib/view_data/pg/controls/row/get.rb

Class Method Summary collapse

Class Method Details

.call(ids) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/view_data/pg/controls/row/get.rb', line 21

def self.call(ids)
  id_1, id_2 = ids

  table = Table::CompositePrimaryKey.name

  session = Session.build

  result = session.execute(<<~SQL, [id_1, id_2])
    SELECT * FROM #{table} WHERE id_1 = $1 AND id_2 = $2 LIMIT 1
  SQL

  session.close

  result.to_a[0]
end