• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 8389227144

22 Mar 2024 10:56AM UTC coverage: 26.087% (-53.9%) from 79.937%
8389227144

push

github

web-flow
refactor: move zod schema to openapi (#487)

2100 of 3363 branches covered (62.44%)

282 of 757 new or added lines in 74 files covered. (37.25%)

14879 existing lines in 182 files now uncovered.

25574 of 98035 relevant lines covered (26.09%)

5.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.22
/apps/nestjs-backend/src/db-provider/sort-query/function/sort-function.abstract.ts
1
import { InternalServerErrorException } from '@nestjs/common';
1✔
2
import { SortFunc } from '@teable/core';
1✔
3
import type { Knex } from 'knex';
1✔
4
import type { IFieldInstance } from '../../../features/field/model/factory';
1✔
5
import type { ISortFunctionInterface } from './sort-function.interface';
1✔
6

1✔
7
export abstract class AbstractSortFunction implements ISortFunctionInterface {
1!
UNCOV
8
  protected columnName: string;
×
UNCOV
9

×
UNCOV
10
  constructor(
×
UNCOV
11
    protected readonly knex: Knex,
×
UNCOV
12
    protected readonly field: IFieldInstance
×
UNCOV
13
  ) {
×
UNCOV
14
    const { dbFieldName } = this.field;
×
UNCOV
15

×
UNCOV
16
    this.columnName = dbFieldName;
×
UNCOV
17
  }
×
UNCOV
18

×
UNCOV
19
  compiler(builderClient: Knex.QueryBuilder, sortFunc: SortFunc) {
×
UNCOV
20
    const functionHandlers = {
×
UNCOV
21
      [SortFunc.Asc]: this.asc,
×
UNCOV
22
      [SortFunc.Desc]: this.desc,
×
UNCOV
23
    };
×
UNCOV
24
    const chosenHandler = functionHandlers[sortFunc].bind(this);
×
UNCOV
25

×
UNCOV
26
    if (!chosenHandler) {
×
27
      throw new InternalServerErrorException(`Unknown function ${sortFunc} for sort`);
×
28
    }
×
UNCOV
29

×
UNCOV
30
    return chosenHandler(builderClient);
×
UNCOV
31
  }
×
UNCOV
32

×
UNCOV
33
  asc(builderClient: Knex.QueryBuilder): Knex.QueryBuilder {
×
UNCOV
34
    builderClient.orderByRaw(`?? ASC NULLS FIRST`, [this.columnName]);
×
UNCOV
35
    return builderClient;
×
UNCOV
36
  }
×
UNCOV
37

×
UNCOV
38
  desc(builderClient: Knex.QueryBuilder): Knex.QueryBuilder {
×
UNCOV
39
    builderClient.orderByRaw(`?? DESC NULLS LAST`, [this.columnName]);
×
UNCOV
40
    return builderClient;
×
UNCOV
41
  }
×
UNCOV
42

×
UNCOV
43
  protected createSqlPlaceholders(values: unknown[]): string {
×
UNCOV
44
    return values.map(() => '?').join(',');
×
UNCOV
45
  }
×
UNCOV
46
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc