[MODM-153] "Near" Query does not work. Created: 10/Aug/11 Updated: 20/Feb/12 |
|
| Status: | Open |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | 1.0.0BETA2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Dmitry | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
"Near" statement does not work for me. The following code returns all cities from collection: $cities = $this->dm->createQuery('City')
->field('coordinates')->near(50, 60)
->execute();
Could you please fix it? |
| Comments |
| Comment by mark wright [ 02/Sep/11 ] |
|
It also does not work in beta3 but it fails differently. It never returns anything. $places = $documentManager->createQueryBuilder('Documents\Place') This returns 0 documents even though I have a point at 36.5788493, -121.7207805. Doctrine\MongoDB\Query\Builder::near() only takes one argument so the Y value is ignored. However, the docblock specifies 2 params. |
| Comment by Tim Sakharchuk [ 04/Sep/11 ] |
|
Hi All, Here is correct realization of this function in public function near($x, $y) { $this->query['type'] = Query::TYPE_GEO_LOCATION; $this->query['near'] = array($x, $y); return $this; }When may this fix appear in Doctrine ODM? Thanks! |
| Comment by Shane A. Stillwell [ 20/Feb/12 ] |
|
I had the same issue on 1.0.0.BETA3. The solution was to change the query up a little. $places = $this->dm->createQueryBuilder('\Application\Event')->field('latitude')->near(50)->field('longitude')->near(60)->getQuery()->execute();
|
[MODM-149] Fix PHPDoc @return types in various places Created: 05/Jul/11 Updated: 05/Apr/12 |
|
| Status: | Open |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Document Manager |
| Affects Version/s: | 1.0.0BETA3 |
| Fix Version/s: | None |
| Type: | Documentation | Priority: | Critical |
| Reporter: | Dayson Pais | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In certain PHPDoc blocks for functions, the @return type is not of the right type. This causes auto-completion issues in various IDEs (I'm using PhpStorm). For example, in \Doctrine\ODM\MongoDB\DocumentManager on line #341 the ->createQueryBuilder($documentName = null) function. /**
|
| Comments |
| Comment by Lee Davis [ 05/Apr/12 ] |
|
This appears to be fixed in 1.0.0BETA4-DEV Line 357 in Doctrine\ODM\MongoDB\DocumentManager... /**
|
[MODM-116] Collection Per Class Inheritance : Documents of a child class referenced in a parent class may be saved to the parent collection Created: 07/Feb/11 Updated: 21/Apr/11 |
|
| Status: | Reopened |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Document Manager |
| Affects Version/s: | 1.0.0BETA3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | JF Bustarret | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Here is my class hierarchy (classes & attributes renamed for a better understanding) :
/** @Document @InheritanceType("COLLECTION_PER_CLASS") **/
class Parent {
/** @ReferenceOne(targetDocument="Child") **/
protected $child;
}
/** @Document **/
class Child extends Parent {
}
When doing : $parent->setXXX($value); $parent->getChild()->setXXX($value2) the $parent->getChild() document is saved to the Parent collection. It looks like the problems lies in UnitOfWork::executeUpdates :
if (get_class($document) == $className || $document instanceof Proxy && $document instanceof $className) {
$child_document is an instance of Proxy (ChildProxy) and also an instance of Parent => saved using the Parent persister. Shouldn't the test be : get_class($document) == $className || get_class($document) == $className_of_Proxy ? As a side note : why "if ($class->isEmbeddedDocument) { continue; }" is within the foreach and not a "if ($class->isEmbeddedDocument) { return; }" at the beginning of the method ? |
| Comments |
| Comment by Jonathan H. Wage [ 11/Feb/11 ] |
|
I added a test for this here and it appears to be passing: https://github.com/doctrine/mongodb-odm/commit/3f24d77cc04adc0bb5532333e33826100457c666 |
| Comment by JF Bustarret [ 11/Feb/11 ] |
|
I'll try to get more info on the problem and provide a test for it. |
| Comment by JF Bustarret [ 28/Mar/11 ] |
|
Here is a new test case :
/** @Document
* @InheritanceType("COLLECTION_PER_CLASS")
**/
class MODM116Parent
{
/** @Id */
private $id;
/** @String */
private $name;
/** @ReferenceOne **/
private $child;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getChild()
{
return $this->child;
}
public function setChild(MODM116Child $child)
{
$this->child = $child;
}
}
/** @Document **/
class MODM116Child extends MODM116Parent
{
/** @EmbedMany(targetDocument="MODM116Embedded") **/
protected $embedded;
function addEmbedded($parent) {
$this->embedded[] = new MODM116Embedded($parent);
}
}
/** @EmbeddedDocument **/
class MODM116Embedded {
/** @ReferenceOne(targetDocument="MODM116Parent") **/
protected $parent;
public function __construct($parent) {
$this->parent = $parent;
}
}
$parent = new MODM116Parent();
$parent->setName('test');
$parent->setChild(new MODM116Child());
$dm->persist($parent->getChild());
$dm->persist($parent);
$dm->flush();
$dm->clear();
$parent = $dm->getRepository(get_class($parent))->findOneBy(array('name' => 'test'));
$parent->getChild()->setName('ok');
$parent->getChild()->addEmbedded($parent);
$dm->flush();
|
| Comment by JF Bustarret [ 30/Mar/11 ] |
|
Pulled the last version from git. The bug still exists. |
| Comment by JF Bustarret [ 21/Apr/11 ] |
|
Up. Any news on a fix ? |