Skip to content

Commit

Permalink
ObjectSuggestions: Fix exotic columns match
Browse files Browse the repository at this point in the history
These columns should only be shown if expicitely given by user.
Previously, columns with a similar suffix were also found, e.g. the search for `id` also showed `uuid` as search suggestion.
  • Loading branch information
sukhwinder33445 committed Jul 16, 2024
1 parent b377ae1 commit a0e20aa
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,9 @@ protected function queryTags(Model $model, string $searchTerm): Query

protected function matchSuggestion($path, $label, $searchTerm)
{
if (preg_match('/[_.](id)$/', $path)) {
if (preg_match('/[_.](id)$/', $path, $matches)) {
// Only suggest exotic columns if the user knows about them
$trimmedSearch = trim($searchTerm, ' *');
return substr($path, -strlen($trimmedSearch)) === $trimmedSearch;
return $matches[1] === trim($searchTerm, ' *');
}

return parent::matchSuggestion($path, $label, $searchTerm);
Expand Down

0 comments on commit a0e20aa

Please sign in to comment.