You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! First of all - big apologies if such issue was already created at some point. I'm having a hard time trying to even google for it as i'm unsure how to form my search query properly for this one. Anyway, i have a objects table and two STI models using it
So, basically, it's a one big tree structure with objects associated with each other using in_reply_to_ap_object_id (which is a foreign key to either Article or Comment STI model, basically to Namespace::Object model instance. And now, when I'm doing the following:
a following record in hierarchies model is being created:
The problem is - for some reason unknown to me, the ancestor_id is set to the comment id instead of the article id (213 instead of 4) which leads to me not being able to fetch article comments using hash_tree method. I tried several ways of doing that but each has it's own quirks:
article.hash_tree - this produces SELECT "activity_pub_objects".* FROM "activity_pub_objects" INNER JOIN "activity_pub_object_hierarchies" ON "activity_pub_objects"."id" = "activity_pub_object_hierarchies"."descendant_id" WHERE "activity_pub_object_hierarchies"."ancestor_id" = $1 ORDER BY "activity_pub_object_hierarchies".generations ASC [["ancestor_id", 4]] query which obviously returns nothing as ancestor_id in DB is 213 not 4
article.replies.hash_tree - this returns only 0 generation of records, so just comment is being returned in the hash result. No comment2 as comment child.
article.children.hash_tree - nothing is returned, same query as in 1
I have a gut feeling it's related to the fact I'm using STI instead of having two separate models but that's a requirement of this specific app and i can't really change it.
PS. i just tested deep-nesting several comments and hash_tree works perfectly fine starting from zero level comment - so for my example comment.hash_tree returns a full comments tree as intented. It seems just using article as a source of hash_tree is breaking things
I would really appreciate any tips on this one! 🙏
The text was updated successfully, but these errors were encountered:
Alright, it can be easily reproductable using the folowing steps and i think that's a bug:
Define models as mentioned in original post
Try assigning a comment as a child of an article but using becomes method to make sure they are all the same type (i think that's the part that is broken in the gem because when I'm assigning comment to comment - all works fine):
becomes might probably be ignored because it's broken anyway. I just used it to try to remove all the moving parts but it didn't helped, so closure_tree is resolving to the proper STI type internally anyway i guess
3. Observe that parend_id was properly populated but the record for given comment (gen 0) in hierarchies table has an ancestor_id set to comment id instead of article id (so ancestor_id = descendant_id). It can be fixed by manually changing ancestor_id to article id but that's not a real solution obviously.
Hey! First of all - big apologies if such issue was already created at some point. I'm having a hard time trying to even google for it as i'm unsure how to form my search query properly for this one. Anyway, i have a
objects
table and two STI models using itSo, basically, it's a one big tree structure with objects associated with each other using
in_reply_to_ap_object_id
(which is a foreign key to eitherArticle
orComment
STI model, basically toNamespace::Object
model instance. And now, when I'm doing the following:a following record in hierarchies model is being created:
The problem is - for some reason unknown to me, the
ancestor_id
is set to the comment id instead of the article id (213 instead of 4) which leads to me not being able to fetch article comments usinghash_tree
method. I tried several ways of doing that but each has it's own quirks:article.hash_tree
- this producesSELECT "activity_pub_objects".* FROM "activity_pub_objects" INNER JOIN "activity_pub_object_hierarchies" ON "activity_pub_objects"."id" = "activity_pub_object_hierarchies"."descendant_id" WHERE "activity_pub_object_hierarchies"."ancestor_id" = $1 ORDER BY "activity_pub_object_hierarchies".generations ASC [["ancestor_id", 4]]
query which obviously returns nothing asancestor_id
in DB is213
not4
article.replies.hash_tree
- this returns only 0 generation of records, so justcomment
is being returned in the hash result. Nocomment2
ascomment
child.article.children.hash_tree
- nothing is returned, same query as in1
I have a gut feeling it's related to the fact I'm using STI instead of having two separate models but that's a requirement of this specific app and i can't really change it.
PS. i just tested deep-nesting several comments and
hash_tree
works perfectly fine starting from zero level comment - so for my examplecomment.hash_tree
returns a full comments tree as intented. It seems just usingarticle
as a source ofhash_tree
is breaking thingsI would really appreciate any tips on this one! 🙏
The text was updated successfully, but these errors were encountered: