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

Upgrade Nest.js and related dependencies #602

Closed
maurizi opened this issue Mar 3, 2021 · 1 comment · Fixed by #637
Closed

Upgrade Nest.js and related dependencies #602

maurizi opened this issue Mar 3, 2021 · 1 comment · Fixed by #637
Assignees

Comments

@maurizi
Copy link
Contributor

maurizi commented Mar 3, 2021

No description provided.

@pcaisse
Copy link
Contributor

pcaisse commented Mar 4, 2021

We are motivated to upgrade TypeORM in particular due to this nasty bug (intended behavior?) where if you filter on a non-existent field using it would just remove the WHERE clause entirely and not throw an error, including on updates/deletes: typeorm/typeorm#3416

For a minimal example, copy/paste this into a file at src/manage/src/commands/test-where-clause-bug.ts:

import { Command } from "@oclif/command";
import { createConnection } from "typeorm";

import { User } from "../../../server/src/users/entities/user.entity";
import { connectionOptions } from "../lib/dbUtils";

export default class TestWhereClauseBug extends Command {
  async run(): Promise<void> {
    const connection = await createConnection(connectionOptions);
    const userRepo = connection.getRepository(User);

    /* tslint:disable:no-object-mutation */
    const result = await userRepo.find({ userId: "07f9966f-facf-42ce-a4ee-48320007f1cc" }); // actual field name is `id`
    this.log("result", result);
  }
}

Then run

$ ./scripts/manage test-where-clause-bug

and you will see all users listed like so:

Creating district-builder-2_manage_run ... done
Version 9 of Highlight.js has reached EOL and is no longer supported.
Please upgrade or ask whatever dependency you are using to upgrade.
https://github.com/highlightjs/highlight.js/issues/2877
query: SELECT "User"."id" AS "User_id", "User"."email" AS "User_email", "User"."name" AS "User_name", "User"."isEmailVerified" AS "User_isEmailVerified", "User"."hasSeenTour" AS "User_hasSeenTour", "User"."passwordHash" AS "User_passwordHash" FROM "user" "User"
result [
  User {
    id: '07f9966f-facf-42ce-a4ee-48320007f1cc',
    email: 'pcaisse@azavea.com',
    name: 'Peter Caisse',
    isEmailVerified: false,
    hasSeenTour: true,
    passwordHash: '$2b$10$LE5K5Zm9AJdAPIuBppEo6eEsBQB8XMZ6v1mbvoCYF3ylfqxI39mJi'
  },
  User {
    id: '5cccbc68-06a7-4b6e-a05f-732063bc81fa',
    email: 'test@azavea.com',
    name: 'Test User',
    isEmailVerified: false,
    hasSeenTour: false,
    passwordHash: '$2b$10$sh8AB9Ei3o9NUJXxXAEYxesxO48N5cs1lar3AOuEXH28Zno0uNCb2'
  }
]

Thus if we did userRepo.delete({ userId: "07f9966f-facf-42ce-a4ee-48320007f1cc" }) we would silently delete all of our users...

@pcaisse pcaisse self-assigned this Mar 18, 2021
@pcaisse pcaisse mentioned this issue Mar 19, 2021
1 task
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 a pull request may close this issue.

2 participants