# fetch cut_in_line and request_time since they're in the order_by
# and we're asking for distinct values
select => {ahr => ['id', 'cut_in_line', 'request_time']},
- from => {
- ahr => {
- ahcm => {type => 'left'} # there may be no copy maps
- }
- },
+ from => { ahr => 'ahcm' },
order_by => [
{
"class" => "ahr",
],
distinct => 1,
where => {
- '-or' => [
- {
- '+ahcm' => {
- target_copy => {
- in => {
- select => {ahcm => ['target_copy']},
- from => 'ahcm',
- where => {hold => $hold->id}
- }
+ {
+ '+ahcm' => {
+ target_copy => {
+ in => {
+ select => {ahcm => ['target_copy']},
+ from => 'ahcm',
+ where => {hold => $hold->id}
}
- }
- },
- {
- '+ahr' => {
- hold_type => $hold->hold_type,
- target => $hold->target
- }
+ }
}
- ]
- },
+ }
+ }
});
my $qpos = 1;