l3pp4rd/DoctrineExtensions — pull request #247 by comfortablynumb (2012-01-27 17:21:21+00:00)
Title: [WIP] Tree: Materialized Path

Hi all,

I'm in the middle of a project which needs this, so I've started to work on the Materialized Path strategy for the Tree extension yesterday.

This is just an experiment yet. It's far from being complete. There are a lot of work to do yet, including:

* Add some more mapping and runtime validations
* Add more methods to the repository (so far I've included only one just to make it work)
* Check and optimize the internals of the strategy
* My need was only for MongoDB, but create the ORM equivalent I think it's trivial. I've abstracted as much as possible all the functionalities in AbstractMaterializedPath class. So far, I need to implement only two methods in the strategy, and create a repository for the ORM.
* Add more tests (There are already some)

There are some drawbacks though:

* In MongoDB, updates to multiple documents are not atomic, so this could lead in tree inconsistencies. What would be the best approach to minimize this?

And, finally, some questions:

* Should we make the "level" property mandatory in this strategy? I think it's worth it, and some internal queries could benefit from this instead of using a regex.
* Should we avoid in the PathSource the usage of the selected "separator", throwing a RuntimeException when trying to set the PathSource with it? I think yes, but I ask because maybe someone has a better alternative.

Well, that's all for now. I'd like to hear your opinions guys.

Thanks.