Skip to content

Commit

Permalink
fix: remove eval from lib/gzr/commands/plan/ls.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
drstrangelooker committed Nov 7, 2023
1 parent 70e80d6 commit 84e74f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/gzr/commands/plan/ls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ def execute(input: $stdin, output: $stdout)
}
data = run_inline_query(query)
fields = query[:fields]
expressions = fields.collect { |f| "[:'#{f}']" }
else
data = query_all_scheduled_plans("all",@options[:fields])
fields = field_names(@options[:fields])
expressions = fields.collect { |fn| field_expression_hash(fn) }
end
begin
say_ok "No plans found"
Expand All @@ -78,8 +76,12 @@ def execute(input: $stdin, output: $stdout)
table_hash = Hash.new
table_hash[:header] = fields unless @options[:plain]
table_hash[:rows] = data.map do |row|
expressions.collect do |e|
eval "row#{e}"
if @options[:disabled] then
fields.collect do |f|
row.fetch(f.to_sym, nil)
end
else
field_expressions_eval(fields,row)
end
end
table = TTY::Table.new(table_hash)
Expand Down

0 comments on commit 84e74f4

Please sign in to comment.