prostgles-server 2.0.115 → 2.0.119
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.
- package/dist/DboBuilder.d.ts +2 -1
- package/dist/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder.js +8 -2
- package/dist/DboBuilder.js.map +1 -1
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +0 -49
- package/dist/Prostgles.js.map +1 -1
- package/dist/QueryBuilder.d.ts.map +1 -1
- package/dist/QueryBuilder.js +32 -11
- package/dist/QueryBuilder.js.map +1 -1
- package/lib/DboBuilder.ts +8 -2
- package/lib/Prostgles.ts +0 -64
- package/lib/QueryBuilder.ts +31 -12
- package/package.json +2 -2
- package/tests/client/PID.txt +1 -1
- package/tests/client/package-lock.json +15 -27
- package/tests/client/package.json +1 -1
- package/tests/client_only_queries.js +4 -0
- package/tests/client_only_queries.ts +4 -0
- package/tests/server/media/{5f408b71-0bb7-4e50-9b75-2d801d1e2e41.txt → 13b4236b-5aea-4d2e-bbad-2db2e2805bed.txt} +0 -0
- package/tests/server/media/{60c6817d-d1a2-43f3-a5ed-09c00f7833e3.txt → 9ac6b13b-ae7b-4fd0-a2b1-306475553d70.txt} +0 -0
- package/tests/server/media/{6c06b195-7346-4a6f-9cda-65372fa88282.txt → dc98a9ca-317e-472b-9fd9-9430c74bb574.txt} +0 -0
- package/tests/server/media/{e7505aae-6822-4555-848a-a28882576ecb.txt → dfcda106-8e08-476a-8afb-5a48f6952432.txt} +0 -0
- package/tests/server/package-lock.json +3 -3
package/lib/QueryBuilder.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
|
|
7
|
-
import { pgp, Filter, LocalParams, isPlainObject, TableHandler, ViewHandler } from "./DboBuilder";
|
|
7
|
+
import { pgp, Filter, LocalParams, isPlainObject, TableHandler, ViewHandler, postgresToTsType } from "./DboBuilder";
|
|
8
8
|
import { TableRule, flat } from "./Prostgles";
|
|
9
9
|
import { SelectParamsBasic as SelectParams, isEmpty, FieldFilter, asName, TextFilter_FullTextSearchFilterKeys, TS_PG_Types, ColumnInfo } from "prostgles-types";
|
|
10
10
|
import { get } from "./utils";
|
|
@@ -698,19 +698,38 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
698
698
|
// res = `CASE WHEN position(${term} IN ${col}) > 0 THEN TRUE ELSE FALSE END`;
|
|
699
699
|
|
|
700
700
|
} else if(returnType === "object" || returnType === "boolean"){
|
|
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
|
+
}
|
|
701
719
|
res = `CASE
|
|
702
|
-
${
|
|
703
|
-
|
|
704
|
-
const colNameEscaped = asNameAlias(c, tableAlias)
|
|
720
|
+
${_cols
|
|
721
|
+
.map(c => {
|
|
722
|
+
const colNameEscaped = asNameAlias(c.key, tableAlias)
|
|
705
723
|
let colSelect = `${colNameEscaped}::TEXT`;
|
|
706
|
-
const isTstamp = colInfo?.udt_name.startsWith("timestamp");
|
|
707
|
-
if(isTstamp || colInfo?.udt_name === "date"){
|
|
708
|
-
colSelect = `( CASE WHEN ${colNameEscaped} IS NULL THEN ''
|
|
724
|
+
const isTstamp = c.colInfo?.udt_name.startsWith("timestamp");
|
|
725
|
+
if(isTstamp || c.colInfo?.udt_name === "date"){
|
|
726
|
+
colSelect = `( CASE WHEN ${colNameEscaped} IS NULL THEN ''
|
|
727
|
+
ELSE concat_ws(' ',
|
|
709
728
|
${colNameEscaped}::TEXT,
|
|
710
|
-
${isTstamp? `'TZ' || to_char(${colNameEscaped}, 'OF'), `: ''}
|
|
711
|
-
to_char(${colNameEscaped}, '
|
|
712
|
-
'Q' || to_char(${colNameEscaped}, 'Q'),
|
|
713
|
-
'WK' || to_char(${colNameEscaped}, 'WW')
|
|
729
|
+
${isTstamp? `'TZ' || trim(to_char(${colNameEscaped}, 'OF')), `: ''}
|
|
730
|
+
trim(to_char(${colNameEscaped}, 'Day Month')),
|
|
731
|
+
'Q' || trim(to_char(${colNameEscaped}, 'Q')),
|
|
732
|
+
'WK' || trim(to_char(${colNameEscaped}, 'WW'))
|
|
714
733
|
) END)`
|
|
715
734
|
}
|
|
716
735
|
let colTxt = `COALESCE(${colSelect}, '')`; // position(${term} IN ${colTxt}) > 0
|
|
@@ -723,7 +742,7 @@ export const FUNCTIONS: FunctionSpec[] = [
|
|
|
723
742
|
return `
|
|
724
743
|
WHEN ${colTxt} ${matchCase? "LIKE" : "ILIKE"} ${asValue('%' + rawTerm + '%')}
|
|
725
744
|
THEN json_build_object(
|
|
726
|
-
${asValue(c)},
|
|
745
|
+
${asValue(c.key)},
|
|
727
746
|
${makeTextMatcherArray(
|
|
728
747
|
colTxt,
|
|
729
748
|
term
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prostgles-server",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.119",
|
|
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.
|
|
34
|
+
"prostgles-types": "^1.5.122",
|
|
35
35
|
"sharp": "^0.29.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
package/tests/client/PID.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
15516
|
|
@@ -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.
|
|
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.
|
|
118
|
-
"resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.
|
|
119
|
-
"integrity": "sha512-
|
|
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.
|
|
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.
|
|
131
|
-
"resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.
|
|
132
|
-
"integrity": "sha512-
|
|
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.
|
|
284
|
-
"resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.
|
|
285
|
-
"integrity": "sha512-
|
|
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.
|
|
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.
|
|
299
|
-
"resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.
|
|
300
|
-
"integrity": "sha512-
|
|
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",
|
|
@@ -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
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"../..": {
|
|
25
25
|
"name": "prostgles-server",
|
|
26
|
-
"version": "2.0.
|
|
26
|
+
"version": "2.0.118",
|
|
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.
|
|
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.
|
|
1459
|
+
"prostgles-types": "^1.5.122",
|
|
1460
1460
|
"sharp": "^0.29.3",
|
|
1461
1461
|
"typescript": "^3.9.7"
|
|
1462
1462
|
}
|