Skip to content

Commit

Permalink
Merge pull request #14229 from lpichler/accept_numbers_in_column_from…
Browse files Browse the repository at this point in the history
…_miq_expression_field

Allow regex for MiqExpression::Field which contains numbers in associations
  • Loading branch information
kbrock authored Mar 10, 2017
2 parents a912f50 + 1908983 commit f340d71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/miq_expression/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class MiqExpression::Field < MiqExpression::Target
REGEX = /
(?<model_name>([[:upper:]][[:alnum:]]*(::)?)+)
(?!.*\b(managed|user_tag)\b)
\.?(?<associations>[a-z_\.]+)?
\.?(?<associations>[a-z][0-9a-z_\.]+)?
-(?<column>[a-z]+(_[[:alnum:]]+)*)
/x

Expand Down
7 changes: 7 additions & 0 deletions spec/lib/miq_expression/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
tag = "Vm.hosts.user_tag-name"
expect(described_class.parse(tag)).to be_nil
end

it 'parses field with numbers in association' do
field = 'Vm.win32_services-dependencies'
expect(described_class.parse(field)).to have_attributes(:model => Vm,
:associations => %w(win32_services),
:column => 'dependencies')
end
end

describe "#parse!" do
Expand Down

0 comments on commit f340d71

Please sign in to comment.