• 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

6.67
/src/schema-builder/table/TableForeignKey.ts
1
import { ForeignKeyMetadata } from "../../metadata/ForeignKeyMetadata"
2
import { TableForeignKeyOptions } from "../options/TableForeignKeyOptions"
3
import { Driver } from "../../driver/Driver"
4

5
/**
6
 * Foreign key from the database stored in this class.
7
 */
8
export class TableForeignKey {
1✔
UNCOV
9
    readonly "@instanceof" = Symbol.for("TableForeignKey")
×
10

11
    // -------------------------------------------------------------------------
12
    // Public Properties
13
    // -------------------------------------------------------------------------
14

15
    /**
16
     * Name of the foreign key constraint.
17
     */
18
    name?: string
19

20
    /**
21
     * Column names which included by this foreign key.
22
     */
UNCOV
23
    columnNames: string[] = []
×
24

25
    /**
26
     * Database of Table referenced in the foreign key.
27
     */
28
    referencedDatabase?: string
29

30
    /**
31
     * Database of Table referenced in the foreign key.
32
     */
33
    referencedSchema?: string
34

35
    /**
36
     * Table referenced in the foreign key.
37
     */
38
    referencedTableName: string
39

40
    /**
41
     * Column names which included by this foreign key.
42
     */
UNCOV
43
    referencedColumnNames: string[] = []
×
44

45
    /**
46
     * "ON DELETE" of this foreign key, e.g. what action database should perform when
47
     * referenced stuff is being deleted.
48
     */
49
    onDelete?: string
50

51
    /**
52
     * "ON UPDATE" of this foreign key, e.g. what action database should perform when
53
     * referenced stuff is being updated.
54
     */
55
    onUpdate?: string
56

57
    /**
58
     * Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
59
     * or at the end of a transaction
60
     */
61
    deferrable?: string
62

63
    // -------------------------------------------------------------------------
64
    // Constructor
65
    // -------------------------------------------------------------------------
66

67
    constructor(options: TableForeignKeyOptions) {
UNCOV
68
        this.name = options.name
×
UNCOV
69
        this.columnNames = options.columnNames
×
UNCOV
70
        this.referencedColumnNames = options.referencedColumnNames
×
UNCOV
71
        this.referencedDatabase = options.referencedDatabase
×
UNCOV
72
        this.referencedSchema = options.referencedSchema
×
UNCOV
73
        this.referencedTableName = options.referencedTableName
×
UNCOV
74
        this.onDelete = options.onDelete
×
UNCOV
75
        this.onUpdate = options.onUpdate
×
UNCOV
76
        this.deferrable = options.deferrable
×
77
    }
78

79
    // -------------------------------------------------------------------------
80
    // Public Methods
81
    // -------------------------------------------------------------------------
82

83
    /**
84
     * Creates a new copy of this foreign key with exactly same properties.
85
     */
86
    clone(): TableForeignKey {
UNCOV
87
        return new TableForeignKey(<TableForeignKeyOptions>{
×
88
            name: this.name,
89
            columnNames: [...this.columnNames],
90
            referencedColumnNames: [...this.referencedColumnNames],
91
            referencedDatabase: this.referencedDatabase,
92
            referencedSchema: this.referencedSchema,
93
            referencedTableName: this.referencedTableName,
94
            onDelete: this.onDelete,
95
            onUpdate: this.onUpdate,
96
            deferrable: this.deferrable,
97
        })
98
    }
99

100
    // -------------------------------------------------------------------------
101
    // Static Methods
102
    // -------------------------------------------------------------------------
103

104
    /**
105
     * Creates a new table foreign key from the given foreign key metadata.
106
     */
107
    static create(
108
        metadata: ForeignKeyMetadata,
109
        driver: Driver,
110
    ): TableForeignKey {
UNCOV
111
        return new TableForeignKey(<TableForeignKeyOptions>{
×
112
            name: metadata.name,
113
            columnNames: metadata.columnNames,
114
            referencedColumnNames: metadata.referencedColumnNames,
115
            referencedDatabase: metadata.referencedEntityMetadata.database,
116
            referencedSchema: metadata.referencedEntityMetadata.schema,
117
            referencedTableName: metadata.referencedTablePath,
118
            onDelete: metadata.onDelete,
119
            onUpdate: metadata.onUpdate,
120
            deferrable: metadata.deferrable,
121
        })
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