This repository was archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
PHPORM-33 Add tests on Query\Builder methods #14
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -925,6 +925,10 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' | |
} | ||
} | ||
|
||
if (func_num_args() == 1 && is_string($column)) { | ||
throw new \ArgumentCountError(sprintf('Too few arguments to function %s("%s"), 1 passed and at least 2 expected when the 1st is a string.', __METHOD__, $column)); | ||
} | ||
|
||
return parent::where(...$params); | ||
} | ||
|
||
|
@@ -1378,4 +1382,28 @@ public function havingBetween($column, iterable $values, $boolean = 'and', $not | |
{ | ||
throw new \BadMethodCallException('This method is not supported by MongoDB'); | ||
} | ||
|
||
/** @internal This method is not supported by MongoDB. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good strategy to mark these as internal to have the IDE notify users already 👍 |
||
public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false) | ||
{ | ||
throw new \BadMethodCallException('This method is not supported by MongoDB'); | ||
} | ||
|
||
/** @internal This method is not supported by MongoDB. */ | ||
public function orWhereIntegerInRaw($column, $values) | ||
{ | ||
throw new \BadMethodCallException('This method is not supported by MongoDB'); | ||
} | ||
|
||
/** @internal This method is not supported by MongoDB. */ | ||
public function whereIntegerNotInRaw($column, $values, $boolean = 'and') | ||
{ | ||
throw new \BadMethodCallException('This method is not supported by MongoDB'); | ||
} | ||
|
||
/** @internal This method is not supported by MongoDB. */ | ||
public function orWhereIntegerNotInRaw($column, $values, $boolean = 'and') | ||
{ | ||
throw new \BadMethodCallException('This method is not supported by MongoDB'); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -332,7 +332,7 @@ public function testTransaction(): void | |
$count = User::count(); | ||
$this->assertEquals(2, $count); | ||
|
||
$this->assertTrue(User::where('alcaeus')->exists()); | ||
$this->assertTrue(User::where('name', 'alcaeus')->exists()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Being too permissive didn't allow to detect this incorrect query. - { "alcaeus": null }
+ { "name": "alcaeus" } The new exception made it surface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to stop using my name in tests. It makes blaming me for my mistakes too easy 😅 |
||
$this->assertTrue(User::where(['name' => 'klinson'])->where('age', 21)->exists()); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on the
if
itself, but I'm wondering if the condition should readfunc_num_args() >= 3
- we wouldn't be removing the$
from an operator if$boolean
was defined as well 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me how
$boolean
is used, but I see it's passed on to the parent method below. I think that's right, and this suggests another lingering bug.I'll defer to you guys whether to fix here (if so, add a regression test that passes a fourth parameter to
where()
(I suppose an explicit'and'
string is fine) or report a new JIRA issue and address in a subsequent PR. A new issue probably makes more sense for visibility in the release notes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #20