typeorm: [Bug] UpdateById broken due to wrong operation?

So here’s the entity code:

@Entity('MON_CONTROL_PLACE', {
  orderBy: {
    name: 'ASC',
    id: 'DESC',
  },
} as any)
export class ControlPlace {
  @PrimaryGeneratedColumn({
    // name: 'MON_CONTROL_PLACE_ID',
  })
  id: number

  @Column({
    nullable: false,
    unique: true,
  })
  name: string

  // Relations
  @OneToMany(
    (type) => RouteLine,
    (routeLine) => routeLine.controlPlace,
  )
  routeLines: Promise<RouteLine[]>

  @CreateDateColumn()
  createdAt: Date

  @UpdateDateColumn()
  updatedAt: Date

  @VersionColumn()
  version: number
}

Here’s the relation code:

@Entity('MON_ROUTE_LINE', {
  orderBy: {
    id: 'DESC',
  },
} as any)
export class RouteLine {
  @PrimaryGeneratedColumn({
    name: 'MON_ROUTE_LINE_ID',
  })
  id: number

  @Column('real', {
    default: 0,
  })
  kms: number

  @Column('time without time zone', {
    nullable: false,
  })
  horas: Date

  // Relations
  @ManyToOne(
    (type) => Route,
    (route) => route.routeLines,
    { nullable: false },
  )
  @JoinColumn({
    // name: 'MON_ROUTE_ID',
  })
  route: Promise<Route>

  @ManyToOne(
    (type) => ControlPlace,
    (controlPlace) => controlPlace.routeLines,
    { nullable: false },
  )
  @JoinColumn({
    // name: 'MON_CONTROL_PLACE_ID',
  })
  controlPlace: Promise<ControlPlace>

  @CreateDateColumn()
  createdAt: Date

  @UpdateDateColumn()
  updatedAt: Date

  @VersionColumn()
  version: number
}

And here’s the error: image

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (15 by maintainers)

Commits related to this issue

Most upvoted comments

For some reason it says that certain relation cannot be null, which in theory should already have a value in database since is an update, seems like if i don’t extract the id out of data then it doesn’t take it as a partial.