Last active
August 17, 2020 08:46
-
-
Save BenSchZA/40da2989164e755de7bac8ad278ad9a7 to your computer and use it in GitHub Desktop.
Filter by has_many association
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from(record in Domain.DHR.DeviceHistoryRecord, | |
left_join: failures in assoc(record, :failures), on: failures.device_history_record_id == entry.id, | |
where: ilike(failures.type, ^"%#{query}%"), | |
distinct: entry.id | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to query all
DeviceHistoryRecord
s that have a failure of the given type.failures
has ahas_many
/belongs_to
relationship with theDeviceHistoryRecord
.