Project

General

Profile

Bug #11282

search on numeric facts is broken if using "~".

Added by Amir Fefer over 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Facts
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When trying to search a numeric value fact and using operator '~' there a 500 error:
"PG::UndefinedFunction: ERROR: operator does not exist: numeric ~~* integer
LINE 1: ... E'^\\d+$' AND CAST ILIKE 0)) ...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts."

recreate:
search- facts.uptime_days ~ 0


Related issues

Related to Foreman - Feature #11150: Allow searching of facts as types other than stringClosed2015-07-19

Associated revisions

Revision 8658fa37 (diff)
Added by Imri Zvik over 4 years ago

Fixes #11282 - Search on numeric facts is broken if using "~"

History

#1 Updated by Dominic Cleal over 4 years ago

  • Related to Feature #11150: Allow searching of facts as types other than string added

#2 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 63

#3 Updated by Imri Zvik over 4 years ago

Excluding the LIKE operator for PG in cast_facts solved this issue.
i.e.
instead of:
elsif (is_int && is_pg)

do:
elsif (is_int && is_pg && operator !~ /LIKE/i)

Dominic, if it sounds like an acceptable solution to you, I will open a PR.

#4 Updated by Ohad Levy over 4 years ago

Imri Zvik wrote:

Excluding the LIKE operator for PG in cast_facts solved this issue.
i.e.
instead of:
elsif (is_int && is_pg)

do:
elsif (is_int && is_pg && operator !~ /LIKE/i)

Dominic, if it sounds like an acceptable solution to you, I will open a PR.

I would suggest to open a PR and make sure you add the case mention here (and maybe others?) as a test?

thanks!

#5 Updated by Imri Zvik over 4 years ago

Ohad Levy wrote:

Imri Zvik wrote:

Excluding the LIKE operator for PG in cast_facts solved this issue.
i.e.
instead of:
elsif (is_int && is_pg)

do:
elsif (is_int && is_pg && operator !~ /LIKE/i)

Dominic, if it sounds like an acceptable solution to you, I will open a PR.

I would suggest to open a PR and make sure you add the case mention here (and maybe others?) as a test?

thanks!

Already did in my fork ;)
I will open a PR tomorrow.

#6 Updated by The Foreman Bot over 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2622 added
  • Pull request deleted ()

#7 Updated by Dominic Cleal over 4 years ago

  • Status changed from Ready For Testing to New
  • Pull request added
  • Pull request deleted (https://github.com/theforeman/foreman/pull/2622)

#8 Updated by The Foreman Bot over 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2626 added
  • Pull request deleted ()

#9 Updated by Imri Zvik over 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#10 Updated by Dominic Cleal over 4 years ago

  • Assignee set to Imri Zvik

Also available in: Atom PDF