@saltcorn/postgres 1.3.0-beta.13 → 1.3.0-beta.14

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/postgres.js +24 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/postgres",
3
- "version": "1.3.0-beta.13",
3
+ "version": "1.3.0-beta.14",
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-beta.13",
15
+ "@saltcorn/db-common": "1.3.0-beta.14",
16
16
  "pg": "^8.13.1",
17
17
  "pg-copy-streams": "^6.0.6",
18
18
  "replacestream": "4.0.3"
package/postgres.js CHANGED
@@ -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 (table_name, field_expression, language) => {
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
- const sql = `create index "${sqlsanitize(
424
- table_name
425
- )}_fts_index" on "${getTenantSchema()}"."${sqlsanitize(
426
- table_name
427
- )}" USING GIN (to_tsvector('${
428
- language || "english"
429
- }', ${field_expression}));`;
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
  };