Exception: WiseGopher::UndeclaredColumns

Inherits:
Error
  • Object
show all
Defined in:
lib/wise_gopher/errors.rb

Overview

raised when result contains more columns than declared

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_names) ⇒ UndeclaredColumns

Returns a new instance of UndeclaredColumns.



32
33
34
35
36
# File 'lib/wise_gopher/errors.rb', line 32

def initialize(column_names)
  @column_names = column_names.map do |name|
    "- \"#{name}\""
  end.join("\n")
end

Instance Attribute Details

#column_namesObject (readonly)

Returns the value of attribute column_names.



30
31
32
# File 'lib/wise_gopher/errors.rb', line 30

def column_names
  @column_names
end

Instance Method Details

#messageObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/wise_gopher/errors.rb', line 38

def message
  <<~STR
    \n
    The following columns where found in result but were not declared:
    #{column_names}

    If you need them during query execution but not in result,
    you should ignore them, like this:

    class Query < WiseGopher::Base
      query "SELECT title, rating FROM articles"

      row do
        column :title, :string
        ignore :rating
      end
    end
  STR
end