Bug #5566

Fact Values Query Produces Error

Added by Paul Calabro over 3 years ago. Updated over 3 years ago.

Status:Closed
Priority:Normal
Assigned To:Joseph Magen
Category:Search
Target version:Sprint 25
Difficulty: Bugzilla link:1093151
Found in release:1.5.0 Pull request:
Story points-
Velocity based estimate-
Release1.5.2Release relationshipAuto

Description

When issuing the following query: fact = network_address <any string goes here>

I receive the following trace:

ActiveRecord::StatementInvalid
PGError: ERROR: syntax error at or near "OR" LINE 1: ...ub01%' OR "fact_names"."name" ILIKE '%dub01%' OR OR "hostgr... ^ : SELECT DISTINCT "fact_values".id, "fact_values"."value" AS alias_0 FROM "fact_values" LEFT OUTER JOIN "fact_names" ON "fact_names"."id" = "fact_values"."fact_name_id" LEFT OUTER JOIN "hosts" ON "hosts"."id" = "fact_values"."host_id" AND "hosts"."type" IN ('Host::Managed') LEFT OUTER JOIN "hostgroups" ON "hostgroups"."id" = "hosts"."hostgroup_id" LEFT OUTER JOIN "hosts" "hosts_fact_values" ON "hosts_fact_values"."id" = "fact_values"."host_id" AND "hosts_fact_values"."type" IN ('Host::Managed') INNER JOIN "fact_names" fact_names_364687 ON (fact_names_364687.id = fact_values.fact_name_id) WHERE (fact_names.name <> '_timestamp') AND ((fact_names_364687."name" = '') AND (("fact_names"."name" = 'network_address') AND ("fact_values"."value" ILIKE '%dub01%' OR "fact_values"."value" ILIKE '%dub01%' OR "fact_names"."name" ILIKE '%dub01%' OR OR "hostgroups"."name" ILIKE '%dub01%' OR "fact_names"."short_name" ILIKE '%dub01%'))) ORDER BY "fact_values"."value" ASC NULLS FIRST LIMIT 150 OFFSET 0
app/views/fact_values/index.html.erb:15:in `_app_views_fact_values_index_html_erb___1537369141514873972_74205940'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'

If I change the query to: fact = network_address and host = <FQDN goes here>

it works fine.


Related issues

Duplicated by Foreman - Bug #5906: Can't search facts give error / facts search for a partic... Duplicate 05/23/2014
Duplicated by Foreman - Bug #5670: Invalid sql when searching for two words Duplicate 05/12/2014

Associated revisions

Revision b7ae6836
Added by Joseph Magen over 3 years ago

fixes #5566 - free text fact values query produces invalid SQL error

History

#1 Updated by Dominic Cleal over 3 years ago

  • Category set to Search

#2 Updated by Dominic Cleal over 3 years ago

  • Bugzilla link set to https://bugzilla.redhat.com/show_bug.cgi?id=1093151

#3 Updated by Dominic Cleal over 3 years ago

  • Duplicated by Bug #5906: Can't search facts give error / facts search for a particular word does not work added

#4 Updated by Joseph Magen over 3 years ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Joseph Magen
  • Target version set to Sprint 24

#5 Updated by Paul Calabro over 3 years ago

This fixed my issue! Thanks guys! :)

#6 Updated by Dmitri Dolguikh over 3 years ago

  • Target version changed from Sprint 24 to Sprint 25

#7 Updated by Dominic Cleal over 3 years ago

  • Duplicated by Bug #5670: Invalid sql when searching for two words added

#8 Updated by Dominic Cleal over 3 years ago

  • Release set to 1.5.2

#9 Updated by Joseph Magen over 3 years ago

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

Also available in: Atom PDF