Open sheoak opened 4 months ago
Hi @sheoak , thank you for the issue. I'll check what is going on there and will update you here. It is probably a bug
Looked at the implementation - fetch_all_links
doesn't implement fetching BackLink
s. Maybe @roman-right accidently forgot it.
In this case the following happens:
Document.fetch_all_links
calls Document.fetch_link
for each linkDocument.fetch_link
is executed, where ref_obj
is of type list[BackLink]
if isinstance(ref_obj, list) and ref_obj:
values = await Link.fetch_list(ref_obj, fetch_links=True)
setattr(self, field, values)
Note that Link.fetch_list
is called
Link.repack_links
to get linked documents that aren't fetched yetid
from the link here and fails, because BackLink
doesn't have id
So at the moment you have to use find
methods
So at the moment you have to use
find
methods
I'm not quite sure if this is related, but when I try to find documents that have a BackLink I get an error, that the BackLink field can not be encoded If you have any ideas how to work around this, please tell me 😉
I don't know if this is related, but in Pydantic v2 it seems like the way to define a BackLink
s original_field
is different from the description in the docs. From reading the source code the following seems to be the way to do it:
class Door(Document):
house: BackLink[House] = Field(json_schema_extra={"original_field": "door"})
as opposed to
class Door(Document):
house: BackLink[House] = Field(original_field="door")
I don't know if this is related, but in Pydantic v2 it seems like the way to define a
BackLink
soriginal_field
is different from the description in the docs
Yes, and the new format is poorly documented. But it still doesn’t work in my case.
Any updates on this?
Any updates on this? Is there a way on demand fetch one particular BackLink field? Can someone share an example?
Yeah, this is causing issues for us as well, the weird part is that it seems to periodically work. Has any work been done on this?
it also seems that there are a lot of tickets on nested links not populating that have been closed by the bot even though they have not been completed. on the links we can run through the object and force them to populate, but because it isnt really possible to fetch a backlink after the initial search, this becomes quite difficult
Will this be resolved in the near future ?
Beside that it's a lot of try and error to get the magic behind it ... the documentation is kinda minimal when it comes to stuff like that. At the moment the whole code we use isn't even remotely populating something on the list of backlinked documents.
Describe the bug When creating backlinks, the documentation (to my knowledge) doesn’t show a way to retrieve them immediately. This has been asked several times in the questions section, but I realized none of them are answered so I post this as an issue now.
Is there a way to populate the backlink, similar to fetch_all_links with Link objects? (see example below)
To Reproduce Considering the definitions below:
The following does NOT work:
This works:
Expected behavior Backlinks should be populated