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

ngageoint / geopackage-js / 4026249674

pending completion
4026249674

push

github

Christopher Caldwell
update typescript, fix linter errors and remove module comments

3590 of 8008 branches covered (44.83%)

Branch coverage included in aggregate %.

1218 of 1218 new or added lines in 92 files covered. (100.0%)

15084 of 20419 relevant lines covered (73.87%)

1570.21 hits per line

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

66.67
/lib/user/userConnection.ts
1
import { UserColumn } from './userColumn';
2
import { UserRow } from './userRow';
3
import { UserTable } from './userTable';
4
import { GeoPackageConnection } from '../db/geoPackageConnection';
5
import { ResultSet } from '../db/resultSet';
6
import { SQLUtils } from '../db/sqlUtils';
1✔
7
import { SqliteQueryBuilder } from '../db/sqliteQueryBuilder';
1✔
8
import { UserResultSet } from './userResultSet';
9
import { DBValue } from '../db/dbValue';
10

11
/**
12
 * GeoPackage Connection used to define common functionality within different
13
 * connection types
14
 * @param <TColumn> column type
15
 * @param <TTable> table type
16
 * @param <TRow> row type
17
 * @param <TResult> result type
18
 */
19
export abstract class UserConnection<
1✔
20
  TColumn extends UserColumn,
21
  TTable extends UserTable<TColumn>,
22
  TRow extends UserRow<TColumn, TTable>,
23
  TResult extends UserResultSet<TColumn, TTable, TRow>,
24
> {
25
  /**
26
   * Connection
27
   */
28
  protected readonly connection: GeoPackageConnection;
29

30
  /**
31
   * Table
32
   */
33
  protected table: TTable;
34

35
  /**
36
   * Constructor
37
   * @param connection GeoPackage connection
38
   */
39
  protected constructor(connection: GeoPackageConnection) {
40
    this.connection = connection;
5,726✔
41
  }
42

43
  /**
44
   * Get the table
45
   * @return table
46
   */
47
  public getTable(): TTable {
1✔
48
    return this.table;
1,154✔
49
  }
50

51
  /**
52
   * Set the table
53
   * @param table table
54
   */
55
  public setTable(table: TTable): void {
1✔
56
    this.table = table;
5,726✔
57
  }
58

59
  /**
60
   * Create a result by wrapping the ResultSet
61
   * @param columns result set
62
   * @param resultSet result set
63
   * @param sql SQL statement
64
   * @param selectionArgs selection arguments
65
   * @return result
66
   */
67
  protected abstract createResult(
68
    columns: string[],
69
    resultSet: ResultSet,
70
    sql: string,
71
    selectionArgs: string[],
72
  ): TResult;
73

74
  /**
75
   * Perform raw query
76
   * @param sql
77
   * @param selectionArgs
78
   */
79
  public rawQuery(sql: string, selectionArgs: []): TResult {
1✔
80
    const resultSet = SQLUtils.query(this.connection, sql, selectionArgs);
×
81
    return this.createResult(undefined, resultSet, sql, selectionArgs);
×
82
  }
83

84
  /**
85
   * Perform raw query with specified columns
86
   * @param sql
87
   * @param columns
88
   * @param selectionArgs
89
   */
90
  public rawQueryWithColumns(sql: string, columns: string[], selectionArgs: any[]): TResult {
1✔
91
    const resultSet = SQLUtils.query(this.connection, sql, selectionArgs);
×
92
    return this.createResult(columns, resultSet, sql, selectionArgs);
×
93
  }
94

95
  /**
96
   * Perform query
97
   * @param distinct
98
   * @param tables
99
   * @param columns
100
   * @param where
101
   * @param whereArgs
102
   * @param join
103
   * @param groupBy
104
   * @param having
105
   * @param orderBy
106
   * @param limit
107
   * @param offset
108
   */
109
  public query(
1✔
110
    distinct: boolean,
111
    tables: string,
112
    columns?: string[],
113
    where?: string,
114
    whereArgs?: any[],
115
    join?: string,
116
    groupBy?: string,
117
    having?: string,
118
    orderBy?: string,
119
    limit?: number,
120
    offset?: number,
121
  ): TResult {
122
    const sql = this.querySQL(distinct, tables, columns, where, join, groupBy, having, orderBy, limit, offset);
2,518✔
123
    const resultSet = SQLUtils.query(this.connection, sql, whereArgs);
2,518✔
124
    return this.createResult(columns, resultSet, sql, whereArgs);
2,518✔
125
  }
126

127
  /**
128
   * Perform query
129
   * @param distinct
130
   * @param tables
131
   * @param columns
132
   * @param where
133
   * @param whereArgs
134
   * @param join
135
   * @param groupBy
136
   * @param having
137
   * @param orderBy
138
   * @param limit
139
   * @param offset
140
   */
141
  public count(
1✔
142
    distinct: boolean,
143
    tables: string,
144
    columns?: string[],
145
    where?: string,
146
    whereArgs?: [] | DBValue[],
147
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
    join?: string,
149
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
150
    groupBy?: string,
151
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
152
    having?: string,
153
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
154
    orderBy?: string,
155
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
156
    limit?: number,
157
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
    offset?: number,
159
  ): number {
160
    return SQLUtils.count(this.connection, tables, where, whereArgs);
1,069✔
161
  }
162

163
  /**
164
   * Get a count of results
165
   * @param table  table name
166
   * @param distinct  distinct column flag
167
   * @param column column name
168
   * @param where where clause
169
   * @param args arguments
170
   * @return count
171
   */
172
  public countColumn(table: string, distinct: boolean, column: string, where: string, args: any[]): number {
1✔
173
    let count = 0;
×
174
    const value = this.connection.aggregateFunction('COUNT', table, distinct, column, where, args);
×
175
    if (value != null) {
×
176
      count = value.intValue();
×
177
    }
178
    return count;
×
179
  }
180

181
  /**
182
   * {@inheritDoc}
183
   */
184
  public querySQL(
1✔
185
    distinct: boolean,
186
    tables: string,
187
    columns?: string[],
188
    where?: string,
189
    join?: string,
190
    groupBy?: string,
191
    having?: string,
192
    orderBy?: string,
193
    limit?: number,
194
    offset?: number,
195
  ): string {
196
    return SqliteQueryBuilder.buildQuery(
2,537✔
197
      distinct,
198
      tables,
199
      columns,
200
      where,
201
      join,
202
      groupBy,
203
      having,
204
      orderBy,
205
      limit,
206
      offset,
207
    );
208
  }
209

210
  /**
211
   * Get the connection
212
   */
213
  public getConnection(): GeoPackageConnection {
1✔
214
    return this.connection;
1✔
215
  }
216
}
1✔
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