diff --git a/tdrive/backend/node/src/services/documents/services/index.ts b/tdrive/backend/node/src/services/documents/services/index.ts index d24e0f920..364052ca9 100644 --- a/tdrive/backend/node/src/services/documents/services/index.ts +++ b/tdrive/backend/node/src/services/documents/services/index.ts @@ -59,8 +59,6 @@ import archiver from "archiver"; import internal from "stream"; import config from "config"; import { randomUUID } from "crypto"; -import { MultipartFile } from "@fastify/multipart"; -import { UploadOptions } from "../../files/types"; export class DocumentsService { version: "1"; diff --git a/tdrive/backend/node/test/unit/core/services/database/services/orm/connectors/postgres/postgres-query-builder.test.ts b/tdrive/backend/node/test/unit/core/services/database/services/orm/connectors/postgres/postgres-query-builder.test.ts index f72824cb3..6380a351d 100644 --- a/tdrive/backend/node/test/unit/core/services/database/services/orm/connectors/postgres/postgres-query-builder.test.ts +++ b/tdrive/backend/node/test/unit/core/services/database/services/orm/connectors/postgres/postgres-query-builder.test.ts @@ -131,26 +131,43 @@ describe('The PostgresQueryBuilder', () => { const entity = newTestDbEntity(); const newValue = "new-tag-value"; - const [queryText, params] = subj.buildatomicCompareAndSet(entity, "tags", null, newValue); + const queries = subj.buildatomicCompareAndSet(entity, "tags", null, newValue); + let queryText, params; - expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags = $4 RETURNING tags`); + [queryText, params] = queries.updateQuery; + expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags IS NULL`); expect(params[0]).toBe(JSON.stringify(newValue)); expect(params[1]).toBe(entity.company_id); expect(params[2]).toBe(entity.id); - expect(params[3]).toBe(null); + expect(params.length).toBe(3); + + [queryText, params] = queries.getValueQuery; + expect(normalizeWhitespace(queryText as string)).toBe(`SELECT "tags" FROM "test_table" WHERE company_id = $1 AND id = $2`); + expect(params[0]).toBe(entity.company_id); + expect(params[1]).toBe(entity.id); + expect(params.length).toBe(2); }); test('buildatomicCompareAndSet to null', async () => { const entity = newTestDbEntity(); const previousValue = "new-tag-value"; - const [queryText, params] = subj.buildatomicCompareAndSet(entity, "tags", previousValue, null); + const queries = subj.buildatomicCompareAndSet(entity, "tags", previousValue, null); + let queryText, params; - expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags = $4 RETURNING tags`); + [queryText, params] = queries.updateQuery; + expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags = $4`); expect(params[0]).toBe(null); expect(params[1]).toBe(entity.company_id); expect(params[2]).toBe(entity.id); expect(params[3]).toBe(JSON.stringify(previousValue)); + expect(params.length).toBe(4); + + [queryText, params] = queries.getValueQuery; + expect(normalizeWhitespace(queryText as string)).toBe(`SELECT "tags" FROM "test_table" WHERE company_id = $1 AND id = $2`); + expect(params[0]).toBe(entity.company_id); + expect(params[1]).toBe(entity.id); + expect(params.length).toBe(2); }); const assertInsertQueryParams = (actual: TestDbEntity, expected: any[]) => {