Skip to content

Commit

Permalink
Fixed validation of numeric strings. These will and must be strictly …
Browse files Browse the repository at this point in the history
…handled as strings to support a numeric string _key.
  • Loading branch information
LaravelFreelancerNL committed Nov 18, 2020
1 parent 9fd59ea commit e341c2d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
php-version: '7.4'
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
coverage: xdebug
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/ValidatesExpressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function isNull($value): bool
*/
public function isNumber($value): bool
{
return is_numeric($value);
return is_numeric($value) && !is_string($value);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/AQL/OperatorExpressionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OperatorExpressionsTest extends TestCase
public function testIf()
{
$qb = new QueryBuilder();
$qb->let('x', 5)->return($qb->if(['x', '==', '5'], true, false));
$qb->let('x', 5)->return($qb->if(['x', '==', 5], true, false));
self::assertEquals("LET x = 5 RETURN (x == 5) ? true : false", $qb->get()->query);
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/GrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ public function testIsNumeric()

$result = $this->grammar->isNumber('string');
self::assertFalse($result);

$result = $this->grammar->isNumber('1');
self::assertFalse($result);
}

public function testFormatBind()
Expand Down

0 comments on commit e341c2d

Please sign in to comment.