Skip to content

Commit 4fa153f

Browse files
committed
Fix expression to use table prefix
1 parent fcd76cc commit 4fa153f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/elements/db/VariantQuery.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ protected function beforePrepare(): bool
483483
$sortOrderIndex = Db::findIndex(CraftTable::ELEMENTS_OWNERS, ['sortOrder'], false);
484484
// Forcing the use of the `sortOrder` index if no custom `orderBy` is set
485485
if ($sortOrderIndex !== null && empty($this->orderBy)) {
486-
$this->subQuery->innerJoin([new Expression('[[elements_owners]] USE INDEX (' . $sortOrderIndex . ')')], $ownersCondition);
486+
$elementOwnersTable = Craft::$app->getDb()->schema->getRawTableName(\craft\db\Table::ELEMENTS_OWNERS);
487+
$this->subQuery->innerJoin([new Expression('[['.$elementOwnersTable.']] AS elements_owners USE INDEX (' . $sortOrderIndex . ')')], $ownersCondition);
487488
} else {
488489
$this->subQuery->innerJoin(['elements_owners' => CraftTable::ELEMENTS_OWNERS], $ownersCondition);
489490
}

0 commit comments

Comments
 (0)