Skip to content

Foreign Key is Null #763

@yulric

Description

@yulric

Hi there,
I'm trying to debug an issue in my application where the foreign key field for a row is being set to null when the parent object is being saved. The models are very complex so it's hard to create a test case but essentially they look like this,

class ParentEntity {
    childEntitites: Array<ChildEntity>
}

class ChildEntity {
    parentEntity: ParentEntity
}

Assume that all the relevant decorators have been set and it's a ManyToOne relationship. There are no cascade options set on the Parent and Child entities. When I save the ParentEntity the parentEntity field gets set to null.

It looks like this line of code,
https://github.com/typeorm/typeorm/blob/0.0.11/src/persistence/SubjectOperationExecutor.ts#L734

is what's doing it. Would you know why?

Thanks

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