backend-plus 2.5.2-betha.22 → 2.5.2-betha.24

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Codenautas
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Codenautas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,263 +1,263 @@
1
-
2
-
3
- # backend-plus
4
-
5
- Backend for the anti Pareto rule.
6
-
7
-
8
- ![stable](https://img.shields.io/badge/stability-stable-blue.svg)
9
- [![npm-version](https://img.shields.io/npm/v/backend-plus.svg)](https://npmjs.org/package/backend-plus)
10
- [![downloads](https://img.shields.io/npm/dm/backend-plus.svg)](https://npmjs.org/package/backend-plus)
11
- [![build](https://img.shields.io/travis/codenautas/backend-plus/master.svg)](https://travis-ci.org/codenautas/backend-plus)
12
- [![coverage](https://img.shields.io/coveralls/codenautas/backend-plus/master.svg)](https://coveralls.io/r/codenautas/backend-plus)
13
- [![dependencies](https://img.shields.io/david/codenautas/backend-plus.svg)](https://david-dm.org/codenautas/backend-plus)
14
-
15
-
16
- language: ![English](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-en.png)
17
- also available in:
18
- [![Spanish](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-es.png)](LEEME.md)
19
-
20
-
21
-
22
- It's a framework for developing web applications based on PostgreSQL database. It's main features are:
23
-
24
- 1. It is based on centralized metadata that defines:
25
- 1. The data structure (tables and views structure)
26
- 2. The procedures structure (param definition, permissions, encoding)
27
- 3. The menus structure
28
- 2. It provides:
29
- 1. Editable grids (orderable and filterable), with support for edit data using XLSX format files
30
- 2. Login mechanism
31
- 3. Menus
32
- 4. Skins definition
33
-
34
-
35
- ## API
36
-
37
-
38
- ### [table definitions](doc/table-definitions.md)
39
-
40
-
41
-
42
- ### [module definitions](doc/module-definitions.md)
43
-
44
-
45
- ### [client side definitions](doc/client-side-definitions.md)
46
-
47
- ### Menus definition
48
-
49
- menuType | use
50
- ---------|----------
51
- menu | menu or submenu
52
- table | grid or table
53
- proc | procedures
54
-
55
- property | type | default value | menuType | use
56
- ------------|------|----------------|----------|---------
57
- menuType | T | | | menu Type
58
- name | T | | | option name (id)
59
- menuContent | A | | menu | menu content
60
- table | T | `name` | table | table name
61
- label | T | `name` | | if you don't want to use default value to display in menu
62
- selectedByDefault | B | | | is the selected by default option
63
- autoproced | B | `false` | proc | if yo want to execute the procedure without clicking the proced button
64
-
65
- Integrating example:
66
-
67
- ```js
68
- getMenu(context){
69
- return {menu:[
70
- {menuType:'menu', name:'periodic table', menuContent:[
71
- {menuType:'table', name:'ptable' , label:'elements'},
72
- {menuType:'table', name:'pgroups' , label:'groups' },
73
- {menuType:'table', name:'isotopes', label:'isotopes'},
74
- {menuType:'proc' , name:'count_without_isotopes', label:'count'}
75
- ]},
76
- {menuType:'table', name:'images', table:'element_images'},
77
- {menuType:'menu', name:'test', menuContent:[
78
- {menuType:'table', name:'bigint'},
79
- ]},
80
- {menuType:'menu', name:'config', menuContent:[
81
- {name:'users', menuType:'table'},
82
- ]},
83
- ]}
84
- }
85
-
86
- ```
87
- ### Procedures definition
88
-
89
- #### procDef:
90
-
91
- property | type | default value | use
92
- ------------|------|-------------------------------|-----------------------------------------------------
93
- action | T | | Name that will be invoked the procedure
94
- bitacora | BO | { error:false, always:false } | Bitacora Object for core functions register
95
- parameters | POA | `[]` | Param Objects Array
96
- cacheable | Bool | false | The result can be cached
97
- coreFunction| F | | Function that implements the procedure
98
-
99
- #### bitacoraDef:
100
-
101
- propiedad | tipo | default value | uso
102
- ----------------------------------|----------------|----------------------------|-------------------
103
- error | B | false | If true, bitacora saves data of error ocurred during core function execution
104
- always | B | false | If true, bitacora saves all data ocurred during core function execution (overrides error)
105
- targetTable | T | null | Tablename for update result of execution data (must to exists a record for update) (see **targetTableBitacoraFields**). Use null for ignore option
106
- targetTableBitacoraFields | O | { **init_date**: 'init_date', **end_date**: 'end_date', **has_error**: 'has_error', **end_status**: 'end_status'} | Objects who defines the fields where **'targetTable'** will reply bitacora fields (If targetTable is null it's ommited)
107
- targetTableUpdateFieldsCondition | A | null | Fields array to define update condition (each value must to be passed as parameter with the same field name)
108
-
109
-
110
- #### paramDef:
111
-
112
- property | type | default value | use
113
- --------------|----------------|----------------|-------------------
114
- name | T | | name of the parameter that is sent to the procedure
115
- defaultValue | según typeName | | parameter default value
116
- typeName | T | | to define the data type
117
- label | T | name | if you don't want to use default value to display on screen
118
-
119
- #### coreFunction(context, parameters)
120
-
121
- context | uso
122
- ---------|----------------------
123
- be | backendApp object
124
- username | username
125
-
126
- Process definition example:
127
-
128
- ```js
129
- {
130
- action:'count_without_isotopes',
131
- bitacora:{
132
- error:true,
133
- always:true,
134
- targetTable:'other_table',
135
- targetTableBitacoraFields: {
136
- init_date: 'fecha_hora_inicio',
137
- end_date: 'fecha_hora_final',
138
- has_error: 'hubo_error',
139
- end_status: 'resultado'
140
- },
141
- targetTableUpdateFieldsCondition: ['id']
142
- },
143
- parameters:[
144
- {name:'first_atomic_number', defaultValue:10, typeName:'integer'},
145
- {name:'last_atomic_number' , defaultValue:99, typeName:'integer'},
146
- ],
147
- coreFunction:function(context, parameters){
148
- return context.client.query(
149
- `SELECT count(*) as number_of_elements
150
- FROM ptable p left join isotopes i on p.atomic_number=i.atomic_number
151
- WHERE i.atomic_number IS NULL
152
- AND p.atomic_number between coalesce($1,0) and coalesce($2,999)`,
153
- [parameters.first_atomic_number, parameters.last_atomic_number]
154
- ).fetchUniqueRow().then(function(result){
155
- return result.row.number_of_elements;
156
- });
157
- }
158
- },
159
- ```
160
-
161
- ## def-config
162
-
163
- ```js
164
- /// def-config.ts
165
- export defConfig=`
166
- server:
167
- port: 3000
168
- base-url: /my-app
169
- db:
170
- motor: postgresql
171
- host: localhost
172
- database: my_app_db
173
- user: my_app_user
174
- install:
175
- dump:
176
- db:
177
- owner: my_app_owner
178
- client-setup:
179
- title: My app
180
- lang: es
181
- `;
182
-
183
- /// main.ts
184
- import {defConfig} from "./def-config"
185
-
186
- export function emergeMyApp<T extends Constructor<AppBackend>>(Base:T){
187
- /// ...
188
- configStaticConfig(){
189
- super.configStaticConfig();
190
- this.setStaticConfig(defConfig);
191
- }
192
- ///...
193
- }
194
-
195
- ```
196
-
197
- The general application config is setted with `setStaticConfig`.
198
- Any option can be overwrited in `local-config.yaml` file.
199
-
200
- `BACKEND_PLUS_LOCAL_CONFIG` enviroment variable can be a `filename.yaml` with more config options.
201
-
202
- ### config format:
203
-
204
- entry | usage
205
- -----------------------------|---------------
206
- server |
207
- .port | port where is listening
208
- .base-url | base url added to domain name
209
- .module-store |
210
- install | (see Spanish)
211
- .dump | (see Spanish)
212
- ..db.owner | (see Spanish)
213
- ..scripts.post-adapt | (see Spanish)
214
- ..scripts.parts-order | (see Spanish)
215
- devel | (see Spanish)
216
- .delay | (see Spanish)
217
- .cache-content | (see Spanish)
218
- .forceShowAsEditable | (see Spanish)
219
- login | (see Spanish)
220
- .plus | (see Spanish)
221
- ..allowHttpLogin | (see Spanish)
222
- log | (see Spanish)
223
- .req | (see Spanish)
224
- .session | (see Spanish)
225
- client-setup | (see Spanish)
226
- .cursors | (see Spanish)
227
- .skin | (see Spanish)
228
- .menu | (see Spanish)
229
- .title | (see Spanish)
230
- .lang | (see Spanish)
231
-
232
- ```yaml
233
- install:
234
- dump:
235
- db:
236
- owner: user_owner
237
- scripts:
238
- post-adapt: [special_triggers.sql, other_constraints.sql]
239
- login:
240
- plus:
241
- allowHttpLogin: true
242
- store:
243
- module-name: file
244
- log:
245
- req: true
246
- session: true
247
- devel:
248
- cache-content: true
249
- ```
250
-
251
- ## Install
252
-
253
- ```sh
254
- $ npm install backend-plus
255
- ```
256
-
257
- ## License
258
-
259
- [MIT](LICENSE)
260
-
261
- ----------------
262
-
263
-
1
+
2
+
3
+ # backend-plus
4
+
5
+ Backend for the anti Pareto rule.
6
+
7
+
8
+ ![stable](https://img.shields.io/badge/stability-stable-blue.svg)
9
+ [![npm-version](https://img.shields.io/npm/v/backend-plus.svg)](https://npmjs.org/package/backend-plus)
10
+ [![downloads](https://img.shields.io/npm/dm/backend-plus.svg)](https://npmjs.org/package/backend-plus)
11
+ [![build](https://img.shields.io/travis/codenautas/backend-plus/master.svg)](https://travis-ci.org/codenautas/backend-plus)
12
+ [![coverage](https://img.shields.io/coveralls/codenautas/backend-plus/master.svg)](https://coveralls.io/r/codenautas/backend-plus)
13
+ [![dependencies](https://img.shields.io/david/codenautas/backend-plus.svg)](https://david-dm.org/codenautas/backend-plus)
14
+
15
+
16
+ language: ![English](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-en.png)
17
+ also available in:
18
+ [![Spanish](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-es.png)](LEEME.md)
19
+
20
+
21
+
22
+ It's a framework for developing web applications based on PostgreSQL database. It's main features are:
23
+
24
+ 1. It is based on centralized metadata that defines:
25
+ 1. The data structure (tables and views structure)
26
+ 2. The procedures structure (param definition, permissions, encoding)
27
+ 3. The menus structure
28
+ 2. It provides:
29
+ 1. Editable grids (orderable and filterable), with support for edit data using XLSX format files
30
+ 2. Login mechanism
31
+ 3. Menus
32
+ 4. Skins definition
33
+
34
+
35
+ ## API
36
+
37
+
38
+ ### [table definitions](doc/table-definitions.md)
39
+
40
+
41
+
42
+ ### [module definitions](doc/module-definitions.md)
43
+
44
+
45
+ ### [client side definitions](doc/client-side-definitions.md)
46
+
47
+ ### Menus definition
48
+
49
+ menuType | use
50
+ ---------|----------
51
+ menu | menu or submenu
52
+ table | grid or table
53
+ proc | procedures
54
+
55
+ property | type | default value | menuType | use
56
+ ------------|------|----------------|----------|---------
57
+ menuType | T | | | menu Type
58
+ name | T | | | option name (id)
59
+ menuContent | A | | menu | menu content
60
+ table | T | `name` | table | table name
61
+ label | T | `name` | | if you don't want to use default value to display in menu
62
+ selectedByDefault | B | | | is the selected by default option
63
+ autoproced | B | `false` | proc | if yo want to execute the procedure without clicking the proced button
64
+
65
+ Integrating example:
66
+
67
+ ```js
68
+ getMenu(context){
69
+ return {menu:[
70
+ {menuType:'menu', name:'periodic table', menuContent:[
71
+ {menuType:'table', name:'ptable' , label:'elements'},
72
+ {menuType:'table', name:'pgroups' , label:'groups' },
73
+ {menuType:'table', name:'isotopes', label:'isotopes'},
74
+ {menuType:'proc' , name:'count_without_isotopes', label:'count'}
75
+ ]},
76
+ {menuType:'table', name:'images', table:'element_images'},
77
+ {menuType:'menu', name:'test', menuContent:[
78
+ {menuType:'table', name:'bigint'},
79
+ ]},
80
+ {menuType:'menu', name:'config', menuContent:[
81
+ {name:'users', menuType:'table'},
82
+ ]},
83
+ ]}
84
+ }
85
+
86
+ ```
87
+ ### Procedures definition
88
+
89
+ #### procDef:
90
+
91
+ property | type | default value | use
92
+ ------------|------|-------------------------------|-----------------------------------------------------
93
+ action | T | | Name that will be invoked the procedure
94
+ bitacora | BO | { error:false, always:false } | Bitacora Object for core functions register
95
+ parameters | POA | `[]` | Param Objects Array
96
+ cacheable | Bool | false | The result can be cached
97
+ coreFunction| F | | Function that implements the procedure
98
+
99
+ #### bitacoraDef:
100
+
101
+ propiedad | tipo | default value | uso
102
+ ----------------------------------|----------------|----------------------------|-------------------
103
+ error | B | false | If true, bitacora saves data of error ocurred during core function execution
104
+ always | B | false | If true, bitacora saves all data ocurred during core function execution (overrides error)
105
+ targetTable | T | null | Tablename for update result of execution data (must to exists a record for update) (see **targetTableBitacoraFields**). Use null for ignore option
106
+ targetTableBitacoraFields | O | { **init_date**: 'init_date', **end_date**: 'end_date', **has_error**: 'has_error', **end_status**: 'end_status'} | Objects who defines the fields where **'targetTable'** will reply bitacora fields (If targetTable is null it's ommited)
107
+ targetTableUpdateFieldsCondition | A | null | Fields array to define update condition (each value must to be passed as parameter with the same field name)
108
+
109
+
110
+ #### paramDef:
111
+
112
+ property | type | default value | use
113
+ --------------|----------------|----------------|-------------------
114
+ name | T | | name of the parameter that is sent to the procedure
115
+ defaultValue | según typeName | | parameter default value
116
+ typeName | T | | to define the data type
117
+ label | T | name | if you don't want to use default value to display on screen
118
+
119
+ #### coreFunction(context, parameters)
120
+
121
+ context | uso
122
+ ---------|----------------------
123
+ be | backendApp object
124
+ username | username
125
+
126
+ Process definition example:
127
+
128
+ ```js
129
+ {
130
+ action:'count_without_isotopes',
131
+ bitacora:{
132
+ error:true,
133
+ always:true,
134
+ targetTable:'other_table',
135
+ targetTableBitacoraFields: {
136
+ init_date: 'fecha_hora_inicio',
137
+ end_date: 'fecha_hora_final',
138
+ has_error: 'hubo_error',
139
+ end_status: 'resultado'
140
+ },
141
+ targetTableUpdateFieldsCondition: ['id']
142
+ },
143
+ parameters:[
144
+ {name:'first_atomic_number', defaultValue:10, typeName:'integer'},
145
+ {name:'last_atomic_number' , defaultValue:99, typeName:'integer'},
146
+ ],
147
+ coreFunction:function(context, parameters){
148
+ return context.client.query(
149
+ `SELECT count(*) as number_of_elements
150
+ FROM ptable p left join isotopes i on p.atomic_number=i.atomic_number
151
+ WHERE i.atomic_number IS NULL
152
+ AND p.atomic_number between coalesce($1,0) and coalesce($2,999)`,
153
+ [parameters.first_atomic_number, parameters.last_atomic_number]
154
+ ).fetchUniqueRow().then(function(result){
155
+ return result.row.number_of_elements;
156
+ });
157
+ }
158
+ },
159
+ ```
160
+
161
+ ## def-config
162
+
163
+ ```js
164
+ /// def-config.ts
165
+ export defConfig=`
166
+ server:
167
+ port: 3000
168
+ base-url: /my-app
169
+ db:
170
+ motor: postgresql
171
+ host: localhost
172
+ database: my_app_db
173
+ user: my_app_user
174
+ install:
175
+ dump:
176
+ db:
177
+ owner: my_app_owner
178
+ client-setup:
179
+ title: My app
180
+ lang: es
181
+ `;
182
+
183
+ /// main.ts
184
+ import {defConfig} from "./def-config"
185
+
186
+ export function emergeMyApp<T extends Constructor<AppBackend>>(Base:T){
187
+ /// ...
188
+ configStaticConfig(){
189
+ super.configStaticConfig();
190
+ this.setStaticConfig(defConfig);
191
+ }
192
+ ///...
193
+ }
194
+
195
+ ```
196
+
197
+ The general application config is setted with `setStaticConfig`.
198
+ Any option can be overwrited in `local-config.yaml` file.
199
+
200
+ `BACKEND_PLUS_LOCAL_CONFIG` enviroment variable can be a `filename.yaml` with more config options.
201
+
202
+ ### config format:
203
+
204
+ entry | usage
205
+ -----------------------------|---------------
206
+ server |
207
+ .port | port where is listening
208
+ .base-url | base url added to domain name
209
+ .module-store |
210
+ install | (see Spanish)
211
+ .dump | (see Spanish)
212
+ ..db.owner | (see Spanish)
213
+ ..scripts.post-adapt | (see Spanish)
214
+ ..scripts.parts-order | (see Spanish)
215
+ devel | (see Spanish)
216
+ .delay | (see Spanish)
217
+ .cache-content | (see Spanish)
218
+ .forceShowAsEditable | (see Spanish)
219
+ login | (see Spanish)
220
+ .plus | (see Spanish)
221
+ ..allowHttpLogin | (see Spanish)
222
+ log | (see Spanish)
223
+ .req | (see Spanish)
224
+ .session | (see Spanish)
225
+ client-setup | (see Spanish)
226
+ .cursors | (see Spanish)
227
+ .skin | (see Spanish)
228
+ .menu | (see Spanish)
229
+ .title | (see Spanish)
230
+ .lang | (see Spanish)
231
+
232
+ ```yaml
233
+ install:
234
+ dump:
235
+ db:
236
+ owner: user_owner
237
+ scripts:
238
+ post-adapt: [special_triggers.sql, other_constraints.sql]
239
+ login:
240
+ plus:
241
+ allowHttpLogin: true
242
+ store:
243
+ module-name: file
244
+ log:
245
+ req: true
246
+ session: true
247
+ devel:
248
+ cache-content: true
249
+ ```
250
+
251
+ ## Install
252
+
253
+ ```sh
254
+ $ npm install backend-plus
255
+ ```
256
+
257
+ ## License
258
+
259
+ [MIT](LICENSE)
260
+
261
+ ----------------
262
+
263
+
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
13
  function verb(n) { return function (v) { return step([n, v]); }; }
14
14
  function step(op) {
15
15
  if (f) throw new TypeError("Generator is already executing.");
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
13
  function verb(n) { return function (v) { return step([n, v]); }; }
14
14
  function step(op) {
15
15
  if (f) throw new TypeError("Generator is already executing.");
@@ -1,12 +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
- )
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
12
  where semver_to_decimal(semver) is distinct from result;