Code Monkey home page Code Monkey logo

Comments (9)

orklah avatar orklah commented on May 26, 2024 5

I have a similar issue, the solution I found was ->setParameter('owner', $owner, 'uuid_binary') (or ->setParameter('owner', $owner, UuidBinaryType::NAME)) but it could be great if it could work without the type.

from uuid-doctrine.

orklah avatar orklah commented on May 26, 2024 1

@ramsey well, the issue is that Doctrine don't seem to recognize an Uuid object as is when pushed as a param in a dql request (and so, try to inject [Object(Ramsey\Uuid\Uuid)] in the query).

An easy workaround is to give to setParameter a third param UuidBinaryType::NAME to help it recognize the type, but it's not obvious.

Looking at Doctrine's internals quickly, it doesn't look like there is a module to help infer a parameter type from the variable type (there is only a basic ParameterTypeInferer::inferType for native types). Not sure there's anything you can do, other than adding this to the doc

from uuid-doctrine.

nissen-chris avatar nissen-chris commented on May 26, 2024

@orklah just because I was facing the same problem and couldn't find this solution... Where did you find this solution?

from uuid-doctrine.

orklah avatar orklah commented on May 26, 2024

@nissen-chris I don't really remember, it was a year ago. Maybe something I deducted reading this:
#18
(which is another big issue I had with uuids, there is no good way to pass an array of ids in a request to perform an IN() with SQL)

from uuid-doctrine.

nissen-chris avatar nissen-chris commented on May 26, 2024

@orklah Thank you for your quick reply!
No problem. I also found the other issue in this repository but was interested if I missed something bc I couldn't find anything helpful except your comment.

from uuid-doctrine.

GinoPane avatar GinoPane commented on May 26, 2024

I have a similar issue, the solution I found was ->setParameter('owner', $owner, 'uuid_binary') (or ->setParameter('owner', $owner, UuidBinaryType::NAME)) but it could be great if it could work without the type.

I got this error with your solution:

request.CRITICAL: Uncaught PHP Exception PHPUnit\Framework\Error\Warning: "strlen() expects parameter 1 to be string, object given" at /usr/src/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php line 31 {"exception":"[object] (PHPUnit\Framework\Error\Warning(code: 2): strlen() expects parameter 1 to be string, object given at /usr/src/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ConversionException.php:31)"} {"token":"057f870d-48305172"}

from uuid-doctrine.

nissen-chris avatar nissen-chris commented on May 26, 2024

I am using the string representation in the entity. The ID will be present as sting in the entity and then turned into the binary representation when it is persisted to the database.

from uuid-doctrine.

GinoPane avatar GinoPane commented on May 26, 2024

Ah, ok, I have UuidInterface everywhere

from uuid-doctrine.

ramsey avatar ramsey commented on May 26, 2024

I apologize for taking so long to look into this issue.

Is this still a problem, or did you find a work-around? What change could I make in ramsey/uuid-doctrine to help?

from uuid-doctrine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.