Class: PGExaminer::Result::Table

Inherits:
Item
  • Object
show all
Defined in:
lib/pg_examiner/result/table.rb

Instance Attribute Summary

Attributes inherited from Item

#parent, #result, #row

Instance Method Summary collapse

Methods inherited from Item

#initialize, #inspect, #name, #oid

Methods inherited from Base

#==, #diff, #diffable_methods

Constructor Details

This class inherits a constructor from PGExaminer::Result::Item

Instance Method Details

#columnsObject



23
24
25
26
27
# File 'lib/pg_examiner/result/table.rb', line 23

def columns
  @columns ||= result.pg_attribute.select do |c|
    c['attrelid'] == oid
  end.sort_by{|c| c['name']}.map { |row| Column.new(result, row, self) }
end

#constraintsObject



35
36
37
38
39
# File 'lib/pg_examiner/result/table.rb', line 35

def constraints
  @constraints ||= result.pg_constraint.select do |c|
    c['conrelid'] == oid
  end.map{|row| Constraint.new(result, row, self)}.sort_by(&:name)
end

#diffable_attrsObject



15
16
17
18
19
20
21
# File 'lib/pg_examiner/result/table.rb', line 15

def diffable_attrs
  {
    "name"           => "name",
    "relpersistence" => "table type (relpersistence)",
    "reloptions"     => "table options",
  }
end

#diffable_listsObject



6
7
8
9
10
11
12
13
# File 'lib/pg_examiner/result/table.rb', line 6

def diffable_lists
  {
    "columns"     => "columns",
    "indexes"     => "indexes",
    "constraints" => "constraints",
    "triggers"    => "triggers",
  }
end

#indexesObject



29
30
31
32
33
# File 'lib/pg_examiner/result/table.rb', line 29

def indexes
  @indexes ||= result.pg_index.select do |c|
    c['indrelid'] == oid
  end.map{|row| Index.new(result, row, self)}.sort_by(&:name)
end

#triggersObject



41
42
43
44
45
# File 'lib/pg_examiner/result/table.rb', line 41

def triggers
  @triggers ||= result.pg_trigger.select do |t|
    t['tgrelid'] == oid
  end.map{|row| Trigger.new(result, row, self)}.sort_by(&:name)
end