Skip to content

Commit

Permalink
allow transformers to run on null or undefined values
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdave committed Jan 4, 2019
1 parent f7aae31 commit 6295a36
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/driver/postgres/PostgresDriver.ts
Expand Up @@ -429,8 +429,14 @@ export class PostgresDriver implements Driver {
* Prepares given value to a value to be persisted, based on its column type or metadata.
*/
prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any {
if (value === null || value === undefined)
if (value === null || value === undefined) {
if (columnMetadata.transformer) {
// allow transformers to run on null or undefined values
return columnMetadata.transformer.from(value);
}

return value;
}

if (columnMetadata.type === Boolean) {
value = value ? true : false;
Expand Down

0 comments on commit 6295a36

Please sign in to comment.