-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing responce #121
Comments
It's actually an This should work: if ($res['errors'] !== 0) {
return $res;
} |
We could slightly improve this and set the I'm not sure how this behaves for array indexes that are not valid PHP field names though (for example PHP keywords). We would need to test that. |
Hi Daniel! Thanks! Should it be the same for table creation? The fails every time: <?php
use r\Queries\Dbs\Db as rDb;
use r\Queries\Tables\TableCreate;
$conn = $di->get('r\Connection');
$rdb = new rDb($conn->defaultDbName);
$res = $conn->run((new TableCreate($rdb, 'teams')));
if ($res['tables_created'] !== 1) {
throw new Exception('Table "teams" not created');
exit(1);
} |
Oh sorry I forgot that it's still a float. |
The ReQL type system doesn't distinguish between floats and integers unfortunately. I'm not sure if there's anything we can do to make this easier. |
|
I think using I'm not familiar with type hints outside of function declarations. Do you have a link to some documentation or an example? |
I'm no expert, I'm simply quoting the manual: "never trust floating number
It would probably be simpler if there was some way this can be done at the On Mon, Feb 29, 2016, 10:20 AM Daniel Mewes notifications@github.com
|
It would seem that testing a response is extremely cumbersome. First, the response is returned as an object, and needs to be typeset to an array (as all it's properties are private). Next, the individual value needs to be typeset from a float to an int, an inherently "dangerous" operation. Finally, the value can be tested.
In code;
The more intuitive way of testing that I would expect would be:
Am I missing something, or is there really no better way to do this?
The text was updated successfully, but these errors were encountered: