Skip to content

Commit

Permalink
Do not qualify the column name when already prefixed
Browse files Browse the repository at this point in the history
See #33
  • Loading branch information
lorisleiva committed Feb 5, 2021
1 parent 9ca5967 commit 8b0b820
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SearchStringManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public function createBuilder($input)

public static function qualifyColumn($builder, $column)
{
if (strpos($column, '.') !== false) {
return $column;
}

if (! $table = static::getTableFromBuilder($builder)) {
return $column;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/CreateBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ public function it_uses_the_real_column_name_when_using_an_alias()
$this->assertWhereSqlEquals('not active', "models.activated = false", $model);
}

/** @test */
public function is_does_not_prefix_the_column_table_when_it_already_is_prefixed()
{
$model = $this->getModelWithColumns([
'my_model_table.zipcode' => 'postcode',
]);

$this->assertWhereSqlEquals('postcode:1028', "my_model_table.zipcode = 1028", $model);
}

/**
* @test
* @dataProvider success
Expand Down

0 comments on commit 8b0b820

Please sign in to comment.