lib/shiba/index_stats.rb in shiba-0.9.3 vs lib/shiba/index_stats.rb in shiba-0.9.4

- old
+ new

@@ -11,10 +11,19 @@ def any? @tables.any? end + # case insenstive table match + def find_table(name) + table = @tables[name] + return table if table + + _, table = @tables.detect { |k,_| k.casecmp(name).zero? } + return table + end + Table = Struct.new(:name, :count, :indexes) do def encode_with(coder) if self.count.nil? #uuuugly. No unique keys. we'll take our best guess. self.count = indexes.map { |i, parts| parts.columns.map { |v| v.raw_cardinality } }.flatten.max @@ -136,15 +145,15 @@ end attr_reader :tables def table_count(table) - return @tables[table].count if @tables[table] + return find_table(table).count if find_table(table) end def fetch_index(table, name) - tbl = @tables[table] + tbl = find_table(table) return nil unless tbl tbl.indexes[name] end @@ -156,10 +165,10 @@ table = build_table(table) table.add_index_column(index_name, column_name, nil, cardinality, is_unique) end def get_column_size(table_name, column) - table = @tables[table_name] + table = find_table(table_name) return nil unless table table.column_sizes[column] end