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

teableio / teable / 8419847094

25 Mar 2024 12:12PM UTC coverage: 26.087% (-53.9%) from 79.94%
8419847094

push

github

web-flow
chore: husky to v9 and upgrade more deps (#494)

2100 of 3363 branches covered (62.44%)

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!
8
  protected columnName: string;
×
9

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

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

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

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

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

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

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

×
43
  protected createSqlPlaceholders(values: unknown[]): string {
×
44
    return values.map(() => '?').join(',');
×
45
  }
×
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