mirror of
https://github.com/flarum/core.git
synced 2025-08-11 19:04:29 +02:00
feat: add support for SQLite
(#3984)
* feat: add support for sqlite * chore: add warning on install * fix: ignore constraints before transaction begins * chore: update workflow * Apply fixes from StyleCI * chore: generate sqlite dump and manually add foreign keys * chore: fix actions * chore: fix actions * chore: fix actions * chore: fix actions * chore: fix actions * chore: fix actions * test: fix * Apply fixes from StyleCI * fix: sqlite with db prefix * Apply fixes from StyleCI * fix: statistics sqlite
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Flarum\Sticky;
|
||||
use Flarum\Search\Database\DatabaseSearchState;
|
||||
use Flarum\Search\SearchCriteria;
|
||||
use Flarum\Tags\Search\Filter\TagFilter;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
class PinStickiedDiscussionsToTop
|
||||
{
|
||||
@@ -45,22 +46,26 @@ class PinStickiedDiscussionsToTop
|
||||
$sticky->where('is_sticky', true);
|
||||
unset($sticky->orders);
|
||||
|
||||
/** @var Builder $q */
|
||||
foreach ([$sticky, $query] as $q) {
|
||||
$read = $q->newQuery()
|
||||
->selectRaw('1')
|
||||
->from('discussion_user as sticky')
|
||||
->whereColumn('sticky.discussion_id', 'id')
|
||||
->where('sticky.user_id', '=', $state->getActor()->id)
|
||||
->whereColumn('sticky.last_read_post_number', '>=', 'last_post_number');
|
||||
|
||||
// Add the bindings manually (rather than as the second
|
||||
// argument in orderByRaw) for now due to a bug in Laravel which
|
||||
// would add the bindings in the wrong order.
|
||||
$q->selectRaw('(is_sticky and not exists ('.$read->toSql().') and last_posted_at > ?) as is_unread_sticky', array_merge($read->getBindings(), [$state->getActor()->marked_all_as_read_at ?: 0]));
|
||||
}
|
||||
|
||||
$query->union($sticky);
|
||||
|
||||
$read = $query->newQuery()
|
||||
->selectRaw('1')
|
||||
->from('discussion_user as sticky')
|
||||
->whereColumn('sticky.discussion_id', 'id')
|
||||
->where('sticky.user_id', '=', $state->getActor()->id)
|
||||
->whereColumn('sticky.last_read_post_number', '>=', 'last_post_number');
|
||||
$query->orderByDesc('is_unread_sticky');
|
||||
|
||||
// Add the bindings manually (rather than as the second
|
||||
// argument in orderByRaw) for now due to a bug in Laravel which
|
||||
// would add the bindings in the wrong order.
|
||||
$query->orderByRaw('is_sticky and not exists ('.$read->toSql().') and last_posted_at > ? desc')
|
||||
->addBinding(array_merge($read->getBindings(), [$state->getActor()->marked_all_as_read_at ?: 0]), 'union');
|
||||
|
||||
$query->unionOrders = array_merge($query->unionOrders, $query->orders);
|
||||
$query->unionOrders = array_merge($query->unionOrders ?? [], $query->orders ?? []);
|
||||
$query->unionLimit = $query->limit;
|
||||
$query->unionOffset = $query->offset;
|
||||
|
||||
|
Reference in New Issue
Block a user