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

typeorm / typeorm / 19549987525

20 Nov 2025 08:11PM UTC coverage: 80.769% (+4.3%) from 76.433%
19549987525

push

github

web-flow
ci: run tests on commits to master and next (#11783)

Co-authored-by: Oleg "OSA413" Sokolov <OSA413@users.noreply.github.com>

26500 of 32174 branches covered (82.36%)

Branch coverage included in aggregate %.

91252 of 113615 relevant lines covered (80.32%)

88980.79 hits per line

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

36.72
/src/driver/nativescript/NativescriptQueryRunner.ts
1
import { ObjectLiteral } from "../../common/ObjectLiteral"
26✔
2
import { QueryFailedError } from "../../error/QueryFailedError"
26✔
3
import { QueryRunnerAlreadyReleasedError } from "../../error/QueryRunnerAlreadyReleasedError"
26✔
4
import { QueryResult } from "../../query-runner/QueryResult"
26✔
5
import { Broadcaster } from "../../subscriber/Broadcaster"
26✔
6
import { AbstractSqliteQueryRunner } from "../sqlite-abstract/AbstractSqliteQueryRunner"
26✔
7
import { NativescriptDriver } from "./NativescriptDriver"
26✔
8

26✔
9
/**
26✔
10
 * Runs queries on a single sqlite database connection.
26✔
11
 */
26✔
12
export class NativescriptQueryRunner extends AbstractSqliteQueryRunner {
26✔
13
    /**
26✔
14
     * Database driver used by connection.
26✔
15
     */
26✔
16
    driver: NativescriptDriver
26✔
17

26✔
18
    // -------------------------------------------------------------------------
26✔
19
    // Constructor
26✔
20
    // -------------------------------------------------------------------------
26✔
21

26✔
22
    constructor(driver: NativescriptDriver) {
26✔
23
        super()
×
24
        this.driver = driver
×
25
        this.connection = driver.connection
×
26
        this.broadcaster = new Broadcaster(this)
×
27
    }
×
28

26✔
29
    /**
26✔
30
     * Called before migrations are run.
26✔
31
     */
26✔
32
    async beforeMigration(): Promise<void> {
26✔
33
        await this.query(`PRAGMA foreign_keys = OFF`)
×
34
    }
×
35

26✔
36
    /**
26✔
37
     * Called after migrations are run.
26✔
38
     */
26✔
39
    async afterMigration(): Promise<void> {
26✔
40
        await this.query(`PRAGMA foreign_keys = ON`)
×
41
    }
×
42

26✔
43
    /**
26✔
44
     * Executes a given SQL query.
26✔
45
     */
26✔
46
    async query(
26✔
47
        query: string,
×
48
        parameters?: any[],
×
49
        useStructuredResult = false,
×
50
    ): Promise<any> {
×
51
        if (this.isReleased) {
×
52
            throw new QueryRunnerAlreadyReleasedError()
×
53
        }
×
54

×
55
        const connection = this.driver.connection
×
56

×
57
        const databaseConnection = await this.connect()
×
58

×
59
        return new Promise((ok, fail) => {
×
60
            const isInsertQuery = query.substr(0, 11) === "INSERT INTO"
×
61
            connection.logger.logQuery(query, parameters, this)
×
62

×
63
            const handler = (err: any, raw: any) => {
×
64
                // log slow queries if maxQueryExecution time is set
×
65
                const maxQueryExecutionTime =
×
66
                    this.driver.options.maxQueryExecutionTime
×
67
                const queryEndTime = Date.now()
×
68
                const queryExecutionTime = queryEndTime - queryStartTime
×
69

×
70
                if (
×
71
                    maxQueryExecutionTime &&
×
72
                    queryExecutionTime > maxQueryExecutionTime
×
73
                ) {
×
74
                    connection.logger.logQuerySlow(
×
75
                        queryExecutionTime,
×
76
                        query,
×
77
                        parameters,
×
78
                        this,
×
79
                    )
×
80
                }
×
81

×
82
                if (err) {
×
83
                    connection.logger.logQueryError(
×
84
                        err,
×
85
                        query,
×
86
                        parameters,
×
87
                        this,
×
88
                    )
×
89
                    fail(new QueryFailedError(query, parameters, err))
×
90
                }
×
91

×
92
                const result = new QueryResult()
×
93
                result.raw = raw
×
94

×
95
                if (!isInsertQuery && Array.isArray(raw)) {
×
96
                    result.records = raw
×
97
                }
×
98

×
99
                if (useStructuredResult) {
×
100
                    ok(result)
×
101
                } else {
×
102
                    ok(result.raw)
×
103
                }
×
104
            }
×
105
            const queryStartTime = Date.now()
×
106

×
107
            if (isInsertQuery) {
×
108
                databaseConnection.execSQL(query, parameters, handler)
×
109
            } else {
×
110
                databaseConnection.all(query, parameters, handler)
×
111
            }
×
112
        })
×
113
    }
×
114

26✔
115
    // -------------------------------------------------------------------------
26✔
116
    // Protected Methods
26✔
117
    // -------------------------------------------------------------------------
26✔
118

26✔
119
    /**
26✔
120
     * Parametrizes given object of values. Used to create column=value queries.
26✔
121
     */
26✔
122
    protected parametrize(
26✔
123
        objectLiteral: ObjectLiteral,
×
124
        startIndex: number = 0,
×
125
    ): string[] {
×
126
        return Object.keys(objectLiteral).map((key, index) => `"${key}"` + "=?")
×
127
    }
×
128
}
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