@saltcorn/postgres 1.3.0-beta.9 → 1.3.0
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/package.json +2 -2
- package/postgres.js +25 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/postgres",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Postgres structures for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@saltcorn/db-common": "1.3.0
|
|
15
|
+
"@saltcorn/db-common": "1.3.0",
|
|
16
16
|
"pg": "^8.13.1",
|
|
17
17
|
"pg-copy-streams": "^6.0.6",
|
|
18
18
|
"replacestream": "4.0.3"
|
package/postgres.js
CHANGED
|
@@ -234,7 +234,7 @@ const insert = async (tbl, obj, opts = Object.create(null)) => {
|
|
|
234
234
|
valPosList.push(
|
|
235
235
|
`coalesce((select max(_version) from "${schema}"."${sqlsanitize(
|
|
236
236
|
tbl
|
|
237
|
-
)}" where id=$${valList.length}), 0)+1`
|
|
237
|
+
)}" where "${v.pk_name || "id"}"=$${valList.length}), 0)+1`
|
|
238
238
|
);
|
|
239
239
|
} else {
|
|
240
240
|
valList.push(v);
|
|
@@ -418,15 +418,31 @@ const add_index = async (table_name, field_name) => {
|
|
|
418
418
|
* @param {string} field_name - list of columns (members of constraint)
|
|
419
419
|
* @returns {Promise<void>} no result
|
|
420
420
|
*/
|
|
421
|
-
const add_fts_index = async (
|
|
421
|
+
const add_fts_index = async (
|
|
422
|
+
table_name,
|
|
423
|
+
field_expression,
|
|
424
|
+
language,
|
|
425
|
+
disable_fts
|
|
426
|
+
) => {
|
|
422
427
|
// TBD check that there are no problems with lenght of constraint name
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
//CREATE INDEX ON public.test_table USING gist
|
|
429
|
+
// ((name || (cars ->> 'values') || surname) gist_trgm_ops);
|
|
430
|
+
let sql;
|
|
431
|
+
if (disable_fts) {
|
|
432
|
+
await getMyClient().query("CREATE EXTENSION IF NOT EXISTS pg_trgm;");
|
|
433
|
+
sql = `create index "${sqlsanitize(
|
|
434
|
+
table_name
|
|
435
|
+
)}_fts_index" on "${getTenantSchema()}"."${sqlsanitize(
|
|
436
|
+
table_name
|
|
437
|
+
)}" USING gist ((${field_expression}) gist_trgm_ops);`;
|
|
438
|
+
} else
|
|
439
|
+
sql = `create index "${sqlsanitize(
|
|
440
|
+
table_name
|
|
441
|
+
)}_fts_index" on "${getTenantSchema()}"."${sqlsanitize(
|
|
442
|
+
table_name
|
|
443
|
+
)}" USING GIN (to_tsvector('${
|
|
444
|
+
language || "english"
|
|
445
|
+
}', ${field_expression}));`;
|
|
430
446
|
sql_log(sql);
|
|
431
447
|
await getMyClient().query(sql);
|
|
432
448
|
};
|