(
protected readonly metadata: MetadataStorage,
readonly entityName: EntityName<T>,
readonly parent?: ICriteriaNode<T>,
readonly key?: EntityKey<T> | RawQueryFragmentSymbol,
readonly validate = true,
readonly strict = false,
)
| 23 | index?: number; |
| 24 | |
| 25 | constructor( |
| 26 | protected readonly metadata: MetadataStorage, |
| 27 | readonly entityName: EntityName<T>, |
| 28 | readonly parent?: ICriteriaNode<T>, |
| 29 | readonly key?: EntityKey<T> | RawQueryFragmentSymbol, |
| 30 | readonly validate = true, |
| 31 | readonly strict = false, |
| 32 | ) { |
| 33 | const meta = parent && metadata.find<T>(parent.entityName); |
| 34 | |
| 35 | if (meta && key && !RawQueryFragment.isKnownFragmentSymbol(key)) { |
| 36 | const pks = Utils.splitPrimaryKeys<T>(key); |
| 37 | |
| 38 | if (pks.length > 1) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | for (const k of pks) { |
| 43 | this.prop = meta.props.find( |
| 44 | prop => |
| 45 | prop.name === k || (prop.fieldNames?.length === 1 && prop.fieldNames[0] === k && prop.persist !== false), |
| 46 | ); |
| 47 | const isProp = this.prop || meta.props.find(prop => (prop.fieldNames || []).includes(k)); |
| 48 | |
| 49 | // do not validate if the key is prefixed or type casted (e.g. `k::text`) |
| 50 | if (validate && !isProp && !k.includes('.') && !k.includes('::') && !Utils.isOperator(k)) { |
| 51 | throw new Error(`Trying to query by not existing property ${Utils.className(entityName)}.${k}`); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any { |
| 58 | return this.payload; |
nothing calls this directly
no test coverage detected