dobo 2.30.3 → 2.30.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.
@@ -191,9 +191,10 @@ async function driverFactory () {
191
191
  }
192
192
 
193
193
  async _prepBodyForCreate (model, body = {}, options = {}) {
194
+ const { callHandler } = this.app.bajo
194
195
  const { isSet, generateId } = this.app.lib.aneka
195
196
  for (const prop of model.getProperties({ noVirtual: true })) {
196
- if (!isSet(body[prop.name]) && isSet(prop.default)) {
197
+ if (isSet(prop.default) && (!options.noDefault) && (!isSet(body[prop.name]) || body[prop.name] === prop.default)) {
197
198
  if (isFunction(prop.default)) body[prop.name] = await prop.default.call(model)
198
199
  else if (typeof prop.default !== 'string') body[prop.name] = prop.default
199
200
  else {
@@ -207,6 +208,9 @@ async function driverFactory () {
207
208
  body[prop.name] = ulid().slice(0, prop.maxLength)
208
209
  } else if (prop.default === 'generateid' && prop.type === 'string') {
209
210
  body[prop.name] = generateId()
211
+ } else if (prop.default.startsWith('handler:')) {
212
+ const [, ...args] = prop.default.split(':')
213
+ if (args.length > 0) body[prop.name] = await callHandler(args.join(':'))
210
214
  } else if (prop.default.startsWith('md5:') && prop.type === 'string') {
211
215
  const [, field] = prop.default.split(':')
212
216
  const fields = field.split(',')
@@ -14,9 +14,8 @@
14
14
  */
15
15
  async function sanitizeBody ({ body = {}, partial, strict, extFields = [], noDefault, truncateString, onlyTypes = [], action } = {}) {
16
16
  const { isSet } = this.app.lib.aneka
17
- const { callHandler } = this.app.bajo
18
17
  const { sanitizeByType } = this.app.dobo
19
- const { omit, has, isString } = this.app.lib._
18
+ const { omit, has } = this.app.lib._
20
19
  const result = {}
21
20
 
22
21
  const sanitize = (name, type) => {
@@ -27,7 +26,7 @@ async function sanitizeBody ({ body = {}, partial, strict, extFields = [], noDef
27
26
 
28
27
  const omitted = []
29
28
  const details = []
30
- const properties = [...this.getProperties(), ...extFields]
29
+ const properties = [...this.getNonVirtualProperties(), ...extFields]
31
30
  for (const prop of properties) {
32
31
  try {
33
32
  if (partial && !has(body, prop.name)) {
@@ -37,15 +36,6 @@ async function sanitizeBody ({ body = {}, partial, strict, extFields = [], noDef
37
36
  result[prop.name] = body[prop.name]
38
37
  if (prop.type === 'array' && isSet(result[prop.name]) && !Array.isArray(result[prop.name])) result[prop.name] = [result[prop.name]]
39
38
  if (isSet(result[prop.name])) sanitize(prop.name, prop.type)
40
- else {
41
- if (isSet(prop.default) && !noDefault) {
42
- result[prop.name] = prop.default
43
- if (isString(prop.default) && prop.default.startsWith('handler:')) {
44
- const [, ...args] = prop.default.split(':')
45
- if (args.length > 0) result[prop.name] = await callHandler(args.join(':'))
46
- } else sanitize(prop.name, prop.type)
47
- }
48
- }
49
39
  if (result[prop.name] === null) continue
50
40
  if (truncateString && isSet(result[prop.name]) && ['string', 'text'].includes(prop.type)) result[prop.name] = result[prop.name].slice(0, prop.maxLength)
51
41
  if (prop.name.endsWith('Id') && isSet(result[prop.name]) && prop.type === 'string' && ['smallint', 'integer'].includes(this.driver.idField.type)) result[prop.name] = result[prop.name] + ''
@@ -40,7 +40,8 @@ async function sanitizeRecord (record = {}, opts = {}) {
40
40
  let value = ['object', 'array'].includes(prop.type) ? cloneDeep(newRecord[key]) : newRecord[key]
41
41
  if (prop.values) {
42
42
  const values = await this.buildPropValues(prop, opts)
43
- value = (values.find(v => v.value === value) ?? {}).text ?? value
43
+ if (isArray(value)) value = value.map(v => (values.find(opt => opt.value === v) ?? {}).text ?? v)
44
+ else value = (values.find(v => v.value === value) ?? {}).text ?? value
44
45
  }
45
46
  if (prop.format === false) newRecord._fmt[key] = value + ''
46
47
  else if (isFunction(prop.format)) newRecord._fmt[key] = await prop.format.call(this, value, newRecord, opts)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dobo",
3
- "version": "2.30.3",
3
+ "version": "2.30.5",
4
4
  "description": "DBMS for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-06-24
4
+
5
+ - [2.30.5] Bug fix in ```model.sanitizeBody()```
6
+ - [2.30.5] Bug fix in ```model.sanitizeRecord()```
7
+
8
+ ## 2026-06-16
9
+
10
+ - [2.30.4] Bug fix in ```model.sanitizeBody()```
11
+ - [2.30.4] Bug fix in ```model._prepBodyForCreate()```
12
+
3
13
  ## 2026-06-13
4
14
 
5
15
  - [2.30.2] Bug fix in ```model.findAllRecord()```