Integer keys with a value of 0 are not saved #494

Closed
Bilge2 opened this Issue Feb 9, 2013 · 2 comments

Comments

Projects
None yet
2 participants

Bilge2 commented Feb 9, 2013

class Foo {
    public
        /** @Int */
        $bar
    ;
}

$foo = new Foo;
$foo->bar = 0;
$dm->persist($foo);
$dm->flush(); //Foo { }

$foo = new Foo;
$foo->bar = 1;
$dm->persist($foo);
$dm->flush(); //Foo { bar: 1 }
Member

malarzm commented Dec 1, 2014

This no longer seems to be an issue, here's passing test case:

<?php

namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

class GH494Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
    public function test494()
    {
        $d = new GH494Document(0);
        $this->dm->persist($d);
        $this->dm->flush();
        $this->dm->clear();
        $r = $this->dm->getRepository(get_class($d));
        $this->assertNotNull($r->findOneByInt(0));
    }
}

/** @ODM\Document */
class GH494Document
{
    /** @ODM\Id */
    public $id;

    /** @ODM\Int */
    public $int;

    public function __construct($i) 
    {
        $this->int = $i;
    }
}
Member

malarzm commented Mar 6, 2015

Closing the issue for now, @Bilge2 feel free to reopen if it's still happening

@malarzm malarzm closed this Mar 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment