Entity references, indexes and constraints #85

Merged
c.fahner merged 23 commits from issues/5 into main 2026-10-19 16:13:59 +02:00
Owner

Resolves #5

Adds relationships between entities (in the form of Reference constraints)
Adds custom primary fields for non-entities
Adds class- and field-level indexes
Adds class- and field-level unique constraints
Adds invariant constraints
Adds auto-expiring documents
Removes field renaming

Resolves #5 Adds relationships between entities (in the form of Reference constraints) Adds custom primary fields for non-entities Adds class- and field-level indexes Adds class- and field-level unique constraints Adds invariant constraints Adds auto-expiring documents Removes field renaming
c.fahner added this to the v0.2 milestone 2026-10-02 19:05:39 +02:00
c.fahner changed title from WIP: Entity references, indexes and constraints to Entity references, indexes and constraints 2026-10-10 20:36:55 +02:00
src/Schema.php Outdated
@ -19,0 +49,4 @@
*
* Adding the {@see Schema\Constraint\Reference} attribute to a class directly allows creating more
* complex relationships.
* To override the default options for a single field use the {@see Field\Reference} attribute.
Author
Owner

{@see Schema\Field\Reference} (the Field class is not imported directly)

`{@see Schema\Field\Reference}` (the `Field` class is not imported directly)
c.fahner marked this conversation as resolved
@ -0,0 +11,4 @@
*
* Constraints are declared at the top of the class for which to generate a schema.
* You can also declare a single field as unique using the field-specific {@see Field\Unique} attribute.
* Declaring a single field as unique will automatically add it as a constraint of the entire schema.
Author
Owner

"... of to the entire schema."

"... ~~of~~ to the entire schema."
c.fahner marked this conversation as resolved
@ -0,0 +20,4 @@
*
* ```php
* #[Schema\Constraint\Unique([ 'category', 'position' ])]
* #[Schema\Constraint\Invariant(static fn() => new Predicate\GreaterThan(new FieldPath([ 'price' ]), 0))]
Author
Owner

Invalid syntax, function() { } has to be written in full (or replace with a const)

Invalid syntax, `function() { }` has to be written in full (or replace with a const)
c.fahner marked this conversation as resolved
c.fahner stopped working 2026-10-19 07:16:01 +02:00
28 minutes 15 seconds
@ -0,0 +8,4 @@
use Slendium\Ocd\Schema\Constraint\ConstraintAction;
/**
* Contains overrides for the options of an implied field reference.
Author
Owner

"Overrides the default options of an implied field reference."

"Overrides the default options of an implied field reference."
c.fahner marked this conversation as resolved
@ -0,0 +21,4 @@
use MarkerAttribute;
/**
* @param ReflectionClass<object> $reflector
Author
Owner

Missing @internal

Missing `@internal`
c.fahner marked this conversation as resolved
@ -0,0 +40,4 @@
throw DefinitionException::forTooManyTypes($parameter);
}
return ($typeAttrs[0] ?? null)?->newInstance()
Author
Owner

Directly use ternary?: isset(...) ? ...->newInstance() : getImplied

Directly use ternary?: `isset(...) ? ...->newInstance() : getImplied`
c.fahner marked this conversation as resolved
c.fahner stopped working 2026-10-19 15:25:57 +02:00
17 minutes 44 seconds
c.fahner stopped working 2026-10-19 15:58:08 +02:00
12 minutes 35 seconds
c.fahner stopped working 2026-10-19 16:13:59 +02:00
15 minutes 40 seconds
c.fahner deleted branch issues/5 2026-10-19 16:13:59 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 1 hour 14 minutes
c.fahner
1 hour 14 minutes
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
slendium/ocd!85
No description provided.