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

Embeddable as part of composite primary key #682

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MartinLojda
Copy link

First attemp of fixing issue #575

@hrach
Copy link
Member

hrach commented Oct 25, 2024

We need tests, I can add them but please, send me a real usecase :) What's your usage?

@hrach hrach added the feature label Oct 25, 2024
@hrach hrach linked an issue Oct 25, 2024 that may be closed by this pull request
@MartinLojda
Copy link
Author

I have composite primary key that consist of relation (that works fine) and DataRangeEmbeddable which is containing two DateTimeImmutables.

Entity is like this:

 * @property array $id {primary-proxy}
 *
 * @property Trailer $trailer {m:1 Trailer, oneSided=true} {primary}
 * @property DateRangeEmbeddable $date {embeddable} {primary}
 *

And DateRangeEmbeddable is like this:

/**
 * @property DateTimeImmutable $from
 * @property DateTimeImmutable $to
 */

I need to work with date ranges a lot, so it makes sense for me to store it in a special object (for type safety, constraints checks, …).

Thank you!

@hrach
Copy link
Member

hrach commented Oct 25, 2024

Ok, that's an important detail: the whole embeddable is part of the PK. Thx :)

@hrach
Copy link
Member

hrach commented Oct 28, 2024

@MartinLojda Could you please provide an example of how you (how do you want to) query such rows during getById() method?

@MartinLojda
Copy link
Author

I'm thinking about property->subproperty notation to be consistent with findBy conditions… Another posibility is array of subproperties, which might be more practical for my usecase, but i'm not really convinced it is a good way how to do it. Thank you!

@hrach hrach force-pushed the main branch 2 times, most recently from f382442 to e26db5f Compare December 18, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embeddable as part of composite primary key
2 participants