prostgles-server 2.0.116 → 2.0.120

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.
@@ -699,20 +699,26 @@ export const FUNCTIONS: FunctionSpec[] = [
699
699
 
700
700
  } else if(returnType === "object" || returnType === "boolean"){
701
701
  const hasChars = Boolean(term && /[a-z]/i.test(term));
702
+ const _cols = cols.map(c => {
703
+ const colInfo = allColumns.find(ac => ac.name === c);
704
+ return {
705
+ key: c,
706
+ colInfo
707
+ }
708
+ })
709
+ .filter(c => !c.colInfo || c.colInfo.udt_name !== "bytea")
710
+ .filter(c =>
711
+ /** Exclude numeric columns when the search tern contains a character */
712
+ !hasChars ||
713
+ c.colInfo?.udt_name &&
714
+ postgresToTsType(c.colInfo.udt_name) !== "number"
715
+ );
716
+ if(!_cols.length){
717
+ return (returnType === "boolean")? "FALSE" : "NULL"
718
+ }
702
719
  res = `CASE
703
- ${cols.map(c => {
704
- const colInfo = allColumns.find(ac => ac.name === c);
705
- return {
706
- key: c,
707
- colInfo
708
- }
709
- }).filter(c =>
710
- /** Exclude numeric columns when the search tern contains a character */
711
- !hasChars ||
712
- c.colInfo?.udt_name &&
713
- postgresToTsType(c.colInfo.udt_name) !== "number"
714
- )
715
- .map(c => {
720
+ ${_cols
721
+ .map(c => {
716
722
  const colNameEscaped = asNameAlias(c.key, tableAlias)
717
723
  let colSelect = `${colNameEscaped}::TEXT`;
718
724
  const isTstamp = c.colInfo?.udt_name.startsWith("timestamp");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "2.0.116",
3
+ "version": "2.0.120",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "i": "^0.3.7",
32
32
  "npm": "^8.1.4",
33
33
  "pg-promise": "^10.9.5",
34
- "prostgles-types": "^1.5.121",
34
+ "prostgles-types": "^1.5.122",
35
35
  "sharp": "^0.29.3"
36
36
  },
37
37
  "devDependencies": {
@@ -1 +1 @@
1
- 18519
1
+ 40900
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@types/node": "^14.14.16",
13
13
  "@types/socket.io-client": "^1.4.35",
14
- "prostgles-client": "^1.5.127",
14
+ "prostgles-client": "^1.5.131",
15
15
  "prostgles-types": "^1.5.68",
16
16
  "socket.io-client": "^4.2.0"
17
17
  }
@@ -114,22 +114,17 @@
114
114
  "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow=="
115
115
  },
116
116
  "node_modules/prostgles-client": {
117
- "version": "1.5.127",
118
- "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.127.tgz",
119
- "integrity": "sha512-2iA5CD6hH9UGh1q7FEtmSUjmzUHHUHtskf60ik2d0i9oML+6yN8dxZSn7AZuWA+DRIm85wYDS2hfFzumJgUeCQ==",
117
+ "version": "1.5.131",
118
+ "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.131.tgz",
119
+ "integrity": "sha512-LoNNxarPTtJJNZFyJW5U3LbyBMbE+pKSVsAcojiLJQdEpmxlzJ1zPqQf+711eKJ+2sE/9/gc+UeHh8SWQBaGTg==",
120
120
  "dependencies": {
121
- "prostgles-types": "^1.5.120"
121
+ "prostgles-types": "^1.5.122"
122
122
  }
123
123
  },
124
- "node_modules/prostgles-client/node_modules/prostgles-types": {
125
- "version": "1.5.120",
126
- "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.120.tgz",
127
- "integrity": "sha512-dWrXMJFhYmTKsiIBzYHTsCKXN6GoJGJe/lTohnkg9+drAhXbJvUrJ5nZ8LwYgkzG+wbWBwW82KIBGK6Zg4OqLw=="
128
- },
129
124
  "node_modules/prostgles-types": {
130
- "version": "1.5.105",
131
- "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.105.tgz",
132
- "integrity": "sha512-k87FnawwTuyPpnoOPDWMeu7QDevuNhOr9x7xoQ2GxF84Y7W66FPrdE/jh6kD7oqzIZtsV/WEVd0WtX+BC2uwEg=="
125
+ "version": "1.5.122",
126
+ "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.122.tgz",
127
+ "integrity": "sha512-YC9Glu2/uj5IeOb2/vBzz4toHTCYWl/3xDJr/gcLIORJzUq97R0a055+Zgj5afoCaYBVff61yjgujfqiTrxFBA=="
133
128
  },
134
129
  "node_modules/socket.io-client": {
135
130
  "version": "4.2.0",
@@ -280,24 +275,17 @@
280
275
  "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow=="
281
276
  },
282
277
  "prostgles-client": {
283
- "version": "1.5.127",
284
- "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.127.tgz",
285
- "integrity": "sha512-2iA5CD6hH9UGh1q7FEtmSUjmzUHHUHtskf60ik2d0i9oML+6yN8dxZSn7AZuWA+DRIm85wYDS2hfFzumJgUeCQ==",
278
+ "version": "1.5.131",
279
+ "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.131.tgz",
280
+ "integrity": "sha512-LoNNxarPTtJJNZFyJW5U3LbyBMbE+pKSVsAcojiLJQdEpmxlzJ1zPqQf+711eKJ+2sE/9/gc+UeHh8SWQBaGTg==",
286
281
  "requires": {
287
- "prostgles-types": "^1.5.120"
288
- },
289
- "dependencies": {
290
- "prostgles-types": {
291
- "version": "1.5.120",
292
- "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.120.tgz",
293
- "integrity": "sha512-dWrXMJFhYmTKsiIBzYHTsCKXN6GoJGJe/lTohnkg9+drAhXbJvUrJ5nZ8LwYgkzG+wbWBwW82KIBGK6Zg4OqLw=="
294
- }
282
+ "prostgles-types": "^1.5.122"
295
283
  }
296
284
  },
297
285
  "prostgles-types": {
298
- "version": "1.5.105",
299
- "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.105.tgz",
300
- "integrity": "sha512-k87FnawwTuyPpnoOPDWMeu7QDevuNhOr9x7xoQ2GxF84Y7W66FPrdE/jh6kD7oqzIZtsV/WEVd0WtX+BC2uwEg=="
286
+ "version": "1.5.122",
287
+ "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.122.tgz",
288
+ "integrity": "sha512-YC9Glu2/uj5IeOb2/vBzz4toHTCYWl/3xDJr/gcLIORJzUq97R0a055+Zgj5afoCaYBVff61yjgujfqiTrxFBA=="
301
289
  },
302
290
  "socket.io-client": {
303
291
  "version": "4.2.0",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@types/node": "^14.14.16",
16
16
  "@types/socket.io-client": "^1.4.35",
17
- "prostgles-client": "^1.5.127",
17
+ "prostgles-client": "^1.5.131",
18
18
  "prostgles-types": "^1.5.68",
19
19
  "socket.io-client": "^4.2.0"
20
20
  }
@@ -6,12 +6,16 @@ async function client_only(db, auth, log, methods) {
6
6
  const testRealtime = () => {
7
7
  log("Started testRealtime");
8
8
  return new Promise(async (resolve, reject) => {
9
+ var _a, _b;
9
10
  /* METHODS */
10
11
  const t222 = await methods.get();
11
12
  assert_1.strict.equal(t222, 222, "methods.get() failed");
12
13
  /* RAWSQL */
13
14
  const sqlStatement = await db.sql("SELECT $1", [1], { returnType: "statement" });
14
15
  assert_1.strict.equal(sqlStatement, "SELECT 1", "db.sql statement query failed");
16
+ const arrayMode = await db.sql("SELECT 1 as a, 2 as a", undefined, { returnType: "arrayMode" });
17
+ assert_1.strict.equal((_a = arrayMode.rows) === null || _a === void 0 ? void 0 : _a[0].join("."), "1.2", "db.sql statement arrayMode failed");
18
+ assert_1.strict.equal((_b = arrayMode.fields) === null || _b === void 0 ? void 0 : _b.map(f => f.name).join("."), "a.a", "db.sql statement arrayMode failed");
15
19
  const select1 = await db.sql("SELECT $1 as col1", [1], { returnType: "rows" });
16
20
  assert_1.strict.deepStrictEqual(select1[0], { col1: 1 }, "db.sql justRows query failed");
17
21
  const fullResult = await db.sql("SELECT $1 as col1", [1]);
@@ -17,6 +17,10 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
17
17
  const sqlStatement = await db.sql("SELECT $1", [1], { returnType: "statement" });
18
18
  assert.equal(sqlStatement, "SELECT 1", "db.sql statement query failed");
19
19
 
20
+ const arrayMode = await db.sql("SELECT 1 as a, 2 as a", undefined, { returnType: "arrayMode" });
21
+ assert.equal(arrayMode.rows?.[0].join("."), "1.2", "db.sql statement arrayMode failed");
22
+ assert.equal(arrayMode.fields?.map(f => f.name).join("."), "a.a", "db.sql statement arrayMode failed");
23
+
20
24
  const select1 = await db.sql("SELECT $1 as col1", [1], { returnType: "rows" });
21
25
  assert.deepStrictEqual(select1[0], { col1: 1 }, "db.sql justRows query failed");
22
26
 
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "../..": {
25
25
  "name": "prostgles-server",
26
- "version": "2.0.115",
26
+ "version": "2.0.119",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@aws-sdk/client-s3": "^3.32.0",
@@ -33,7 +33,7 @@
33
33
  "i": "^0.3.7",
34
34
  "npm": "^8.1.4",
35
35
  "pg-promise": "^10.9.5",
36
- "prostgles-types": "^1.5.121",
36
+ "prostgles-types": "^1.5.122",
37
37
  "sharp": "^0.29.3"
38
38
  },
39
39
  "devDependencies": {
@@ -1456,7 +1456,7 @@
1456
1456
  "i": "^0.3.7",
1457
1457
  "npm": "^8.1.4",
1458
1458
  "pg-promise": "^10.9.5",
1459
- "prostgles-types": "^1.5.121",
1459
+ "prostgles-types": "^1.5.122",
1460
1460
  "sharp": "^0.29.3",
1461
1461
  "typescript": "^3.9.7"
1462
1462
  }