backend-plus 2.0.3 → 2.0.5

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.
@@ -575,7 +575,6 @@ var TIME_STAMP_PROP = Symbol('TIME_STAMP_PROP');
575
575
  myOwn.setTimeStamp = function setTimeStamp(row){
576
576
  var timeStamp = new Date().getTime();
577
577
  row[TIME_STAMP_PROP] = timeStamp;
578
- console.log('SET=', timeStamp, row[TIME_STAMP_PROP], JSON4all.toUrl(row))
579
578
  return timeStamp;
580
579
  }
581
580
 
@@ -0,0 +1,12 @@
1
+ create or replace function semver_to_decimal(p_semver text) returns decimal
2
+ stable language sql
3
+ as
4
+ $sql$
5
+ select regexp_replace(p_semver, '^(\d+(\.\d*)?)(\D.*|$)$','\1')::decimal;
6
+ $sql$;
7
+
8
+ select *, semver_to_decimal(semver), 'ERROR semver_to_decimal!!!!!!!!!!!!!'
9
+ from (select '12.3.4' semver, 12.3 result
10
+ union values ('12', 12),('12.3',12.3),('12.3.3-r12',12.3),('12b',12)
11
+ )
12
+ where semver_to_decimal(semver) is distinct from result;
@@ -2682,20 +2682,18 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
2682
2682
  }
2683
2683
  var schema=db.quoteIdent(be.config.db.schema);
2684
2684
  linesCreate.push("set role to "+owner+";");
2685
- linesCreate.push(`do
2686
- $do$
2685
+ var control = `-- CONTROL
2686
+ do $do$
2687
2687
  declare
2688
2688
  vExpectedVersion text := '${be.config.db["min-version"]}';
2689
2689
  vCurrentVersion text := (select setting from pg_settings where name = 'server_version');
2690
2690
  begin
2691
- if jsonb('['||replace(vCurrentVersion,'.',',')||']') < jsonb('['||replace(vExpectedVersion,'.',',')||']') then
2691
+ if semver_to_decimal(vCurrentVersion) < semver_to_decimal(vExpectedVersion) then
2692
2692
  raise exception 'BACKEND-PLUS DUMP: Old PostrgreSQL Version % expected %', vCurrentVersion, vExpectedVersion;
2693
2693
  end if;
2694
2694
  end;
2695
2695
  $do$;
2696
- `);
2697
- linesCreate.push(`do
2698
- $do$
2696
+ do $do$
2699
2697
  declare
2700
2698
  vExpected text := 'UTF8';
2701
2699
  vCurrent text := coalesce((select setting from pg_settings where name = 'server_encoding'),'unknown');
@@ -2705,7 +2703,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
2705
2703
  end if;
2706
2704
  end;
2707
2705
  $do$;
2708
- `);
2706
+ `;
2709
2707
  linesCreate.push("drop schema if exists "+schema+' cascade;');
2710
2708
  if (be.config.install.dump["drop-his"]) {
2711
2709
  linesCreate.push("drop schema if exists his cascade;");
@@ -3127,6 +3125,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
3127
3125
  (complete||opts.forDump? searchPathline.join('\n'): '')+
3128
3126
  '\n-- common'+
3129
3127
  common+'\n'+
3128
+ control+'\n'+
3130
3129
  (complete? '\n\n--prepare.sql\n'+ texts[0]+'\n\n' :'' )+
3131
3130
  (complete? texts[3] + '\n\n' : '' )+
3132
3131
  '\n-- functions\n' + functionLines.join('\n')+
@@ -85,7 +85,7 @@ ProcedureTables = [
85
85
  /**
86
86
  *
87
87
  * @param {*} context
88
- * @param {{table:string, fixedFields:{fieldName:string, value:any, range:string}[], paramfun:string[], pick:string, retrieveIgnoringWhere:boolean}} parameters * @param {{table:string, fixedFields:{fieldName:string, value:any, range:string}[], paramfun:string[], pick:string}} parameters
88
+ * @param {{table:string, fixedFields:{fieldName:string, value:any, range?:string, until?:string}[], paramfun:string[], pick:string, retrieveIgnoringWhere:boolean}} parameters * @param {{table:string, fixedFields:{fieldName:string, value:any, range?:string, until?:string}[], paramfun:string[], pick:string}} parameters
89
89
  */
90
90
  async function tableDatum(context, parameters){
91
91
  var be=context.be;
@@ -136,6 +136,9 @@ ProcedureTables = [
136
136
  queryValues.push(pair.range);
137
137
  queryValues.push(pair.range);
138
138
  comparison = " between $" + (queryValues.length-3) + ' - $' +(queryValues.length-1) + ' and $' +(queryValues.length-2) + ' + $' +(queryValues.length-3);
139
+ } else if(pair.until){
140
+ queryValues.push(pair.until);
141
+ comparison = " between $" + (queryValues.length-1) + ' and $' + (queryValues.length);
139
142
  }
140
143
  }
141
144
  var exprClausule=' AND '+be.db.quoteIdent(alias)+'.'+be.db.quoteIdent(fieldName) + comparison
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.0.3",
4
+ "version": "2.0.5",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",
@@ -55,9 +55,9 @@
55
55
  "mini-tools": "^1.12.2",
56
56
  "moment": "^2.30.1",
57
57
  "multiparty": "^4.2.3",
58
- "nodemailer": "^6.9.15",
58
+ "nodemailer": "^6.9.16",
59
59
  "numeral": "^2.0.6",
60
- "pg-promise-strict": "^1.4.1",
60
+ "pg-promise-strict": "^1.4.2",
61
61
  "pikaday": "^1.8.2",
62
62
  "pug": "^3.0.3",
63
63
  "read-yaml-promise": "^1.0.2",
@@ -68,7 +68,7 @@
68
68
  "session-file-store": "^1.5.0",
69
69
  "sql-tools": "^0.1.2",
70
70
  "stack-trace": "^0.0.10",
71
- "stylus": "0.63.0",
71
+ "stylus": "0.64.0",
72
72
  "type-store": "^0.4.4",
73
73
  "typed-controls": "^0.12.2",
74
74
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
@@ -82,7 +82,7 @@
82
82
  "@types/js-yaml": "^4.0.9",
83
83
  "@types/mocha": "^10.0.9",
84
84
  "@types/multiparty": "~4.2.1",
85
- "@types/node": "^22.7.5",
85
+ "@types/node": "^22.8.7",
86
86
  "@types/nodemailer": "^6.4.16",
87
87
  "@types/numeral": "~2.0.5",
88
88
  "@types/session-file-store": "^1.2.5",
@@ -97,14 +97,14 @@
97
97
  "karma-ie-launcher": "^1.0.0",
98
98
  "karma-mocha": "^2.0.1",
99
99
  "kill-9": "~0.4.3",
100
- "mocha": "^10.7.3",
100
+ "mocha": "^10.8.2",
101
101
  "nyc": "^17.1.0",
102
- "puppeteer": "^23.5.2",
102
+ "puppeteer": "^23.6.1",
103
103
  "sinon": "^19.0.2",
104
104
  "supertest": "^7.0.0",
105
105
  "types.d.ts": "~0.6.21",
106
106
  "typescript": "^5.6.3",
107
- "why-is-node-running": "^3.2.0"
107
+ "why-is-node-running": "^3.2.1"
108
108
  },
109
109
  "engines": {
110
110
  "node": ">= 18"