orientdb-odm icon indicating copy to clipboard operation
orientdb-odm copied to clipboard

Implemented skip in findBy method in Repository class

Open tomcyr opened this issue 12 years ago • 14 comments

There was $offset argument but it was nothing meaning for query:)

tomcyr avatar Jan 28 '13 23:01 tomcyr

Hi tomcyr,

what about adding a test for this PR?

odino avatar Jan 29 '13 07:01 odino

Hi @odino, OK, I'll do it later.

tomcyr avatar Jan 29 '13 09:01 tomcyr

great, thanks!

odino avatar Jan 29 '13 09:01 odino

https://github.com/tomcyr/orientdb-odm/commit/dcddc4a392e7392a628e9edddb8bcc1c5d780739 - http status 100 we have as response when updating documents

tomcyr avatar Jan 31 '13 02:01 tomcyr

@tomcyr great job! Im just gonna check one thing with luca garulli.

@lvca, is it normal that we get a response 100 Continue when updating a document through the HTTP protocol?

odino avatar Jan 31 '13 07:01 odino

@odino you should receive 200 if ok

lvca avatar Jan 31 '13 07:01 lvca

@tomcyr is there any way we can reproduce why we're getting 100 Continue?

odino avatar Jan 31 '13 08:01 odino

OK, let's say we have example test records in db from this example: https://github.com/doctrine/orientdb-odm/issues/158

Next in my action:

/**
* @Route("/api/test")
*/
public function indexAction()
{
    $manager = $this->container->get('odm');
    $tests = $manager->getRepository('\ConceptIt\SmartShopperBundle\Entity\Test')->findBy(array(), array(), 10);
    foreach($tests as $key => $test){
        $test->setName('aaa'.$key);
        $manager->persist($test);
    }

}

And then I receive HTTP STATUS 100 and response text 'Record '#14:0' updated successful'. I'm almost sure if I was persist object first time and then I was updating but without getting it from repository I received HTTP STATUS 200 but I'll check it later. And of course I'm using persist method from this branch: https://github.com/tomcyr/orientdb-odm/tree/custompersist

tomcyr avatar Jan 31 '13 10:01 tomcyr

OK, I know now but it's very strange: After update record I have response with headers: HTTP/1.1 200 OK Date: Fri Feb 01 01:41:06 CET 2013 Content-Type: text/plain; charset=utf-8 Server: OrientDB Server v.1.3.0 (build @BUILD@) Connection: Keep-Alive Set-Cookie: OSESSIONID=OS13596792653036567721899010732517; Path=/; HttpOnly Content-Length: 34

Record #12:1 updated successfully. 500 Internal Server Error - InvalidQueryException

so I dump before Exception InvalidQueryException, in code:

    public function getData()
    {
        if (!$this->isValid()) {
            var_dump($this->response->getStatusCode());
            throw new InvalidQueryException($this->response->getBody(), $this);
        }
        $body = $this->response->getBody();

        if (null === $json = json_decode($body)) {
            if ($this->isValidRid($body)) {
                return $body;
            } elseif ($body === "") {
                return true;
            }
            throw new \RuntimeException("Invalid JSON payload");
        }

        return $json;
    }

and in dump i have 100 !!! Isn't strange?? So I added status_continue into valid responses

tomcyr avatar Feb 01 '13 00:02 tomcyr

There is another problem yet. If we're updating document in Orient DB which has @version > 0 we must send our @version in request. We have @version of document in response when we're getting it from db but we must have it in our object. So the simplest way is to add property version with name @version in annotation in every Entity class. But I'm wonder if there is any better place for it??

tomcyr avatar Feb 01 '13 09:02 tomcyr

@tomcyr like for the RID, I think it makes sense to add a custom property

@nrk what about having a trait for that? The thing is, how to gracefully degradate when we're using php 5.3...

odino avatar Feb 03 '13 05:02 odino

hey @tomcyr, any news on this?

odino avatar May 07 '13 19:05 odino

hey @odino, because nothing happened with orientdb-odm last few months I used mongo :(

tomcyr avatar May 22 '13 12:05 tomcyr

ok, no worries :)

odino avatar May 22 '13 12:05 odino