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

Doesnt work inside QueryBuilder #41

Closed
arcziby opened this issue Jul 29, 2021 · 4 comments
Closed

Doesnt work inside QueryBuilder #41

arcziby opened this issue Jul 29, 2021 · 4 comments

Comments

@arcziby
Copy link

arcziby commented Jul 29, 2021

It doesn't work when i want to get value by QueryBuilder

this.userRepository
      .createQueryBuilder('user')
      .where('user.email = :email', { email })
      .getOne();
  @Column({
    type: 'varchar',
    nullable: false,
    transformer: new EncryptionTransformer({
      key: 'e41c966f21f9e1577802463f8924e6a3fe3e9751f201304213b2f845d8841d61',
      algorithm: 'aes-256-cbc',
      ivLength: 16,
      iv: 'ff5ac19190424b1d88f9419ef949ae56',
    }),
  })
  email: string;
@generalpiston
Copy link
Owner

I just wrote a test case for this and it appears to work: https://app.circleci.com/pipelines/github/generalpiston/typeorm-encrypted/28/workflows/9d036039-a719-42c8-bf81-fc06d012107a/jobs/55.

What does your data look like? How are you adding records?

Take a peek at the test cases to see examples of how to use this library: https://github.com/generalpiston/typeorm-encrypted/tree/c3119c043a9b4d1796544196b397d5f1ed4f6488/test

@arcziby
Copy link
Author

arcziby commented Jul 29, 2021

Could you please write test case where you select data with conditional where and pass simple (no encrypted) value, for example i have encrypted emails in database but i'd like select user by email SELECT user WHERE user.email = 'a@a.eu'

@generalpiston
Copy link
Owner

Ahh... I see... I don't think we can handle that case. Unfortunately, typeorm lets you use transformers for storing and fetching columns, but not filtering (or other more complicated SQL).

See https://github.com/generalpiston/typeorm-encrypted/#why-wont-complex-queries-work.

Sorry man :(

@arcziby
Copy link
Author

arcziby commented Jul 30, 2021

ok, so maybe you can add new tool for encrypt some value and later i just const encryptedemail = encrypt(email); SELECT user WHERE user.email = encryptedemail

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

No branches or pull requests

2 participants