Skip to content

Commit

Permalink
perf(core): Improve hydrator performance for customFields (#2961)
Browse files Browse the repository at this point in the history
Remove a workaround that led to refetching relations in customFields.
Prevent refetching of customFields during hydration
  • Loading branch information
jnugh authored Jul 19, 2024
1 parent 620eeb1 commit f40761d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,16 @@ export class EntityHydrator {
const missingRelations: string[] = [];
for (const relation of options.relations.slice().sort()) {
if (typeof relation === 'string') {
const parts = !relation.startsWith('customFields') ? relation.split('.') : [relation];
const parts = relation.split('.');
let entity: Record<string, any> | undefined = target;
const path = [];
for (const part of parts) {
path.push(part);
// null = the relation has been fetched but was null in the database.
// undefined = the relation has not been fetched.
if (entity && entity[part] === null) {
break;
}
if (entity && entity[part]) {
entity = Array.isArray(entity[part]) ? entity[part][0] : entity[part];
} else {
Expand Down

0 comments on commit f40761d

Please sign in to comment.