Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better entity values comparison on save #4769

Merged
merged 1 commit into from Oct 18, 2019
Merged

better entity values comparison on save #4769

merged 1 commit into from Oct 18, 2019

Conversation

silentroach
Copy link
Contributor

@silentroach silentroach commented Sep 18, 2019

@Entity()
export class Post {
    @PrimaryGeneratedColumn()
    id: number;
    @Column({ name: "dt", type: "timestamp with time zone" })  // <-- type is important here
    date: Date;
}

const post = new Post();
post.id = 1;
post.date = new Date();
await postRepository.save(post);       // <-- first save, it is ok

const loadedPost = await postRepository.findOneOrFail(1);
await postRepository.save(loadedPost); // <-- was not changed, 
                                       // but typeorm will update the record with the same date

Entity property with column type "timestamp with time zone" value is always different for TypeORM on save.

Seems like you forget to normalize these values on value comparison function.

@silentroach silentroach changed the title better timestamp comparison better entity values comparison on save Sep 18, 2019
@pleerock
Copy link
Member

Thanks for waiting @silentroach. I'll merge this change since Im releasing a new version today, however this functionality needs a tests, you know it =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants