Skip to content

Commit

Permalink
Merge pull request #2015 from bcgov/feature/ACLS-2312-QA-2
Browse files Browse the repository at this point in the history
Fix not nullable date field not allowing to save empty date
  • Loading branch information
trslater authored Dec 12, 2024
2 parents 02db183 + dc92c90 commit 4ae5c7f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export class ApplicationDecisionConditionDateDto {
@IsString()
uuid?: string;

@Transform(({ value }) => value.getTime())
@Transform(({ value }) => value && value.getTime())
@IsNumber()
date?: number;
date?: number | null;

@Transform(({ value }) => value && value.getTime())
@IsNumber()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class ApplicationDecisionConditionDate extends Base {
}

@AutoMap()
@Column({ type: 'timestamptz' })
date: Date;
@Column({ type: 'timestamptz', nullable: true })
date: Date | null;

@AutoMap()
@Column({ type: 'timestamptz', nullable: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export class NoticeOfIntentDecisionConditionDateDto {
@IsString()
uuid?: string;

@Transform(({ value }) => value.getTime())
@Transform(({ value }) => value && value.getTime())
@IsNumber()
date?: number;
date?: number | null;

@Transform(({ value }) => value && value.getTime())
@IsNumber()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class NoticeOfIntentDecisionConditionDate extends Base {
}

@AutoMap()
@Column({ type: 'timestamptz' })
date: Date;
@Column({ type: 'timestamptz', nullable: true })
date: Date | null;

@AutoMap()
@Column({ type: 'timestamptz', nullable: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class ApplicationDecisionProfile extends AutomapperProfile {
ApplicationDecisionConditionDateDto,
forMember(
(dto) => dto.date,
mapFrom((entity) => entity.date.getTime()),
mapFrom((entity) => entity.date && entity.date.getTime()),
),
forMember(
(dto) => dto.completedDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class NoticeOfIntentDecisionProfile extends AutomapperProfile {
NoticeOfIntentDecisionConditionDateDto,
forMember(
(dto) => dto.date,
mapFrom((entity) => entity.date.getTime()),
mapFrom((entity) => entity.date && entity.date.getTime()),
),
forMember(
(dto) => dto.completedDate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MakeConditionDateDatesNullable1734030229522 implements MigrationInterface {
name = 'MakeConditionDateDatesNullable1734030229522'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_date" ALTER COLUMN "date" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_decision_condition_date" ALTER COLUMN "date" DROP NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_decision_condition_date" ALTER COLUMN "date" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_date" ALTER COLUMN "date" SET NOT NULL`);
}

}

0 comments on commit 4ae5c7f

Please sign in to comment.