tempest-framework
tempest-framework copied to clipboard
Optional ids in ORM
The model query builders currently assume there's always an Id field on model classes. This assumption should be made optional, because Ids aren't actually required by the database
Yes, thank you. This assumption also discarded the fact that many RDBMS support compound primary keys.
The framework may still need to make the id "assumption" somehow for tracking relationships and whatnot if not specified otherwise.
I propose we add a Key and/or PrimaryKey attributes. One for the class, which would allow specifying compound primary keys and one if you just want to specify it directly on the property.
Something like:
#[PrimaryKey(['license_plate', 'state'])]
final class Car
{
public string $licensePlate;
public string $state;
public string $make;
//...
}
or
final class Book
{
#[Key]
public string $uuid;
public string $title;
//...
}