orm icon indicating copy to clipboard operation
orm copied to clipboard

Embeddable as part of composite primary key

Open MartinLojda opened this issue 1 year ago • 8 comments

First attemp of fixing issue #575

MartinLojda avatar Oct 25 '24 11:10 MartinLojda

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

hrach avatar Oct 25 '24 11:10 hrach

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!

MartinLojda avatar Oct 25 '24 12:10 MartinLojda

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

hrach avatar Oct 25 '24 12:10 hrach

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

hrach avatar Oct 28 '24 15:10 hrach

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!

MartinLojda avatar Oct 29 '24 06:10 MartinLojda

Is there anything I can do to help for this MR to be merged into main and released? Thanks for the info ;-)

MartinLojda avatar Mar 19 '25 05:03 MartinLojda

Actually yes, I wanted to try out querying and add a test for it.

hrach avatar Mar 19 '25 07:03 hrach

Actually yes, I wanted to try out querying and add a test for it.

Can you be more specific? What can I do? Writing tests is not my strong suit, nevertheless…

MartinLojda avatar Apr 23 '25 11:04 MartinLojda