Skip to content

[Uid] Mention the Doctrine type hinting of UUID/ULID values #14693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

javiereguiluz
Copy link
Member

Fixes #14676.

$qb = $this->createQueryBuilder('p')
// ...
// add 'ulid' as the third argument to tell Doctrine that this is an ULID
->setParameter('user', $user->getUlid(), 'ulid')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doctrine recommends to use constants in the documentation, is there an equivalent for ULID?

<?php

use Doctrine\DBAL\Types\Types;

// prevents attempt to load metadata for date time class, improving performance
$qb->setParameter('date', new \DateTimeImmutable(), Types::DATE_IMMUTABLE)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the type in DBAL. There's guid but not uuid or ulid. See https://github.com/doctrine/dbal/blob/2.12.x/lib/Doctrine/DBAL/Types/Types.php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ulid require another dependency that Doctrine ?

It looks like GUID and UUID could be used because they are synonyms:

/**
 * Represents a GUID/UUID datatype (both are actually synonyms) in the database.
 */
class GuidType extends StringType
{

Source: https://github.com/doctrine/dbal/blob/9e37d1bdc1ee589e9baab2bb16aebf6e16a18a92/lib/Doctrine/DBAL/Types/GuidType.php#L8

But I dont know for ULID and I don't want to block the merging of this PR, feel free to keep the current code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's sad that we don't have an ULID type ... so let's use strings for now. Thanks!

@javiereguiluz javiereguiluz merged commit 1e8b725 into symfony:5.2 Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants