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

ngageoint / geopackage-js / 4078143969

pending completion
4078143969

push

github

Christopher Caldwell
bump version

3593 of 8015 branches covered (44.83%)

Branch coverage included in aggregate %.

15102 of 20471 relevant lines covered (73.77%)

1564.55 hits per line

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

78.38
/lib/user/userTableReader.ts
1
import { UserTable } from './userTable';
2
import { UserColumn } from './userColumn';
3
import { GeoPackageConnection } from '../db/geoPackageConnection';
4
import { TableInfo } from '../db/table/tableInfo';
1✔
5
import { SQLiteMaster } from '../db/master/sqliteMaster';
1✔
6
import { TableColumn } from '../db/table/tableColumn';
7
import { GeoPackageException } from '../geoPackageException';
1✔
8

9
/**
10
 * @class
11
 */
12
export abstract class UserTableReader<TColumn extends UserColumn, TTable extends UserTable<TColumn>> {
1✔
13
  /**
14
   * Table name
15
   */
16
  private readonly tableName: string;
17

18
  /**
19
   * @param tableName name of the table
20
   */
21
  protected constructor(tableName: string) {
22
    this.tableName = tableName;
5,182✔
23
  }
24

25
  /**
26
   * Creates a user column
27
   */
28
  abstract createColumn(tableColumn: TableColumn): TColumn;
29

30
  /**
31
   * Creates a user column
32
   */
33
  abstract createTable(tableName: string, columnList: TColumn[]): TTable;
34

35
  /**
36
   * Read the table
37
   * @param db connection
38
   * @return table
39
   */
40
  public readTable(db: GeoPackageConnection): TTable {
5,182✔
41
    const columnList: TColumn[] = [];
5,182✔
42

43
    const tableInfo = TableInfo.info(db, this.tableName);
5,182✔
44
    if (tableInfo === null || tableInfo === undefined) {
5,182!
45
      throw new GeoPackageException('Table does not exist: ' + this.tableName);
×
46
    }
47

48
    const constraints = SQLiteMaster.queryForConstraints(db, this.tableName);
5,182✔
49

50
    tableInfo.getColumns().forEach((tableColumn) => {
5,182✔
51
      if (tableColumn.getDataType() === null || tableColumn.getDataType() === undefined) {
21,818!
52
        throw new GeoPackageException('Unsupported column data type ' + tableColumn.getType());
×
53
      }
54
      const column = this.createColumn(tableColumn);
21,818✔
55

56
      const columnConstraints = constraints.getColumnConstraints(column.getName());
21,818✔
57
      if (columnConstraints !== null && columnConstraints !== undefined && columnConstraints.hasConstraints()) {
21,818!
58
        column.clearConstraints();
×
59
        column.addConstraints(columnConstraints.constraints);
×
60
      }
61

62
      columnList.push(column);
21,818✔
63
    });
64

65
    const table: TTable = this.createTable(this.tableName, columnList);
5,182✔
66
    table.addConstraintsWithConstraints(constraints.getTableConstraints());
5,182✔
67
    return table;
5,182✔
68
  }
69
}
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