Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced search - user input for booleans broken #5896

Closed
himdel opened this issue Jul 29, 2019 · 5 comments · Fixed by #5906
Closed

Advanced search - user input for booleans broken #5896

himdel opened this issue Jul 29, 2019 · 5 comments · Fixed by #5906
Labels

Comments

@himdel
Copy link
Contributor

himdel commented Jul 29, 2019

  1. Compute > Infra > VMs > VMs accordion
  2. Open Adv search, create filter: choose something where it is possible to choose between true/false values ("user will input the value")
  3. Click on Apply and choose something from the drop down
  4. => there is still 'value' in the drop down :(

(created from #5875 (review), thanks @hstastna)

What I've found so far:

  • changing the option works, the right %option element gets selected
  • bootstrap select is just displaying Chose, even though .val() on the select is right
  • miqSelectPickerEvent's onchange handler doesn't seem to get triggered

Bonus bug:

reloading the screen when chosing that bool triggers a 500 exception until logout+login:

[----] I, [2019-07-29T14:51:49.690686 #14446:2ac9309d7064]  INFO -- : Processing by VmInfraController#report_data as HTML
[----] I, [2019-07-29T14:51:49.690842 #14446:2ac9309d7064]  INFO -- :   Parameters: {"model_name"=>"ManageIQ::Providers::InfraManager::Vm", "model"=>"ManageIQ::Providers::InfraManager::Vm", "active_tree"=>"vms_filter_tree", "explorer"=>true, "additional_options"=>{"named_scope"=>[], "gtl_dbname"=>nil, "model"=>"ManageIQ::Providers::InfraManager::Vm", "match_via_descendants"=>nil, "parent_id"=>nil, "parent_class_name"=>nil, "parent_method"=>nil, "association"=>nil, "view_suffix"=>nil, "row_button"=>nil, "menu_click"=>nil, "sb_controller"=>nil, "embedded"=>nil, "showlinks"=>nil, "policy_sim"=>nil, "in_a_form"=>nil, "lastaction"=>"show_list", "display"=>nil, "gtl_type"=>"grid", "supported_features_filter"=>nil, "clickable"=>nil, "no_checkboxes"=>nil, "report_name"=>nil, "custom_action"=>nil}, "vm"=>{}}
[----] D, [2019-07-29T14:51:49.692819 #14446:2ac9309d7064] DEBUG -- : PostgreSQLAdapter#log_after_checkout, connection_pool: size: 30, connections: 6, in use: 2, waiting_in_queue: 0
...
[----] F, [2019-07-29T14:51:49.769337 #14446:2ac9309d7064] FATAL -- : Error caught: [ActiveRecord::StatementInvalid] PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type boolean: "user_input"
LINE 1: ...template" IS NULL OR "vms"."template" = FALSE)) = 'user_inpu...
                                                             ^
: SELECT COUNT(*) FROM (SELECT DISTINCT "vms".*, (SELECT "ems_clusters"."name" FROM "ems_clusters" WHERE "ems_clusters"."id" = "vms"."ems_cluster_id") AS "ems_cluster_name", (SELECT  "compliances"."compliant" FROM "compliances" WHERE "compliances"."resource_id" = "vms"."id" ORDER BY "compliances"."timestamp" DESC LIMIT 1) AS "last_compliance_status", (SELECT COUNT(*) FROM "snapshots" WHERE "vms"."id" = "snapshots"."vm_or_template_id") AS "v_total_snapshots", (SELECT  (SELECT SUM("disks"."size") FROM "disks" WHERE "hardwares"."id" = "disks"."hardware_id") FROM "hardwares" WHERE "hardwares"."vm_or_template_id" = "vms"."id" LIMIT 1) AS "allocated_disk_storage", (CASE WHEN ("vms"."ems_id" IS NULL AND "vms"."storage_id" IS NULL) THEN 'archived' WHEN ("vms"."ems_id" IS NULL AND "vms"."storage_id" IS NOT NULL) THEN 'orphaned' WHEN "vms"."template" = TRUE THEN 'template' WHEN "vms"."retired" = TRUE THEN 'retired' WHEN ("vms"."connection_state" IS NOT NULL AND "vms"."connection_state" != 'connected') THEN 'disconnected' ELSE LOWER(COALESCE("vms"."power_state", 'unknown')) END) AS "normalized_state" FROM "vms" LEFT OUTER JOIN "hosts" ON "hosts"."id" = "vms"."host_id" LEFT OUTER JOIN "storages" ON "storages"."id" = "vms"."storage_id" LEFT OUTER JOIN "ext_management_systems" ON "ext_management_systems"."id" = "vms"."ems_id" LEFT OUTER JOIN "snapshots" ON "snapshots"."vm_or_template_id" = "vms"."id" LEFT OUTER JOIN "compliances" ON "compliances"."resource_id" = "vms"."id" AND "compliances"."resource_type" = $1 LEFT OUTER JOIN "operating_systems" ON "operating_systems"."vm_or_template_id" = "vms"."id" LEFT OUTER JOIN "hardwares" ON "hardwares"."vm_or_template_id" = "vms"."id" LEFT OUTER JOIN "taggings" ON "taggings"."taggable_id" = "vms"."id" AND "taggings"."taggable_type" = $2 LEFT OUTER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" WHERE "vms"."type" IN ('ManageIQ::Providers::InfraManager::Vm', 'ManageIQ::Providers::Vmware::InfraManager::Vm', 'ManageIQ::Providers::Kubevirt::InfraManager::Vm', 'ManageIQ::Providers::Redhat::InfraManager::Vm', 'ManageIQ::Providers::Microsoft::InfraManager::Vm', 'VmXen') AND "vms"."template" = $3 AND (("vms"."ems_id" IS NOT NULL AND ("vms"."retired" IS NULL OR "vms"."retired" = FALSE) AND ("vms"."template" IS NULL OR "vms"."template" = FALSE)) = 'user_input')) subquery_for_count
...
/home/himdel/manageiq/lib/rbac/filterer.rb:286:in `search'
/home/himdel/manageiq/lib/rbac/filterer.rb:146:in `search'
/home/himdel/manageiq/lib/rbac.rb:3:in `search'
/home/himdel/manageiq/app/models/miq_report/search.rb:117:in `paged_view_search'
/home/himdel/manageiq-ui-classic/app/controllers/application_controller.rb:1325:in `get_view'
/home/himdel/manageiq-ui-classic/app/controllers/application_controller.rb:422:in `report_data'
...
@martinpovolny
Copy link
Member

We need to fix this one, create a BZ and backport to Ivanchuk.

@martinpovolny
Copy link
Member

ping @h-kataria

@himdel
Copy link
Contributor Author

himdel commented Jul 30, 2019

Not sure about the bonus bug (except that it happens when we don't chose any value in the user input select and just reload the screen),

but: the issue of not being able to chose anything in the select is caused by this piece of code (in _user_input_filter.html.haml):

    $('#quicksearchbox').on('shown.bs.modal', function () {
      if (miqDomElementExists('value_1')) $('#value_1').focus();
    })

(I think bootstrap-select can't handle when the hidden select element gets focused.)

=> #5906

@h-kataria
Copy link
Contributor

@himdel
Copy link
Contributor Author

himdel commented Jul 30, 2019

👍 thanks, adding the second one to the PR.
(The first one was closed as a dup of #5875 fixing the apply button.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants