Skip to content

Commit

Permalink
fixed invalid decimal separator casting in locales using , rather than .
Browse files Browse the repository at this point in the history
  • Loading branch information
jarektkaczyk committed Mar 3, 2018
1 parent 4fac84d commit 2c3e26e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function addSearchClauses(
$this->searchWhere($subquery, $columns, $words, $whereBindings);
}

$this->query->where('relevance', '>=', new Expression($threshold));
$this->query->where('relevance', '>=', new Expression(number_format($threshold, 2)));

$this->query->orders = array_merge(
[['column' => 'relevance', 'direction' => 'desc']],
Expand Down
12 changes: 6 additions & 6 deletions tests/SearchableBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function single_character_wildcards()
{
$sql = 'select * from (select `users`.*, max(case when `users`.`last_name` = ? then 150 else 0 end) '.
'as relevance from `users` where (`users`.`last_name` like ?) '.
'group by `users`.`primary_key`) as `users` where `relevance` >= 2.5 order by `relevance` desc';
'group by `users`.`primary_key`) as `users` where `relevance` >= 2.50 order by `relevance` desc';

$bindings = ['jaros_aw', 'jaros_aw'];

Expand Down Expand Up @@ -157,7 +157,7 @@ public function additional_order_clauses()
'+ case when `profiles`.`name` = ? then 15 else 0 end) as relevance '.
'from `users` left join `profiles` on `users`.`profile_id` = `profiles`.`id` '.
'where (`users`.`first_name` like ? or `profiles`.`name` like ?) group by `users`.`primary_key`) '.
'as `users` where `relevance` >= 0.5 order by `relevance` desc, `first_name` asc';
'as `users` where `relevance` >= 0.50 order by `relevance` desc, `first_name` asc';

$bindings = ['jarek', 'jarek', 'jarek', 'jarek'];

Expand All @@ -176,7 +176,7 @@ public function length_aware_pagination()
'+ case when `users`.`last_name` like ? then 50 else 0 end '.
'+ case when `users`.`last_name` like ? then 10 else 0 end) '.
'as relevance from `users` where (`users`.`last_name` like ?) '.
'group by `users`.`primary_key`) as `users` where `relevance` >= 2.5';
'group by `users`.`primary_key`) as `users` where `relevance` >= 2.50';

$bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];

Expand All @@ -195,7 +195,7 @@ public function case_insensitive_operator_in_postgres()
'+ case when "users"."last_name" ilike ? then 50 else 0 end '.
'+ case when "users"."last_name" ilike ? then 10 else 0 end) '.
'as relevance from "users" where ("users"."last_name" ilike ?) '.
'group by "users"."primary_key") as "users" where "relevance" >= 2.5 order by "relevance" desc';
'group by "users"."primary_key") as "users" where "relevance" >= 2.50 order by "relevance" desc';

$bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];

Expand Down Expand Up @@ -228,7 +228,7 @@ public function wildcard_search_by_default()
'+ case when `users`.`last_name` like ? then 50 else 0 end '.
'+ case when `users`.`last_name` like ? then 10 else 0 end) '.
'as relevance from `users` where (`users`.`last_name` like ?) '.
'group by `users`.`primary_key`) as `users` where `relevance` >= 2.5 order by `relevance` desc';
'group by `users`.`primary_key`) as `users` where `relevance` >= 2.50 order by `relevance` desc';

$bindings = ['jarek', 'jarek%', '%jarek%', '%jarek%'];

Expand Down Expand Up @@ -301,7 +301,7 @@ public function explicit_search_on_joined_table()
'as relevance from `users` left join `profiles` on `users`.`profile_id` = `profiles`.`id` '.
'where (`users`.`first_name` like ? or `users`.`first_name` like ? or `users`.`last_name` like ? or `users`.`last_name` like ? '.
'or `users`.`email` like ? or `users`.`email` like ? or `profiles`.`name` like ? or `profiles`.`name` like ?) '.
'group by `users`.`primary_key`) as `users` where `relevance` >= 4.5 order by `relevance` desc';
'group by `users`.`primary_key`) as `users` where `relevance` >= 4.50 order by `relevance` desc';

$bindings = [
'jarek', 'tkaczyk', 'jarek', 'tkaczyk', 'jarek', 'tkaczyk', 'jarek', 'tkaczyk',
Expand Down

0 comments on commit 2c3e26e

Please sign in to comment.