MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / wrapWrite

Method wrapWrite

packages/sql/src/plugin/transformer.ts:671–684  ·  view source on GitHub ↗
(prop: EntityProperty | undefined, fieldName: string | undefined, valueNode: ValueNode)

Source from the content-addressed store, hash-verified

669 }
670
671 wrapWrite(prop: EntityProperty | undefined, fieldName: string | undefined, valueNode: ValueNode): OperationNode {
672 if (!prop?.hasConvertToDatabaseValueSQL || !fieldName || valueNode.value == null || isRaw(valueNode.value)) {
673 return valueNode;
674 }
675 const customType = this.fieldType(prop, fieldName);
676 if (!customType?.convertToDatabaseValueSQL) {
677 return valueNode;
678 }
679 const fragments = customType.convertToDatabaseValueSQL('?', this.#platform).split('?');
680 return RawNode.create(
681 fragments,
682 fragments.slice(0, -1).map(() => valueNode),
683 );
684 }
685
686 /** Resolve the customType for a specific field name (handles composite-PK FK fan-out via prop.customTypes[]). */
687 fieldType(prop: EntityProperty, fieldName: string): Type<any> | undefined {

Callers 2

processInsertValuesMethod · 0.95
processInputValueNodeMethod · 0.95

Calls 6

fieldTypeMethod · 0.95
isRawFunction · 0.90
sliceMethod · 0.80
createMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected