Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Commit 8d87464

Browse files
committed
Make populate method optional
I know, I know. It's weird to have the populate() method in a PopulationService be optional. HOWEVER! there are a number of tables that we're populating through other services (e.g., meetings, course instances) and we may need to split those out into separate drop() functions so we can prevent deadlocks. Apparently there isn't a way to define an optional abstract method in an abstract class, but if we drop the abstract keyword from the method we can make it optional and it will still enforce the type rules on parameters and return values. See: microsoft/TypeScript#6413
1 parent 6125481 commit 8d87464

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎tests/mocks/database/population/base.population.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ import { Repository } from 'typeorm';
22
import { Injectable } from '@nestjs/common';
33
import { BaseEntity } from 'server/base/base.entity';
44
import { TestData } from './data';
5+
56
/**
67
* Abstract generic class for implementing the various population services
78
*/
8-
99
@Injectable()
1010
export abstract class BasePopulationService<E extends BaseEntity> {
1111
/** The repository associated with the specific Entity */
1212
protected repository: Repository<E>;
1313

1414
/**
15-
* Each Population service will need to provide it's own populate function,
15+
* Each Population service will need to provide its own populate function,
1616
* since it would be almost impossible to handle testData, relations, etc in
1717
* a generic way.
1818
* @param data A list of data to be entered into the database
1919
*/
20-
public abstract async populate(
21-
data: Record<string, TestData[]>
22-
): Promise<E[]>;
20+
public async populate?(data: Record<string, TestData[]>): Promise<E[]>;
2321

2422
/**
2523
* A generic drop function will simply call clear() (i.e. TRUNCATE) on the

0 commit comments

Comments
 (0)