Skip to content

Commit

Permalink
groonga-database-inspector: show column value type
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed May 31, 2015
1 parent 4f345b3 commit ed077c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/groonga/database-inspector.rb
Expand Up @@ -158,6 +158,9 @@ def report_column(column)
indent do
write("ID: #{column.id}\n")
write("Type: #{inspect_column_type(column)}\n")
unless column.index?
write("Value type: #{inspect_value_type(column.range)}\n")
end
write("Path: #{inspect_path(column.path)}\n")
write("Disk usage: #{inspect_sub_disk_usage(column.disk_usage)}\n")
end
Expand Down Expand Up @@ -265,6 +268,14 @@ def inspect_key_type(table)
end
end

def inspect_value_type(range)
if range.nil?
"(no value)"
else
range.name
end
end

def inspect_tokenizer(table)
if table.support_key?
tokenizer = table.default_tokenizer
Expand Down
16 changes: 15 additions & 1 deletion test/test-database-inspector.rb
Expand Up @@ -144,6 +144,7 @@ def inspect_column(column)
#{column.local_name}:
ID: #{column.id}
Type: #{inspect_column_type(column)}
Value type: #{inspect_value_type(column.range)}
Path: <#{column.path}>
Disk usage: #{inspect_sub_disk_usage(column.disk_usage)}
INSPECTED
Expand All @@ -164,6 +165,14 @@ def inspect_column_type(column)
end
end

def inspect_value_type(range)
if range.nil?
"(no value)"
else
range.name
end
end

class DatabaseTest < self
def test_empty
assert_equal(<<-INSPECTED, report)
Expand Down Expand Up @@ -713,10 +722,15 @@ def create_table
end

def inspected(type)
if type != "index"
value_type = "\n Value type: #{@column.range.name}"
else
value_type = ""
end
<<-INSPECTED
#{@column.local_name}:
ID: #{@column.id}
Type: #{type}
Type: #{type}#{value_type}
Path: <#{@column.path}>
Disk usage: #{inspect_sub_disk_usage(@column.disk_usage)}
INSPECTED
Expand Down

0 comments on commit ed077c5

Please sign in to comment.