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

fix: stop column transformers from modifying where #10847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hanssen0
Copy link

Description of change

This change stops column transformers from modifying the original where criteria.

@Entity()
export class Job {
  @Column({
    type: "varchar",
    transformer: {
      from: (raw: string): Date => new Date(raw),
      to: (date: Date): string => date.toISOString(),
    },
  })
  submittedAt: Date;
}

// ...

const criteria = {
  submittedAt: MoreThanOrEqual(sinceTime),
};

await jobRepo.findBy(criteria);
await jobRepo.findBy(criteria);

The FindOperator within the where was changed during the first findBy, causing the second query to fail by trying to transform a transformed value.

This PR tries to fix this problem.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • I want to keep files that I didn't touch.
  • npm run test passes with this change
  • They failed but were not related to this change.
  • This pull request links relevant issues as Fixes #0000 N/A
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

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

1 participant