Skip to content

Auto assignments with target filter queries like "type.id=not=XYZ" doesn't match targets without target type (with EclipseLink only) #2758

@avgustinmm

Description

@avgustinmm

Issue:

  • I have 4 devices: 2 of type NOT_XYZ and 2 without type.
  • I create target filter with "type.id=not=XYZ" and assign a distribution set (compatible with all devices)
  • Expected: all 4 devices should be involved
  • Result: only these of type NOT_XYZ are involved. Targets without type are not.

After some debug:

  • this behavior is observed with EclipseLink JPA provider only. With Hibernate it seems as expected - so, it seems the bug comes from there
  • JpaTargetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable creates the following SQL queries:
# EclipseLink
SELECT DISTINCT * FROM sp_target t1 
  LEFT OUTER JOIN sp_target_type t0 ON (t0.id = t1.target_type) 
  LEFT OUTER JOIN (sp_target_type_ds_type t4 JOIN sp_distribution_set_type t2 ON (t2.id = t4.distribution_set_type)) ON (t4.target_type = t0.id), 
  sp_target_type t3 
  WHERE (((((t3.id IS NULL) OR (t1.target_type <> ?)) AND ((t1.target_type IS NULL) OR (t2.id = ?))) AND (t1.tenant = ?)) AND ((t3.id = t1.target_type) AND (t3.tenant = ?))) LIMIT ?, ?
# Hibernate
select distinct * from sp_target jt1_0 
  left join sp_target_type tt1_0 on tt1_0.id=jt1_0.target_type and tt1_0.tenant = ? 
  left join sp_target_type tt2_0 on tt2_0.id=jt1_0.target_type and tt2_0.tenant = ? 
  left join sp_target_type_ds_type dst1_0 on tt2_0.id=dst1_0.target_type
  where jt1_0.tenant = ? and (tt1_0.id is null or tt1_0.id<>?) and (jt1_0.target_type is null or dst1_0.distribution_set_type=?) limit ?,?
  • from the EclipseLink query it seems that the problem is that (t3.tenant = ?) check requires that there is a target type available
  • so, it seems that it is related to EclipseLink and its tenancy support

PS: added a PR with a tests that shows that behavior - #2759 -> TargetManagementSearchTest#shouldFindTargetsWithoutTypeByTypeIdNot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions