Skip to content

How to search a partial uuid? #440

Description

@chateaux

My transactions table uses a uuid which is stored as bytes in the database.

I would like to know how to search for a partial uuid? Obviously, since we are using bytes, the data is stored as a binary in the table so in theory I need to convert the partial uuid string to a binary and then to search on that.

Is there anyway to do this natively with UUID?

If I had a full UUID, I am simply going to use something like so:

$qb->andWhere('transactions.uuid = :uuid')->setParameter('uuid', Uuid::fromString($options['transactionUuid'])->getBytes());

But to search a partial uuid, I am looking to do something as follows:

$qb->expr()->like('transaction.uuid', Uuid:fromString(':search')->getBytes()),

But obviously the fromString requires a correctly formed uuid string as apposed to a partial.

I am not sure this is possible and perhaps is one of the downfalls of using bytes in the table as apposed to string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions