Skip to content

Column with transformer is not normalized for update #2703

@andreasrueedlinger

Description

@andreasrueedlinger

Issue type:

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

Database system/driver:

[x] all

TypeORM version:

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

Steps to reproduce or a small repository showing the problem:
If you add a transformer to a column which serializes the property value to the desired format, this transformation is not considered in SubjectChangedColumnsComputer and the column is always marked as changed if you are working with a complex object type for the column which is serialized to string for example.

export interface MyComplexType {
  foo: string;
  bar: number;
  xy: Date;
}

export const myTransformer: ValueTransformer = {
  from: dbValue => {
    const parsed = (dbValue || '').split(',');
    return { foo: parsed[0], bar: +parsed[1] || undefined };
  },
  to: entityValue => `${entityValue.foo},${entityValue.bar}`
};

@Entity('foo')
export class Foo {
  @PrimaryGeneratedColumn({ type: 'int' })
  readonly id: number;

  @Column('text', { transformer: myTransformer })
  transformed: MyComplexType;
}

Why is column.getEntityValue() not called with the transform flag to true in computeDiffColumns of SubjectChangedColumnsComputer?

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