Class: ActiveRecord::ConnectionAdapters::Cubrid2::ExplainPrettyPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/cubrid2/explain_pretty_printer.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#pp(result, elapsed) ⇒ Object

Pretty prints the result of an query that resembles Cubrid shell:

Field                 Type                  Null                  Key                   Default               Extra
'host_year'           'INTEGER'             'NO'                  'PRI'                 NULL                  ''
'event_code'          'INTEGER'             'NO'                  'MUL'                 NULL                  ''
'athlete_code'        'INTEGER'             'NO'                  'MUL'                 NULL                  ''
'stadium_code'        'INTEGER'             'NO'                  ''                    NULL                  ''
'nation_code'         'CHAR(3)'             'YES'                 ''                    NULL                  ''
'medal'               'CHAR(1)'             'YES'                 ''                    NULL                  ''
'game_date'           'DATE'                'YES'                 ''                    NULL                  ''

7 rows selected. (0.010673 sec)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_record/connection_adapters/cubrid2/explain_pretty_printer.rb', line 21

def pp(result, elapsed)
  widths    = compute_column_widths(result) + 4
  separator = build_separator(widths)

  pp = []

  pp << build_cells(result.columns, widths)
  pp << separator

  result.rows.each do |row|
    pp << build_cells(row, widths)
  end

  pp << build_footer(result.rows.length, elapsed)

  pp.join("\n") + "\n"
end