Uh oh!
There was an error while loading. Please reload this page.
Feat: toString() for queries - #174
Conversation
| * | ||
| * @return string | ||
| */ | ||
| public function toString(): string |
There was a problem hiding this comment.
@Meldiron I think this is a pretty cool suggestion, can we have the same thing for Role and Permission?
There was a problem hiding this comment.
__toString() would only be used in the case where the object is contextually expected to be a string, e.g.
echo Query::limit(1);For the case in the description, we would have to call the magic method:
'queries' => [ Query::limit(1)->__toString() ]I think it's cleaner to implement an instance method toString() instead
abnegate
commented
Jan 10, 2023
@Meldiron What's left to move this out of draft state? |
Meldiron
commented
Jan 10, 2023
This is not relevant anymore, closing the PR. |
In Appwrite, we currently test queries by passing string versions into HTTP requests, such as
Thanks to introduction of
toString(), we can now build actual query classes in Appwrite tests, such asThat will improve code quality and will make sure no unexpected test breaks occur when internal change is done to queries syntax.