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
Added MongoDB support #1
Conversation
@@ -22,10 +22,14 @@ | |||
"source": "https://github.com/portphp/doctrine", | |||
"docs": "https://portphp.readthedocs.org" | |||
}, | |||
"minimum-stability": "dev", |
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.
I think this kind of configuration should go to the bottom of the file: most people are rather interested in requirements than stability settings for development.
"doctrine/orm": "~2.4" | ||
"doctrine/orm": "~2.4", | ||
"doctrine/mongodb": "dev-master", | ||
"doctrine/mongodb-odm": "dev-master" |
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.
Why these aggressive dependencies? @sagikazarmark And I think we should create a separate doctrine-mongo-adapter and move this there.
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.
I thought the plan was to support object manager in one adapter.
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.
Yeah, we decided that in portphp/portphp#13. However, that means the dependencies here need to be moved to require-dev
.
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.
Ah, you already mentioned that above.
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.
Then why do we need a separate mongo adapter?
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.
You’re right, we don’t (as long as we move the deps to require-dev
).
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.
Cool! 👍
Conflicts: src/DoctrineWriter.php
@sagikazarmark @ddeboer Please accept portphp/portphp#26 |
See my comment on that PR |
@sagikazarmark https://travis-ci.org/portphp/doctrine-adapter/jobs/71258849 fails again on php5.4 ... why? |
Not on PHP 5.4, but with lowest dependencies. One of the dependencies version must be higher. You can try it: $ composer update --prefer-lowest --prefer-stable and run tests. Try moving the lowest dependency up. |
@sagikazarmark Done! :-) |
Great. Awaiting for response from @ddeboer |
This reverts commit 942c01c.
$query = $this->objectManager->createQuery( | ||
sprintf('SELECT COUNT(o) FROM %s o', $this->objectName) | ||
); | ||
$query = $this->objectManager->createQueryBuilder() |
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.
Why do you use the query builder here?
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.
For getting this method work for both Doctrine ORM and Doctrine MongoDB ODM.
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.
Ah okay.
@@ -262,47 +287,50 @@ protected function disableLogging() | |||
*/ | |||
protected function reEnableLogging() | |||
{ | |||
$config = $this->entityManager->getConnection()->getConfiguration(); | |||
//TODO: do we need to add support for MongoDB logging? | |||
if (!($this->objectManager instanceof \Doctrine\ORM\EntityManager)) return; |
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.
Should throw an exception if the odm is used.
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.
Why? If ODM is used, it will just do nothing. This is expected behaviour. Logger should be disabled/enabled only for EntityManager
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.
Yeah i think this isn't expected. If i call an method and he does not throw any exception, i would expect that he works.
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.
What's your proposition then? If the ODM is used, this method shouldn't be called. Should I change the code this way?
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.
I would simply throw an Exception
if the objectManager
property isn't a Doctrine\ORM\EntityManager
.
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.
Then this exception should be handled in the client code.
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.
Exactly. If the user tries some illegal actions, an exception should be thrown.
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.
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 a user tries to do illegal actions. The logger for SQL is disabled to speed up the write operations. Honesty, I don't know how to disable the logging for MongoDB. That's why this functionality is supported for Doctrine ORM only.
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.
Ah, so this is an internal thing. Still, a separated class would simply solve this issue.
Hey Sergey, i would really say thank you for your work. Really great PR 👍 I'm 👍 on this. |
Thanks, Baachi :-) |
I agree with @Baachi 👍 |
@smilesrg Looks great! can you please squash commits? |
@ddeboer done |
@ddeboer any news on acception this PR? |
@ddeboer wow, after 1.5 years it has been merged today :-) Hope my contribution will be helpful :-) |
Yeah, sorry about that delay. It’s definitely helpful! Thanks for your work. 😄 |
Added MongoDB support