Bug #17121
closedColumn ancestry ambiguous when showing facts
Description
When clicking on the "expand" (+) button when listing the facts for a host, an invalid sql is generated:
ActiveRecord::StatementInvalid: Mysql2::Error: Column 'ancestry' in where clause is ambiguous: SELECT `fact_values`.`id` AS t0_r0, `fact_values`.`value` AS t0_r1, `fact_values`.`fact_name_id` AS t0_r2, `fact_values`.`host_id` AS t0_r3, `fact_values`.`updated_at` AS t0_r4, `fact_values`.`created_at` AS t0_r5, `fact_names`.`id` AS t1_r0, `fact_names`.`name` AS t1_r1, `fact_names`.`updated_at` AS t1_r2, `fact_names`.`created_at` AS t1_r3, `fact_names`.`compose` AS t1_r4, `fact_names`.`short_name` AS t1_r5, `fact_names`.`type` AS t1_r6, `fact_names`.`ancestry` AS t1_r7, `hosts`.`id` AS t2_r0, `hosts`.`name` AS t2_r1, `hosts`.`last_compile` AS t2_r2, `hosts`.`last_report` AS t2_r3, `hosts`.`updated_at` AS t2_r4, `hosts`.`created_at` AS t2_r5, `hosts`.`root_pass` AS t2_r6, `hosts`.`architecture_id` AS t2_r7, `hosts`.`operatingsystem_id` AS t2_r8, `hosts`.`environment_id` AS t2_r9, `hosts`.`ptable_id` AS t2_r10, `hosts`.`medium_id` AS t2_r11, `hosts`.`build` AS t2_r12, `hosts`.`comment` AS t2_r13, `hosts`.`disk` AS t2_r14, `hosts`.`installed_at` AS t2_r15, `hosts`.`model_id` AS t2_r16, `hosts`.`hostgroup_id` AS t2_r17, `hosts`.`owner_id` AS t2_r18, `hosts`.`owner_type` AS t2_r19, `hosts`.`enabled` AS t2_r20, `hosts`.`puppet_ca_proxy_id` AS t2_r21, `hosts`.`managed` AS t2_r22, `hosts`.`use_image` AS t2_r23, `hosts`.`image_file` AS t2_r24, `hosts`.`uuid` AS t2_r25, `hosts`.`compute_resource_id` AS t2_r26, `hosts`.`puppet_proxy_id` AS t2_r27, `hosts`.`certname` AS t2_r28, `hosts`.`image_id` AS t2_r29, `hosts`.`organization_id` AS t2_r30, `hosts`.`location_id` AS t2_r31, `hosts`.`type` AS t2_r32, `hosts`.`otp` AS t2_r33, `hosts`.`realm_id` AS t2_r34, `hosts`.`compute_profile_id` AS t2_r35, `hosts`.`provision_method` AS t2_r36, `hosts`.`grub_pass` AS t2_r37, `hosts`.`global_status` AS t2_r38, `hosts`.`lookup_value_matcher` AS t2_r39, `hosts`.`expired_on` AS t2_r40, `hosts`.`discovery_rule_id` AS t2_r41, `hosts`.`pxe_loader` AS t2_r42 FROM `fact_values` INNER JOIN `hosts` ON `hosts`.`id` = `fact_values`.`host_id` AND `hosts`.`type` IN ('Host::Managed') INNER JOIN `hostgroups` ON `hostgroups`.`id` = `hosts`.`hostgroup_id` INNER JOIN `fact_names` ON `fact_names`.`id` = `fact_values`.`fact_name_id` WHERE (fact_names.name <> '_timestamp') AND (((`hostgroups`.`id` = '40') OR (`hostgroups`.`id` = '288') OR ( hosts.id IN (553,554,638,639,1213,1638,1905,1907,1910,1911,1912,1913,1914,1915,1957,1958,1959,1960,2107,2110,2111,2113,2339,2340,2341,2342,2343,4008,4009,5730,5733,5736,8586,10989,11076,11079,11082,11085,11088,11091,11094,11097,11595,11598,11601,11604,11607,11610,11613,11616,11619,11796,11799,11922,11964,11967,11970,11973,12000,12003,12006,12012,12015,12024) ))) AND ((fact_values.id IN)) AND ((fact_names.ancestry LIKE '%/1281' OR ancestry = '1281')) AND (fact_names.name <> '_timestamp') ORDER BY `fact_values`.`value` ASC, fact_names.name LIMIT 150 OFFSET 0
Updated by Dominic Cleal almost 8 years ago
Is this combined with a non-admin user, limited by host groups or similar?
Updated by Timo Goebel almost 8 years ago
Dominic Cleal wrote:
Is this combined with a non-admin user, limited by host groups or similar?
Yes. I actually meant to include this information in the original report.
Updated by Timo Goebel almost 8 years ago
Changing
to
conds.push "(fact_names.ancestry LIKE '%/?' OR fact_names.ancestry = '?')"
seems to fix the issue.
Updated by Marek Hulán about 6 years ago
- Status changed from New to Duplicate
Closing as dup of #23505
Updated by Marek Hulán about 6 years ago
- Related to Bug #23505: Viewing children fact values as a user with limited view_host permissions results in "PG::Error: ERROR: column reference "ancestry" is ambiguous" added