ismx-nexo-node-app 0.4.21 → 0.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,16 @@ class PostgresUtils {
19
19
  ]));
20
20
  }
21
21
  static columns(table) {
22
- return table.map((t) => t.name);
22
+ return table.map((t) => {
23
+ if (!PostgresUtils.isReservedWord(t.name))
24
+ return t.name;
25
+ else
26
+ return `"${t.name}"`;
27
+ });
28
+ }
29
+ static isReservedWord(word) {
30
+ const reservedWords = new Set(['select', 'from', 'where', 'join', 'table', 'user', 'group', 'order', 'limit', 'offset', 'insert', 'update', 'delete']);
31
+ return reservedWords.has(word.toLowerCase());
23
32
  }
24
33
  static bindOrDefault(table, object, startIndex) {
25
34
  let index = startIndex;
@@ -5,6 +5,7 @@ export default abstract class PostgresUtils {
5
5
  static camelToSnake(column: string): string;
6
6
  static snakeToCamel(obj: any): any;
7
7
  static columns(table: Column[]): string[];
8
+ static isReservedWord(word: string): boolean;
8
9
  static bindOrDefault(table: Column[], object: {
9
10
  [p: string]: Primitive;
10
11
  }, startIndex: any): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -27,7 +27,16 @@ export default abstract class PostgresUtils
27
27
  }
28
28
 
29
29
  static columns(table: Column[]): string[] {
30
- return table.map((t) => t.name);
30
+ return table.map((t) => {
31
+ if (!PostgresUtils.isReservedWord(t.name))
32
+ return t.name;
33
+ else return `"${t.name}"`;
34
+ });
35
+ }
36
+
37
+ static isReservedWord(word: string): boolean {
38
+ const reservedWords = new Set(['select', 'from', 'where', 'join', 'table', 'user', 'group', 'order', 'limit', 'offset', 'insert', 'update', 'delete']);
39
+ return reservedWords.has(word.toLowerCase());
31
40
  }
32
41
 
33
42
  static bindOrDefault(table: Column[], object: { [p: string]: Primitive }, startIndex: any): { bindings: string[], values: any[] } {