-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[db] fix the query for non-fga migrated users #19194
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ import { | |
MaybeUser, | ||
PartialUserUpdate, | ||
UserDB, | ||
isBuiltinUser, | ||
} from "../user-db"; | ||
import { DBGitpodToken } from "./entity/db-gitpod-token"; | ||
import { DBIdentity } from "./entity/db-identity"; | ||
|
@@ -662,16 +663,13 @@ export class TypeORMUserDBImpl extends TransactionalDBImpl<UserDB> implements Us | |
|
||
async findUserIdsNotYetMigratedToFgaVersion(fgaRelationshipsVersion: number, limit: number): Promise<string[]> { | ||
const userRepo = await this.getUserRepo(); | ||
const ids = (await userRepo | ||
const users = await userRepo | ||
.createQueryBuilder("user") | ||
.select(["id"]) | ||
.where({ | ||
fgaRelationshipsVersion: Not(Equal(fgaRelationshipsVersion)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @svenefftinge Can you share some insight into what's not working here, e.g. how the resulting query looks like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, I wrote a test and verified it failed and then used the pattern we use in other queries as well to make the test pass. |
||
markedDeleted: Equal(false), | ||
}) | ||
.where("fgaRelationshipsVersion != :fgaRelationshipsVersion", { fgaRelationshipsVersion }) | ||
.andWhere("markedDeleted != true") | ||
.orderBy("_lastModified", "DESC") | ||
.limit(limit) | ||
.getMany()) as Pick<DBUser, "id">[]; | ||
return ids.map(({ id }) => id); | ||
.getMany(); | ||
return users.map((user) => user.id).filter((id) => !isBuiltinUser(id)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should be able to keep the select to reduce the amount of bytes shuffled around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@svenefftinge I tried, and it's indeed this line that fails the method,
.select(["user.id"])
works. 🙄 So this is different to other querybuilder methods, which does not auto-namespace it's argument. And also, MySQL happily executes and retunrs and empty result... 🙈