Skip to content

Commit

Permalink
Only set attributes if they're not null or undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Bogart committed Feb 18, 2021
1 parent 50709e7 commit bec21a9
Show file tree
Hide file tree
Showing 3 changed files with 694 additions and 630 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/README.md
Expand Up @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Changed
- Only set attributes if they're not null or undefined.


## [v2.3.0]
Expand Down
10 changes: 6 additions & 4 deletions lib/attribute-assigner.ts
Expand Up @@ -77,10 +77,12 @@ export class AttributeAssigner<T> {

for (const name of attributeNames) {
const attribute = await this._get(name);
if (relationNames.includes(name)) {
await this.adapter.relate(this.evaluator.instance, name, attribute, this.model);
} else {
this.adapter.set(this.evaluator.instance, name, attribute);
if (attribute !== undefined && attribute !== null) {
if (relationNames.includes(name)) {
await this.adapter.relate(this.evaluator.instance, name, attribute, this.model);
} else {
this.adapter.set(this.evaluator.instance, name, attribute);
}
}
}

Expand Down

0 comments on commit bec21a9

Please sign in to comment.