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

typeorm / typeorm / 22256862981

21 Feb 2026 12:31PM UTC coverage: 81.291% (+0.1%) from 81.176%
22256862981

push

github

web-flow
feat!: remove deprecated `Connection` and `ConnectionOptions` (#12022)

27682 of 33521 branches covered (82.58%)

Branch coverage included in aggregate %.

1205 of 1301 new or added lines in 76 files covered. (92.62%)

1 existing line in 1 file now uncovered.

93920 of 116068 relevant lines covered (80.92%)

71235.59 hits per line

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

45.45
/src/driver/nativescript/NativescriptDriver.ts
1
import { DataSource } from "../../data-source/DataSource"
26✔
2
import { DriverPackageNotInstalledError } from "../../error/DriverPackageNotInstalledError"
26✔
3
import { QueryRunner } from "../../query-runner/QueryRunner"
26✔
4
import { AbstractSqliteDriver } from "../sqlite-abstract/AbstractSqliteDriver"
26✔
5
import { ColumnType } from "../types/ColumnTypes"
26✔
6
import { ReplicationMode } from "../types/ReplicationMode"
26✔
7
import { NativescriptDataSourceOptions } from "./NativescriptDataSourceOptions"
26✔
8
import { NativescriptQueryRunner } from "./NativescriptQueryRunner"
26✔
9

26✔
10
/**
26✔
11
 * Organizes communication with sqlite DBMS within Nativescript.
26✔
12
 */
26✔
13
export class NativescriptDriver extends AbstractSqliteDriver {
26✔
14
    // -------------------------------------------------------------------------
26✔
15
    // Public Properties
26✔
16
    // -------------------------------------------------------------------------
26✔
17

26✔
18
    /**
26✔
19
     * Connection options.
26✔
20
     */
26✔
21
    options: NativescriptDataSourceOptions
26✔
22

26✔
23
    /**
26✔
24
     * Nativescript driver module
26✔
25
     * this is most likely `nativescript-sqlite`
26✔
26
     * but user can pass his own
26✔
27
     */
26✔
28
    driver: any
26✔
29

26✔
30
    // -------------------------------------------------------------------------
26✔
31
    // Constructor
26✔
32
    // -------------------------------------------------------------------------
26✔
33

26✔
34
    constructor(connection: DataSource) {
26✔
35
        super(connection)
×
36

×
37
        this.connection = connection
×
NEW
38
        this.options = connection.options as NativescriptDataSourceOptions
×
39
        this.database = this.options.database
×
40
        this.driver = this.options.driver
×
41

×
42
        // load sqlite package
×
43
        this.loadDependencies()
×
44
    }
×
45

26✔
46
    // -------------------------------------------------------------------------
26✔
47
    // Public Methods
26✔
48
    // -------------------------------------------------------------------------
26✔
49

26✔
50
    /**
26✔
51
     * Closes connection with database.
26✔
52
     */
26✔
53
    async disconnect(): Promise<void> {
26✔
54
        return new Promise<void>((ok, fail) => {
×
55
            this.queryRunner = undefined
×
56
            this.databaseConnection.close().then(ok).catch(fail)
×
57
        })
×
58
    }
×
59

26✔
60
    /**
26✔
61
     * Creates a query runner used to execute database queries.
26✔
62
     * @param mode
26✔
63
     */
26✔
64
    createQueryRunner(mode: ReplicationMode): QueryRunner {
26✔
65
        if (!this.queryRunner) {
×
66
            this.queryRunner = new NativescriptQueryRunner(this)
×
67
        }
×
68

×
69
        return this.queryRunner
×
70
    }
×
71

26✔
72
    normalizeType(column: {
26✔
73
        type?: ColumnType
×
74
        length?: number | string
×
75
        precision?: number | null
×
76
        scale?: number
×
77
    }): string {
×
78
        if ((column.type as any) === Buffer) {
×
79
            return "blob"
×
80
        }
×
81

×
82
        return super.normalizeType(column)
×
83
    }
×
84
    // -------------------------------------------------------------------------
26✔
85
    // Protected Methods
26✔
86
    // -------------------------------------------------------------------------
26✔
87

26✔
88
    /**
26✔
89
     * Creates connection with the database.
26✔
90
     */
26✔
91
    protected createDatabaseConnection() {
26✔
92
        return new Promise<void>((ok, fail) => {
×
93
            const options = Object.assign(
×
94
                {},
×
95
                {
×
96
                    readOnly: this.options.readOnly,
×
97
                    key: this.options.key,
×
98
                    multithreading: this.options.multithreading,
×
99
                    migrate: this.options.migrate,
×
100
                    iosFlags: this.options.iosFlags,
×
101
                    androidFlags: this.options.androidFlags,
×
102
                },
×
103
                this.options.extra || {},
×
104
            )
×
105

×
106
            new this.sqlite(
×
107
                this.options.database,
×
108
                options,
×
109
                (err: Error, db: any): any => {
×
110
                    if (err) return fail(err)
×
111

×
112
                    // use object mode to work with TypeORM
×
113
                    db.resultType(this.sqlite.RESULTSASOBJECT)
×
114

×
115
                    // we need to enable foreign keys in sqlite to make sure all foreign key related features
×
116
                    // working properly. this also makes onDelete work with sqlite.
×
117
                    db.execSQL(
×
118
                        `PRAGMA foreign_keys = ON`,
×
119
                        [],
×
120
                        (err: Error, result: any): any => {
×
121
                            if (err) return fail(err)
×
122
                            // We are all set
×
123
                            ok(db)
×
124
                        },
×
125
                    )
×
126
                },
×
127
            )
×
128
        })
×
129
    }
×
130

26✔
131
    /**
26✔
132
     * If driver dependency is not given explicitly, then try to load it via "require".
26✔
133
     */
26✔
134
    protected loadDependencies(): void {
26✔
135
        this.sqlite = this.driver
×
136
        if (!this.driver) {
×
137
            throw new DriverPackageNotInstalledError(
×
138
                "Nativescript",
×
139
                "nativescript-sqlite",
×
140
            )
×
141
        }
×
142
    }
×
143
}
26✔
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