cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

When searching using a filter with "OR group", only results that satisfy all (not just any) conditions in OR group are returned #1436

Open PolinaSannikova opened 6 years ago

PolinaSannikova commented 6 years ago

Environment

Description of the bug or enhancement

We are using the following filter:

default

default

When we put check marks in both "Assigned Driver" and "Assigned Vehicle", only device info for devices with both Assigned Driver and Assigned Vehicle are shown. The reason for that is the SQL query used when performing search with a filter - when check marks are put there, there are inner joins both for the TAXI_DRIVER table and TAXI_VEHICLE table, so only devices with both Assigned Driver and Assigned Vehicle are shown. SQL queries attached - one with both "Assigned Driver" and "Assigned Vehicle" ticked, the other only with "Assigned Vehicle" ticked.

assigned_driver_assigned_vehicle.txt assigned_vehicle.txt

Data model (relevant fields):

taxi$DriverDeviceInfo Table: TAXI_DRIVER_DEVICE_INFO

Property Column Type Description Cardinality Annotations
device DEVICE_ID taxi$Device Device 1:1 cuba.persistent

taxi$Device Table: TAXI_DEVICE

Property Column Type Description Cardinality Annotations
id ID java.util.UUID ID   cuba.persistent; cuba.primaryKey; cuba.system
driver   taxi$Driver Current Driver 1:1 cuba.persistent
assignedVehicle   taxi$Vehicle Assigned Vehicle 1:1 cuba.persistent

taxi$Driver Table: TAXI_DRIVER

Property Column Type Description Cardinality Annotations
id ID java.util.UUID ID   cuba.persistent; cuba.primaryKey; cuba.system
assignedDevice ASSIGNED_DEVICE_ID taxi$Device Assigned Device 1:1 cuba.persistent

taxi$Vehicle Table: TAXI_VEHICLE

Property Column Type Description Cardinality Annotations
id ID java.util.UUID ID   cuba.persistent;  cuba.primaryKey;  cuba.system
device DEVICE_ID taxi$Device Device N:1 cuba.persistent

The data model of relevant entities attached. datamodel_part.docx

alexbudarov commented 6 years ago

Infamous "you must use left join for variables used in OR condition" EclipseLink problem as I understand this.

jreznot commented 6 years ago

Yes, all the relations with . (like user.group) treated as inner join in EclipseLink. Unfortunately, there is no way to change this. You could use left join or sub query with OR as a workaround.