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

typeorm / typeorm / 15219332477

23 May 2025 09:13PM UTC coverage: 17.216% (-59.1%) from 76.346%
15219332477

Pull #11332

github

naorpeled
cr comments - move if block
Pull Request #11332: feat: add new undefined and null behavior flags

1603 of 12759 branches covered (12.56%)

Branch coverage included in aggregate %.

0 of 31 new or added lines in 3 files covered. (0.0%)

14132 existing lines in 166 files now uncovered.

4731 of 24033 relevant lines covered (19.69%)

60.22 hits per line

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

82.35
/src/schema-builder/table/TableIndex.ts
1
import { IndexMetadata } from "../../metadata/IndexMetadata"
2
import { TableIndexOptions } from "../options/TableIndexOptions"
3

4
/**
5
 * Database's table index stored in this class.
6
 */
7
export class TableIndex {
1✔
8
    readonly "@instanceof" = Symbol.for("TableIndex")
3✔
9

10
    // -------------------------------------------------------------------------
11
    // Public Properties
12
    // -------------------------------------------------------------------------
13

14
    /**
15
     * Index name.
16
     */
17
    name?: string
18

19
    /**
20
     * Columns included in this index.
21
     */
22
    columnNames: string[] = []
3✔
23

24
    /**
25
     * Indicates if this index is unique.
26
     */
27
    isUnique: boolean
28

29
    /**
30
     * The SPATIAL modifier indexes the entire column and does not allow indexed columns to contain NULL values.
31
     * Works only in MySQL.
32
     */
33
    isSpatial: boolean
34

35
    /**
36
     * Create the index using the CONCURRENTLY modifier
37
     * Works only in postgres.
38
     */
39
    isConcurrent: boolean
40

41
    /**
42
     * The FULLTEXT modifier indexes the entire column and does not allow prefixing.
43
     * Works only in MySQL.
44
     */
45
    isFulltext: boolean
46

47
    /**
48
     * NULL_FILTERED indexes are particularly useful for indexing sparse columns, where most rows contain a NULL value.
49
     * In these cases, the NULL_FILTERED index can be considerably smaller and more efficient to maintain than
50
     * a normal index that includes NULL values.
51
     *
52
     * Works only in Spanner.
53
     */
54
    isNullFiltered: boolean
55

56
    /**
57
     * Fulltext parser.
58
     * Works only in MySQL.
59
     */
60
    parser?: string
61

62
    /**
63
     * Index filter condition.
64
     */
65
    where: string
66

67
    // -------------------------------------------------------------------------
68
    // Constructor
69
    // -------------------------------------------------------------------------
70

71
    constructor(options: TableIndexOptions) {
72
        this.name = options.name
3✔
73
        this.columnNames = options.columnNames
3✔
74
        this.isUnique = !!options.isUnique
3✔
75
        this.isSpatial = !!options.isSpatial
3✔
76
        this.isConcurrent = !!options.isConcurrent
3✔
77
        this.isFulltext = !!options.isFulltext
3✔
78
        this.isNullFiltered = !!options.isNullFiltered
3✔
79
        this.parser = options.parser
3✔
80
        this.where = options.where ? options.where : ""
3!
81
    }
82

83
    // -------------------------------------------------------------------------
84
    // Public Methods
85
    // -------------------------------------------------------------------------
86

87
    /**
88
     * Creates a new copy of this index with exactly same properties.
89
     */
90
    clone(): TableIndex {
91
        return new TableIndex(<TableIndexOptions>{
1✔
92
            name: this.name,
93
            columnNames: [...this.columnNames],
94
            isUnique: this.isUnique,
95
            isSpatial: this.isSpatial,
96
            isConcurrent: this.isConcurrent,
97
            isFulltext: this.isFulltext,
98
            isNullFiltered: this.isNullFiltered,
99
            parser: this.parser,
100
            where: this.where,
101
        })
102
    }
103

104
    // -------------------------------------------------------------------------
105
    // Static Methods
106
    // -------------------------------------------------------------------------
107

108
    /**
109
     * Creates index from the index metadata object.
110
     */
111
    static create(indexMetadata: IndexMetadata): TableIndex {
UNCOV
112
        return new TableIndex(<TableIndexOptions>{
×
113
            name: indexMetadata.name,
114
            columnNames: indexMetadata.columns.map(
UNCOV
115
                (column) => column.databaseName,
×
116
            ),
117
            isUnique: indexMetadata.isUnique,
118
            isSpatial: indexMetadata.isSpatial,
119
            isConcurrent: indexMetadata.isConcurrent,
120
            isFulltext: indexMetadata.isFulltext,
121
            isNullFiltered: indexMetadata.isNullFiltered,
122
            parser: indexMetadata.parser,
123
            where: indexMetadata.where,
124
        })
125
    }
126
}
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

© 2025 Coveralls, Inc