class PGExaminer::Result::Column

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/pg_examiner/result/column.rb, line 6
def initialize(*args)
  super
  @default_calculated = false
end

Public Instance Methods

default() click to toggle source
# File lib/pg_examiner/result/column.rb, line 31
def default
  # Have to dance a bit so that the lack of a default becomes nil, but isn't recalculated each time.
  if @default_calculated
    @default
  else
    @default_calculated = true
    @default = result.pg_attrdef.find{|d| d['adrelid'] == row['attrelid'] && d['adnum'] == row['attnum']}['default'] if row['atthasdef'] == 't'
  end
end
diffable_attrs() click to toggle source
# File lib/pg_examiner/result/column.rb, line 18
def diffable_attrs
  {
    'name'       => "name",
    'attndims'   => "array dimensionality",
    'attnotnull' => "column is marked not-null",
    'atttypmod'  => "datatype information (atttypmod)",
  }
end
diffable_methods() click to toggle source
# File lib/pg_examiner/result/column.rb, line 11
def diffable_methods
  {
    "type"    => "type",
    "default" => "default"
  }
end
type() click to toggle source
# File lib/pg_examiner/result/column.rb, line 27
def type
  @type ||= result.pg_type.find{|t| t['oid'] == row['atttypid']}['name']
end