Skip to content
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

🐛 ManyToMany id typecast gets wrong id #427

Closed
1 task done
gam6itko opened this issue Jul 24, 2023 · 1 comment · Fixed by #428
Closed
1 task done

🐛 ManyToMany id typecast gets wrong id #427

gam6itko opened this issue Jul 24, 2023 · 1 comment · Fixed by #428
Assignees
Labels
Milestone

Comments

@gam6itko
Copy link
Contributor

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

After update to 2.3.3 I've got ManyToMany Relation bug. It pass to my custom UuidTypecaster id of Post but not File.

The problem appeared after this changes c7edd6b#diff-e299fc705879bf607db737052f5877933b57a8f09771af24ccad1ff70ea3ad9a

#[Cycle\Entity(table: 'post')]
class Post {
    /**
     * @var File[]
     */
    #[Cycle\Relation\ManyToMany(target: File::class, though: PostScreenshot::class, throughInnerKey: 'post_id')]
    private array $screenshots = [];
}


#[Cycle\Entity(table: 'post_screenshot')]
class PostScreenshot
{
    #[Cycle\Column(type: 'primary', unsigned: true)]
    private ?int $id = null;
}


#[Cycle\Entity(
    table: 'file',
    typecast: [
        \Cycle\ORM\Parser\Typecast::class,
        UuidTypecast::class,
    ]
)]
class File
{
    #[Cycle\Column(type: 'string(36)', primary: true, typecast: 'uuid')]
    private UuidInterface $id;
}


final class UuidTypecast extends AbstractTypecast
{
    protected function getType(): string
    {
        return 'uuid';
    }

    protected function fromDbValue(mixed $value): mixed
    {
        return Uuid::fromString($value);
    }

    protected function toDbValue(mixed $value): mixed
    {
        assert($value instanceof UuidInterface); // bug here
        return $value->toString();
    }
}

Version

ORM 2.3.3
PHP 8.1
@gam6itko gam6itko added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Jul 24, 2023
@gam6itko gam6itko changed the title 🐛 ManyToMany id typecast 🐛 ManyToMany id typecast gets wrong id Jul 24, 2023
@roxblnfk roxblnfk linked a pull request Jul 24, 2023 that will close this issue
@roxblnfk roxblnfk removed the status:to be verified Needs to be reproduced and validated. label Jul 24, 2023
@roxblnfk
Copy link
Member

Will be fixed in ORM 2.3.4 or 2.4.0

@roxblnfk roxblnfk added this to the 2.3.x milestone Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants