Make search attributes not case sensitive

This commit is contained in:
Frederic Guillot 2016-07-14 11:39:59 -04:00
parent 48ee733f9e
commit 9496dfdb6d
No known key found for this signature in database
GPG Key ID: 92D77191BA7FBC99
3 changed files with 22 additions and 1 deletions

View File

@ -9,6 +9,7 @@ New features:
Improvements:
* Make search attributes not case sensitive
* Display TOTP issuer for 2FA
* Make sure that the table schema_version use InnoDB for Mysql

View File

@ -69,7 +69,7 @@ class LexerBuilder
foreach ($attributes as $attribute) {
$this->filters[$attribute] = $filter;
$this->lexer->addToken(sprintf("/^(%s:)/", $attribute), $attribute);
$this->lexer->addToken(sprintf("/^(%s:)/i", $attribute), $attribute);
if ($default) {
$this->lexer->setDefaultToken($attribute);

View File

@ -103,4 +103,24 @@ class LexerBuilderTest extends Base
$this->assertFalse($builder === $clone);
$this->assertFalse($builder->build('test')->getQuery() === $clone->build('test')->getQuery());
}
public function testBuilderWithMixedCaseSearchAttribute()
{
$project = new ProjectModel($this->container);
$taskCreation = new TaskCreationModel($this->container);
$taskFinder = new TaskFinderModel($this->container);
$query = $taskFinder->getExtendedQuery();
$this->assertEquals(1, $project->create(array('name' => 'Project')));
$this->assertNotFalse($taskCreation->create(array('project_id' => 1, 'title' => 'Test')));
$builder = new LexerBuilder();
$builder->withFilter(new TaskAssigneeFilter());
$builder->withFilter(new TaskTitleFilter(), true);
$builder->withQuery($query);
$tasks = $builder->build('AsSignEe:nobody')->toArray();
$this->assertCount(1, $tasks);
$this->assertEquals('Test', $tasks[0]['title']);
}
}