Skip to content
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

Data type confusion #321

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ziaratban
Copy link
Contributor

@ziaratban ziaratban commented Sep 16, 2020

Q A
Is bugfix? yes
New feature? yes
Breaks BC? yes
Tests pass? no

mongodb uses BSON type.
if the driver of mongodb returns boolean data type then i can not detect in php. (not found or found).

for example
a document of MyCollection

{
    _id : "5f61f7ec0ec7a41c618477bf",
    myField : false
}
$value =
    MyCollection::Find()
        ->Select(['myField'])
        ->Where(['_id' => new MongoDB\BSON\ObjectId('5f61f7ec0ec7a41c618477bf')])
    ->Scalar()
;
yii::info($value,'test'); //now result found or not found ?

fix

if(
    MyCollection::Find()
        ->Select(['myField'])
        ->Where(['_id' => new MongoDB\BSON\ObjectId('5f61f7ec0ec7a41c618477bf')])
    ->Scalar($value)
){
    echo 'result found';
    //now you can use $value
}
else
    echo 'result not found';

mongodb uses BSON type.
if the driver of mongodb returns boolean data type then i can not detect in php.
@samdark samdark added the pr:request for unit tests Unit tests are needed. label Sep 21, 2020
@yii-bot
Copy link

yii-bot commented Sep 21, 2020

Thank you for putting effort in the improvement of the Yii framework.
We have reviewed your pull request.

In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests.

Could you add these please?

Thanks!

P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests

This is an automated comment, triggered by adding the label pr:request for unit tests.

@ziaratban
Copy link
Contributor Author

@samdark
test environment has bug.
i fixed some bugs in #316.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:request for unit tests Unit tests are needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants