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

teableio / teable / 21312312825

24 Jan 2026 08:37AM UTC coverage: 64.368% (-0.01%) from 64.381%
21312312825

push

github

web-flow
[sync] fix: boolean formula aggregation and Sentry/OTEL crash (T1613, T1766) (#1107) (#2480)

Synced from teableio/teable-ee@16cf738

Co-authored-by: teable-bot <bot@teable.io>

4741 of 6143 branches covered (77.18%)

6 of 18 new or added lines in 6 files covered. (33.33%)

3 existing lines in 2 files now uncovered.

21876 of 33986 relevant lines covered (64.37%)

5415.3 hits per line

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

0.0
/apps/nestjs-backend/src/db-provider/aggregation-query/sqlite/aggregation-function.sqlite.ts
1
import { NotImplementedException } from '@nestjs/common';
2
import { FieldType } from '@teable/core';
3
import { AbstractAggregationFunction } from '../aggregation-function.abstract';
4

5
export class AggregationFunctionSqlite extends AbstractAggregationFunction {
6
  unique(): string {
7
    const { type, isMultipleCellValue } = this.field;
×
8
    if (
×
9
      ![FieldType.User, FieldType.CreatedBy, FieldType.LastModifiedBy].includes(type) ||
10
      isMultipleCellValue
11
    ) {
12
      return super.unique();
×
13
    }
14

15
    return this.knex.raw(`COUNT(DISTINCT json_extract(${this.tableColumnRef}, '$.id'))`).toQuery();
×
16
  }
17

18
  percentUnique(): string {
19
    const { type, isMultipleCellValue } = this.field;
×
20
    if (
×
21
      ![FieldType.User, FieldType.CreatedBy, FieldType.LastModifiedBy].includes(type) ||
22
      isMultipleCellValue
23
    ) {
24
      return this.knex
×
25
        .raw(`(COUNT(DISTINCT ${this.tableColumnRef}) * 1.0 / MAX(COUNT(*), 1)) * 100`)
26
        .toQuery();
27
    }
28

29
    return this.knex
×
30
      .raw(
31
        `(COUNT(DISTINCT json_extract(${this.tableColumnRef}, '$.id')) * 1.0 / MAX(COUNT(*), 1)) * 100`
32
      )
33
      .toQuery();
34
  }
35
  dateRangeOfDays(): string {
36
    throw new NotImplementedException();
×
37
  }
38

39
  dateRangeOfMonths(): string {
40
    throw new NotImplementedException();
×
41
  }
42

43
  totalAttachmentSize(): string {
44
    // Sum sizes per row, then sum across the current scope (respects GROUP BY)
45
    return this.knex
×
46
      .raw(
47
        `SUM(COALESCE((SELECT SUM(json_extract(j.value, '$.size'))
48
          FROM json_each(COALESCE(${this.tableColumnRef}, '[]')) AS j), 0))`
49
      )
50
      .toQuery();
51
  }
52

53
  percentEmpty(): string {
54
    return this.knex
×
55
      .raw(`((COUNT(*) - COUNT(${this.tableColumnRef})) * 1.0 / MAX(COUNT(*), 1)) * 100`)
56
      .toQuery();
57
  }
58

59
  percentFilled(): string {
60
    return this.knex
×
61
      .raw(`(COUNT(${this.tableColumnRef}) * 1.0 / MAX(COUNT(*), 1)) * 100`)
62
      .toQuery();
63
  }
64

65
  checked(): string {
NEW
66
    return this.knex.raw(`SUM(CASE WHEN ${this.tableColumnRef} = 1 THEN 1 ELSE 0 END)`).toQuery();
×
67
  }
68

69
  unChecked(): string {
NEW
70
    return this.knex
×
71
      .raw(
72
        `SUM(CASE WHEN ${this.tableColumnRef} = 0 OR ${this.tableColumnRef} IS NULL THEN 1 ELSE 0 END)`
73
      )
74
      .toQuery();
75
  }
76

77
  percentChecked(): string {
NEW
78
    return this.knex
×
79
      .raw(
80
        `(SUM(CASE WHEN ${this.tableColumnRef} = 1 THEN 1 ELSE 0 END) * 1.0 / MAX(COUNT(*), 1)) * 100`
81
      )
82
      .toQuery();
83
  }
84

85
  percentUnChecked(): string {
NEW
86
    return this.knex
×
87
      .raw(
88
        `(SUM(CASE WHEN ${this.tableColumnRef} = 0 OR ${this.tableColumnRef} IS NULL THEN 1 ELSE 0 END) * 1.0 / MAX(COUNT(*), 1)) * 100`
89
      )
90
      .toQuery();
91
  }
92
}
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