| 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 { |