Skip to content

Commit

Permalink
fix: filter on operator & validate referenceId
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSmallenbroek committed Sep 27, 2024
1 parent 932bc31 commit ccfa983
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export class RegistrationsPaginationService {

queryBuilder = this.addPaymentFilter(queryBuilder, query);

if (query?.filter?.referenceId?.includes('$ilike') === false) {
// Replacing the filter on referenceId is needed in specific cases where the referenceId only consists of numbers.
// The includes('$') === false is needed to check if the query doesn't contain an '$ilike' operator.
// If the filter has a '$' we don't need to replace the filter
if (query?.filter?.referenceId?.includes('$') === false) {
queryBuilder.andWhere('CAST("referenceId" AS TEXT) = :referenceId', {
referenceId: query.filter.referenceId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ export class RegistrationsInputValidator {
i: number,
validationConfig: ValidationConfigDto,
): Promise<ValidateRegistrationErrorObjectDto | undefined> {
if (row.referenceId && row.referenceId.includes('$')) {
return {
lineNumber: i + 1,
column: GenericAttributes.referenceId,
value: row.referenceId,
error: 'referenceId contains a $ character',
};
}
if (validationConfig.validateExistingReferenceId && row.referenceId) {
const registration = await this.registrationRepository.findOne({
where: { referenceId: Equal(row.referenceId) },
Expand Down

0 comments on commit ccfa983

Please sign in to comment.