Skip to content

Commit

Permalink
chore: improve validation for missing metadata
Browse files Browse the repository at this point in the history
related: #3180
  • Loading branch information
B4nan committed Jun 3, 2022
1 parent 74b5488 commit eb03759
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/entity/ArrayCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AnyEntity, EntityDTO, EntityProperty, IPrimaryKey, Primary } from
import { Reference } from './Reference';
import { wrap } from './wrap';
import { ReferenceType } from '../enums';
import { MetadataError } from '../errors';
import { Utils } from '../utils/Utils';

export class ArrayCollection<T, O> {
Expand Down Expand Up @@ -166,7 +167,13 @@ export class ArrayCollection<T, O> {
*/
get property(): EntityProperty<T> {
if (!this._property) {
const meta = this.owner.__meta!;
const meta = this.owner.__meta;

/* istanbul ignore if */
if (!meta) {
throw MetadataError.missingMetadata(this.owner.constructor.name);
}

const field = Object.keys(meta.properties).find(k => this.owner[k] === this);
this._property = meta.properties[field!];
}
Expand Down

0 comments on commit eb03759

Please sign in to comment.