Skip to content

Commit

Permalink
fix: log error on missing required fields when finding with fields se…
Browse files Browse the repository at this point in the history
…lection
  • Loading branch information
onhate committed Jul 3, 2024
1 parent c72ae56 commit 16741d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,12 @@ export class Model {
}
} else if (value === undefined) {
if (field.required) {
/*
Transactions transform the properties to return something, but
does not have all the properties and required fields may be missing)
/*
Transactions transform the properties to return something, but
does not have all the properties and required fields may be missing).
Also find operation with fields selections may not include required fields.
*/
if (!params.transaction) {
if (!params.transaction && !params.fields) {
this.table.log.error(`Required field "${name}" in model "${this.name}" not defined in table item`, {
model: this.name, raw, params, field,
})
Expand Down Expand Up @@ -1607,7 +1608,7 @@ export class Model {
delete properties[name]
if (this.getPartial(field, params) === false && pathname.match(/[[.]/)) {
/*
Partial disabled for a nested object
Partial disabled for a nested object
Don't create remove entry as the entire object is being created/updated
*/
continue
Expand Down Expand Up @@ -2034,7 +2035,7 @@ export class Model {

/*
Return if a field supports partial updates of its children.
Only relevant for fields with nested schema
Only relevant for fields with nested schema
*/
getPartial(field, params) {
let partial = params.partial
Expand Down

0 comments on commit 16741d6

Please sign in to comment.