tonivj5/typeorm-naming-strategies

Duplicate underscore in oneToMany

Helveg opened this issue · 2 comments

Using an entity with a column like this:

  @ManyToOne(() => Degree, { nullable: true })
  @JoinColumn()
  parentDegree?: Degree;

yields the column name parent_degree__id instead of parent_degree_id

I suspect it could be because of the .concat('') in this line:

snakeCase(embeddedPrefixes.concat('').join('_')) +

since ['a'].concat('') results in ['a', '']; and then ['a', ''].join('_') results in 'a_'. So if like me you had {'prefix': 'a_'} the column name would end up 'a__id' not 'a_id'

Thanks. I will investigate