Skip to content

Conversation

alexdlukens
Copy link

This is my proposed solution for #1189. Please find the minimal code example in the issue report.

This fixes serialization in the case when BackLink data has been fetched using fetch_links=True. In this situation, the BackLink field contains a Document object, which does not have the document_class attribute.

Thanks,

@alexdlukens alexdlukens force-pushed the fix-backlink-return-collection branch from 337d6f7 to 80da15b Compare July 19, 2025 16:10
@alexdlukens alexdlukens changed the title use class from self.__class__ if document_class does not exist when serializing BackLinks use class from self.__class__ when serializing BackLinks with fetched data Jul 19, 2025
@CAPITAINMARVEL
Copy link
Contributor

CAPITAINMARVEL commented Aug 27, 2025

This is my proposed solution for #1189. Please find the minimal code example in the issue report.

This fixes serialization in the case when BackLink data has been fetched using fetch_links=True. In this situation, the BackLink field contains a Document object, which does not have the document_class attribute.

Thanks,

maybe a getattr(self, "document_class", self.class) instead ?

With attribute:
try/except: 0.0754515000153333
getattr: 0.08347969996975735

Without attribute:
try/except: 0.4134541000239551
getattr: 0.08493790001375601

this is what i got with a testing script (using timeit)

This is the case when BackLink data has been fetched using fetch_links=True
@alexdlukens alexdlukens force-pushed the fix-backlink-return-collection branch from 80da15b to 2685fae Compare August 28, 2025 03:51
@CAPITAINMARVEL CAPITAINMARVEL requested a review from a team August 28, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants