Skip to content

Repository save doesn't return autogenerated columns  #4090

@daniildxb

Description

@daniildxb

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[ ] latest
[x] @next
[ ] 0.x.x (or put your version here)

Hi, I've noticed that Repository.save doesn't return several of auto-generated field

Model Route.ts

@Entity({ name: 'routes' })
export class Route {
  @PrimaryGeneratedColumn()
  public id!: number;

  @Column({ nullable: true })
  public name!: string;

  @Column({ nullable: true })
  public description!: string;

  @Column({ nullable: true })
  public distance!: number;

  @Column({
    default: 'inactive',
    enum: ['active', 'not active', 'testing', 'checking'],
  })
  public status!: string;

  @Column({ nullable: true })
  public zoom!: number;

  @Column({ nullable: true, type: 'decimal' })
  public latitude!: number;

  @Column({ nullable: true, type: 'decimal' })
  public longitude!: number;

  @CreateDateColumn({ name: 'created_at' })
  public createdAt!: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  public updatedAt!: Date;

  @OneToMany(type => RouteLeg, routeLeg => routeLeg.route, { cascade: true })
  public legs!: RouteLeg[];

  @ManyToOne(type => Route, route => route.id)
  @JoinColumn({ name: 'source_id' })
  public source!: Route;
}

Method call
getRepository(Route).save(_);

For some reason id and createdAt are not returned while updatedAt is value is returned

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions