• 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

79.55
/lib/db/table/constraintType.ts
1
export enum ConstraintType {
1✔
2
  /**
3
   * Primary key table and column constraint
4
   */
5
  PRIMARY_KEY,
1✔
6

7
  /**
8
   * Unique table and column constraint
9
   */
10
  UNIQUE,
1✔
11

12
  /**
13
   * Check table and column constraint
14
   */
15
  CHECK,
1✔
16

17
  /**
18
   * Foreign key table and column constraint
19
   */
20
  FOREIGN_KEY,
1✔
21

22
  /**
23
   * Not null column constraint
24
   */
25
  NOT_NULL,
1✔
26

27
  /**
28
   * Default column constraint
29
   */
30
  DEFAULT,
1✔
31

32
  /**
33
   * Collate column constraint
34
   */
35
  COLLATE,
1✔
36

37
  /**
38
   * Autoincrement column constraint
39
   */
40
  AUTOINCREMENT,
1✔
41
}
42

43
// eslint-disable-next-line @typescript-eslint/no-namespace
44
export namespace ConstraintType {
1!
45
  export function nameFromType(type: ConstraintType): string {
1✔
46
    return ConstraintType[type];
12✔
47
  }
48

49
  export function fromName(type: string): ConstraintType {
1✔
50
    return ConstraintType[type as keyof typeof ConstraintType] as ConstraintType;
×
51
  }
52

53
  /**
54
   * Table constraints
55
   */
56
  export const TABLE_CONSTRAINTS = new Set<ConstraintType>([
1✔
57
    ConstraintType.PRIMARY_KEY,
58
    ConstraintType.UNIQUE,
59
    ConstraintType.CHECK,
60
    ConstraintType.FOREIGN_KEY,
61
  ]);
62

63
  /**
64
   * Column constraints
65
   */
66
  export const COLUMN_CONSTRAINTS = new Set<ConstraintType>([
1✔
67
    ConstraintType.PRIMARY_KEY,
68
    ConstraintType.NOT_NULL,
69
    ConstraintType.UNIQUE,
70
    ConstraintType.CHECK,
71
    ConstraintType.DEFAULT,
72
    ConstraintType.COLLATE,
73
    ConstraintType.FOREIGN_KEY,
74
    ConstraintType.AUTOINCREMENT,
75
  ]);
76

77
  /**
78
   * Add constraint lookup values
79
   * @param lookup lookup map
80
   * @param type constraint type
81
   */
82
  function addLookups(lookup: Map<string, ConstraintType>, type: ConstraintType): void {
83
    const name = ConstraintType.nameFromType(type);
12✔
84
    const parts = name.split('_');
12✔
85
    lookup.set(parts[0], type);
12✔
86
    if (parts.length > 0) {
12!
87
      lookup.set(name.replace('_', ' '), type);
12✔
88
    }
89
  }
90

91
  /**
92
   * Table constraint parsing lookup values
93
   */
94
  const tableLookup = new Map<string, ConstraintType>();
1✔
95
  Array.from(TABLE_CONSTRAINTS).forEach((type) => {
1✔
96
    addLookups(tableLookup, type);
4✔
97
  });
98

99
  /**
100
   * Column constraint parsing lookup values
101
   */
102
  const columnLookup = new Map<string, ConstraintType>();
1✔
103
  Array.from(COLUMN_CONSTRAINTS).forEach((type) => {
1✔
104
    addLookups(columnLookup, type);
8✔
105
  });
106

107
  /**
108
   * Get a matching table constraint type from the value
109
   * @param value table constraint name value
110
   * @return constraint type or null
111
   */
112
  export function getTableType(value: string): ConstraintType {
1✔
113
    return tableLookup.get(value.toUpperCase());
26,187✔
114
  }
115

116
  /**
117
   * Get a matching column constraint type from the value
118
   *
119
   * @param value
120
   *            column constraint name value
121
   * @return constraint type or null
122
   */
123
  export function getColumnType(value: string): ConstraintType {
1✔
124
    return columnLookup.get(value.toUpperCase());
61,376✔
125
  }
126

127
  /**
128
   * Get a matching constraint type from the value
129
   *
130
   * @param value
131
   *            constraint name value
132
   * @return constraint type or null
133
   */
134
  export function getType(value: string): ConstraintType {
1✔
135
    let type = getTableType(value);
×
136
    if (type == null) {
×
137
      type = getColumnType(value);
×
138
    }
139
    return type;
×
140
  }
141
}
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