mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 07:50:24 +08:00
Make sure query filter works with database prefix, too
Related to flarum/core#269.
This commit is contained in:
parent
05c7438396
commit
a90dfd686a
@ -39,10 +39,15 @@ class PinStickiedDiscussionsToTop
|
||||
->where('discussions.is_sticky', '=', true)
|
||||
->where('users_discussions.user_id', '=', $event->search->getActor()->id);
|
||||
});
|
||||
|
||||
// might be quicker to do a subquery in the order clause than a join?
|
||||
$prefix = app('Illuminate\Database\ConnectionInterface')->getTablePrefix();
|
||||
array_unshift(
|
||||
$query->orders,
|
||||
['type' => 'raw', 'sql' => '(is_sticky AND (users_discussions.read_number IS NULL OR discussions.last_post_number > users_discussions.read_number)) desc']
|
||||
[
|
||||
'type' => 'raw',
|
||||
'sql' => "(is_sticky AND ({$prefix}users_discussions.read_number IS NULL OR {$prefix}discussions.last_post_number > {$prefix}users_discussions.read_number)) desc"
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user