Skip to content

State options do not support subresource with one-to-many relation #7812

@Kyzegs

Description

@Kyzegs

Description
I am trying to create a subresource operation that looks as follows:

new Post(
    uriTemplate: '/users/{userId}/attendances',
    uriVariables: [
        'userId' => new Link(
            toProperty: 'user',
            fromClass: UserEntity::class,
        ),
    ],
    input: CreateAttendanceDto::class,
    processor: AttendancePostProcessor::class,
    stateOptions: new Options(entityClass: AttendanceEntity::class)
),

The issue that I'm running into is that my user can have many attendances. Calling the endpoint will result in the database querying for ANY attendance belonging to the user ID provided. This results in always getting the same attendance entity back if one already exists for that user. Basically eliminating what a POST endpoint should do (create a new object).

I am not too sure if this is behaviour that was implemented intentionally or a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions