backend-plus 2.0.2 → 2.0.4

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.
@@ -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;
@@ -967,7 +967,7 @@ AppBackend.prototype.start = function start(opts){
967
967
  );
968
968
  }
969
969
  be.config.login.plus=changing(be.config.login.plus,{session:{
970
- name: 'bp'+(packagejson.name+be.config.server["base-url"]||Math.random())+'-connect.sid',
970
+ name: 'bp'+(packagejson.name+be.config.server["base-url"]||Math.random()).replace('/','#')+'-connect.sid',
971
971
  cookie:{
972
972
  path: be.config.server["base-url"]||'/',
973
973
  }
@@ -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')+
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.2",
4
+ "version": "2.0.4",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",