mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) upgrade typeorm so we can support newer postgres
Summary: upgrade typeorm version, so Grist can run against newer versions of postgres. Dusted off some old benchmarking code to verify that important queries don't get slower. They don't appear to, unlike for some intermediate versions of typeorm I tried in the past. Most of the changes are because `findOne` changed how it interprets its arguments, and the value it returns when nothing is found. For the return value, I stuck with limiting its impact by emulating old behavior (returning undefined rather than null) rather than propagating the change out to parts of the code unrelated to the database. Test Plan: existing tests pass; manual testing with postgres 10 and 14 Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3613
This commit is contained in:
@@ -77,7 +77,7 @@ export function addOrg(
|
||||
}
|
||||
): Promise<number> {
|
||||
return dbManager.connection.transaction(async manager => {
|
||||
const user = await manager.findOne(User, userId);
|
||||
const user = await manager.findOne(User, {where: {id: userId}});
|
||||
if (!user) { return handleDeletedUser(); }
|
||||
const query = await dbManager.addOrg(user, props, {
|
||||
...options,
|
||||
@@ -411,7 +411,7 @@ export class ApiServer {
|
||||
// Get user's apiKey
|
||||
this._app.get('/api/profile/apikey', expressWrap(async (req, res) => {
|
||||
const userId = getUserId(req);
|
||||
const user = await User.findOne(userId);
|
||||
const user = await User.findOne({where: {id: userId}});
|
||||
if (user) {
|
||||
// The null value is of no interest to the user, let's show empty string instead.
|
||||
res.send(user.apiKey || '');
|
||||
@@ -426,7 +426,7 @@ export class ApiServer {
|
||||
const userId = getAuthorizedUserId(req);
|
||||
const force = req.body ? req.body.force : false;
|
||||
const manager = this._dbManager.connection.manager;
|
||||
let user = await manager.findOne(User, userId);
|
||||
let user = await manager.findOne(User, {where: {id: userId}});
|
||||
if (!user) { return handleDeletedUser(); }
|
||||
if (!user.apiKey || force) {
|
||||
user = await updateApiKeyWithRetry(manager, user);
|
||||
@@ -441,7 +441,7 @@ export class ApiServer {
|
||||
this._app.delete('/api/profile/apikey', expressWrap(async (req, res) => {
|
||||
const userId = getAuthorizedUserId(req);
|
||||
await this._dbManager.connection.transaction(async manager => {
|
||||
const user = await manager.findOne(User, userId);
|
||||
const user = await manager.findOne(User, {where: {id: userId}});
|
||||
if (!user) { return handleDeletedUser(); }
|
||||
user.apiKey = null;
|
||||
await manager.save(User, user);
|
||||
|
||||
Reference in New Issue
Block a user