| 88 | } |
| 89 | |
| 90 | static capture(metadata: MetadataStorage, config: Configuration) { |
| 91 | const captured: { key: string; contextKeys: string[]; code: string }[] = []; |
| 92 | const original = Utils.createFunction; |
| 93 | Utils.createFunction = (context, code, _compiledFunctions, key) => { |
| 94 | captured.push({ key: key!, contextKeys: [...context.keys()], code }); |
| 95 | return original.call(Utils, context, code); |
| 96 | }; |
| 97 | |
| 98 | try { |
| 99 | const platform = config.getDriver().getPlatform(); |
| 100 | const hydrator = new ObjectHydrator(metadata, platform, config); |
| 101 | const comparator = new EntityComparator(metadata, platform, config); |
| 102 | |
| 103 | for (const meta of metadata) { |
| 104 | hydrator.getEntityHydrator(meta, 'full', false); |
| 105 | hydrator.getEntityHydrator(meta, 'full', true); |
| 106 | comparator.getEntityComparator(meta.class); |
| 107 | comparator.getSnapshotGenerator(meta.class); |
| 108 | comparator.getResultMapper(meta); |
| 109 | |
| 110 | if (!meta.embeddable && !meta.virtual) { |
| 111 | hydrator.getEntityHydrator(meta, 'reference', false); |
| 112 | hydrator.getEntityHydrator(meta, 'reference', true); |
| 113 | } |
| 114 | |
| 115 | if (meta.primaryKeys.length > 0) { |
| 116 | comparator.getPkGetter(meta); |
| 117 | comparator.getPkGetterConverted(meta); |
| 118 | comparator.getPkSerializer(meta); |
| 119 | } |
| 120 | } |
| 121 | } finally { |
| 122 | Utils.createFunction = original; |
| 123 | } |
| 124 | |
| 125 | return captured; |
| 126 | } |
| 127 | } |