Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3cf58ce
Add function to parse query expressions
kodumbeats Apr 22, 2021
514bf70
Add method to parse custom filter queries
kodumbeats Apr 22, 2021
80eec64
Add tests for parsing queries
kodumbeats Apr 22, 2021
69e6bc7
Add test for parsing query expressions
kodumbeats Apr 22, 2021
cdf5267
Refactor query into standalone class
kodumbeats Apr 23, 2021
3f75885
Add getters for object properties
kodumbeats Apr 23, 2021
2a8a5b3
Add method to get all query details
kodumbeats Apr 23, 2021
f763ba4
Add return typing
kodumbeats Apr 23, 2021
06f02f7
Clean up code
kodumbeats Apr 23, 2021
e01fcc4
Call parseExpression as a static method
kodumbeats Apr 23, 2021
65a2166
Add tests for query class
kodumbeats Apr 23, 2021
1bb848d
Refactor parsing code into query class and tests
kodumbeats Apr 23, 2021
e802153
Add type hinting
kodumbeats Apr 23, 2021
83a09a3
Merge branch 'v0' into v0
kodumbeats Apr 23, 2021
c18b485
Add types to constructor params
kodumbeats Apr 23, 2021
b2f6603
Rename operand to value
kodumbeats Apr 23, 2021
f581824
Change to protected method
kodumbeats Apr 23, 2021
fe6becb
Use bracket syntax for switch
kodumbeats Apr 23, 2021
1c6e60c
Treat query expression as kv pair
kodumbeats Apr 23, 2021
179a0d5
Create query validator
kodumbeats Apr 23, 2021
8ada10e
Remove references to old var
kodumbeats Apr 23, 2021
8934ce7
Revert "Change to protected method"
kodumbeats Apr 23, 2021
38b02cf
Revert "Treat query expression as kv pair"
kodumbeats Apr 23, 2021
c2b9dc2
Use value instead of operand
kodumbeats Apr 23, 2021
8c8afb3
Merge branch 'v0' of github.com:kodumbeats/database into v0
kodumbeats Apr 23, 2021
7071923
Clarify intended behavior for parseExpression()
kodumbeats Apr 23, 2021
0ec83e0
Add and fix query tests
kodumbeats Apr 23, 2021
e3f1efb
Constructor expects array of $values by default
kodumbeats Apr 23, 2021
0659fe8
Properly scope parseExpression
kodumbeats Apr 23, 2021
6b3bcd2
Typecast expression values and handle comma-separated values
kodumbeats Apr 26, 2021
a1b472d
Test with integer param
kodumbeats Apr 26, 2021
e74da85
Test for typecasted bool expressions
kodumbeats Apr 26, 2021
f7e86b6
Test multiple query values
kodumbeats Apr 26, 2021
a14a730
Cleanup for readability
kodumbeats Apr 26, 2021
631ecfd
Reserve query validator for separate PR
kodumbeats Apr 26, 2021
4d6189b
Only consider periods oudside parentheses
kodumbeats Apr 26, 2021
1f4c64f
Test for float values
kodumbeats Apr 26, 2021
fa28286
Handle null as value
kodumbeats Apr 26, 2021
2ec2fc8
Refactor elseifs into switch
kodumbeats Apr 26, 2021
ab2a6b7
Use single array_map to trim whitespace and typecast
kodumbeats Apr 26, 2021
b01d9dd
Remove unneeded switch case
kodumbeats Apr 26, 2021
7db5c8f
Trim whitespace and remove escape slashes
kodumbeats Apr 26, 2021
40cd42c
Test for whitespace and escaped character
kodumbeats Apr 26, 2021
53cf8dc
Use strrpos to find last occurrence of parenthesis
kodumbeats Apr 26, 2021
ba852c2
Correct comments
kodumbeats Apr 26, 2021
87dd5b3
Test constructor function
kodumbeats Apr 26, 2021
1522284
Properly handle whitespace between values
kodumbeats Apr 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test for whitespace and escaped character
  • Loading branch information
kodumbeats committed Apr 26, 2021
commit 40cd42c84f6340a3bf13f6761d3f28a0cfe4c6e3
12 changes: 12 additions & 0 deletions tests/Database/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,25 @@ public function testParse()
$this->assertEquals('equal', $query->getOperator());
$this->assertContains(false, $query->getValues());

$query = Query::parse('actors.notContains(" Johnny Depp ")');

$this->assertEquals('actors', $query->getAttribute());
$this->assertEquals('notContains', $query->getOperator());
$this->assertContains('Johnny Depp', $query->getValues());

$query = Query::parse('actors.equal("Brad Pitt", "Johnny Depp")');

$this->assertEquals('actors', $query->getAttribute());
$this->assertEquals('equal', $query->getOperator());
$this->assertContains('Brad Pitt', $query->getValues());
$this->assertContains('Johnny Depp', $query->getValues());

$query = Query::parse('writers.contains("Tim O\'Reilly")');

$this->assertEquals('writers', $query->getAttribute());
$this->assertEquals('contains', $query->getOperator());
$this->assertContains("Tim O'Reilly", $query->getValues());

$query = Query::parse('score.greater(8.5)');

$this->assertEquals('score', $query->getAttribute());
Expand Down