• 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

5.26
/src/schema-builder/view/View.ts
1
import {
2
    DataSource,
3
    Driver,
4
    EntityMetadata,
5
    SelectQueryBuilder,
6
    TableIndex,
7
} from "../.."
8
import { ViewOptions } from "../options/ViewOptions"
9

10
/**
11
 * View in the database represented in this class.
12
 */
13
export class View {
1✔
UNCOV
14
    readonly "@instanceof" = Symbol.for("View")
×
15

16
    // -------------------------------------------------------------------------
17
    // Public Properties
18
    // -------------------------------------------------------------------------
19

20
    /**
21
     * Database name that this view resides in if it applies.
22
     */
23
    database?: string
24

25
    /**
26
     * Schema name that this view resides in if it applies.
27
     */
28
    schema?: string
29

30
    /**
31
     * View name
32
     */
33
    name: string
34

35
    /**
36
     * Indicates if view is materialized.
37
     */
38
    materialized: boolean
39

40
    /**
41
     * View Indices
42
     */
43
    indices: TableIndex[]
44

45
    /**
46
     * View definition.
47
     */
48
    expression: string | ((connection: DataSource) => SelectQueryBuilder<any>)
49

50
    // -------------------------------------------------------------------------
51
    // Constructor
52
    // -------------------------------------------------------------------------
53

54
    constructor(options?: ViewOptions) {
UNCOV
55
        this.indices = []
×
UNCOV
56
        if (options) {
×
UNCOV
57
            this.database = options.database
×
UNCOV
58
            this.schema = options.schema
×
UNCOV
59
            this.name = options.name
×
UNCOV
60
            this.expression = options.expression
×
UNCOV
61
            this.materialized = !!options.materialized
×
62
        }
63
    }
64

65
    // -------------------------------------------------------------------------
66
    // Public Methods
67
    // -------------------------------------------------------------------------
68

69
    /**
70
     * Clones this table to a new table with all properties cloned.
71
     */
72
    clone(): View {
73
        return new View(<ViewOptions>{
×
74
            database: this.database,
75
            schema: this.schema,
76
            name: this.name,
77
            expression: this.expression,
78
            materialized: this.materialized,
79
        })
80
    }
81

82
    /**
83
     * Add index
84
     */
85
    addIndex(index: TableIndex): void {
UNCOV
86
        this.indices.push(index)
×
87
    }
88

89
    /**
90
     * Remove index
91
     */
92
    removeIndex(viewIndex: TableIndex): void {
UNCOV
93
        const index = this.indices.find(
×
UNCOV
94
            (index) => index.name === viewIndex.name,
×
95
        )
UNCOV
96
        if (index) {
×
UNCOV
97
            this.indices.splice(this.indices.indexOf(index), 1)
×
98
        }
99
    }
100

101
    // -------------------------------------------------------------------------
102
    // Static Methods
103
    // -------------------------------------------------------------------------
104

105
    /**
106
     * Creates view from a given entity metadata.
107
     */
108
    static create(entityMetadata: EntityMetadata, driver: Driver): View {
UNCOV
109
        const options: ViewOptions = {
×
110
            database: entityMetadata.database,
111
            schema: entityMetadata.schema,
112
            name: driver.buildTableName(
113
                entityMetadata.tableName,
114
                entityMetadata.schema,
115
                entityMetadata.database,
116
            ),
117
            expression: entityMetadata.expression!,
118
            materialized: entityMetadata.tableMetadataArgs.materialized,
119
        }
120

UNCOV
121
        return new View(options)
×
122
    }
123
}
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