Add ability to configure index hint with variable

See #1560
This commit is contained in:
Kijin Sung 2021-01-14 00:40:38 +09:00
parent 0c6bc8fbb1
commit 03e5909036
6 changed files with 81 additions and 4 deletions

View file

@ -101,7 +101,15 @@ class DBQueryParser extends BaseParser
$index_hint->hint_type = strtoupper(trim($tag['type'])) ?: 'USE';
$index_hint->index_name = trim($tag['name']) ?: '';
$index_hint->table_name = trim($tag['table']) ?: '';
if ($index_hint->index_name)
if (isset($tag['var']) && trim($tag['var']))
{
$index_hint->var = trim($tag['var']);
}
if (isset($tag['default']) && trim($tag['default']))
{
$index_hint->index_name = trim($tag['default']);
}
if ($index_hint->index_name || $index_hint->var)
{
$query->index_hints[] = $index_hint;
}