lib/pghero/methods/suggested_indexes.rb in pghero-3.1.0 vs lib/pghero/methods/suggested_indexes.rb in pghero-3.2.0

- old
+ new

@@ -284,23 +284,27 @@ if tree.bool_expr.boolop == :AND_EXPR tree.bool_expr.args.flat_map { |v| parse_where(v) } else raise "Not Implemented" end - elsif aexpr && ["=", "<>", ">", ">=", "<", "<=", "~~", "~~*", "BETWEEN"].include?(aexpr.name.first.string.str) - [{column: aexpr.lexpr.column_ref.fields.last.string.str, op: aexpr.name.first.string.str}] + elsif aexpr && ["=", "<>", ">", ">=", "<", "<=", "~~", "~~*", "BETWEEN"].include?(aexpr.name.first.string.send(str_method)) + [{column: aexpr.lexpr.column_ref.fields.last.string.send(str_method), op: aexpr.name.first.string.send(str_method)}] elsif tree.null_test op = tree.null_test.nulltesttype == :IS_NOT_NULL ? "not_null" : "null" - [{column: tree.null_test.arg.column_ref.fields.last.string.str, op: op}] + [{column: tree.null_test.arg.column_ref.fields.last.string.send(str_method), op: op}] else raise "Not Implemented" end end + def str_method + @str_method ||= Gem::Version.new(PgQuery::VERSION) >= Gem::Version.new("4") ? :sval : :str + end + def parse_sort(sort_clause) sort_clause.map do |v| { - column: v.sort_by.node.column_ref.fields.last.string.str, + column: v.sort_by.node.column_ref.fields.last.string.send(str_method), direction: v.sort_by.sortby_dir == :SORTBY_DESC ? "desc" : "asc" } end end