Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • psiho 101 posts 96 karma points
    Jul 16, 2013 @ 15:14
    psiho
    0

    IsRelated does not care for bidirectional relations

    Like this page documents: http://our.umbraco.org/documentation/Reference/Querying/uQuery/Relations

    IsRelated(int, int)

    Returns: bool

    Returns true if a relationship was found between the two ids for the current RelationType.

    When the RelationType has it's direction configured as a parent to child, the order of the parameters is significant (first is parent, second is child).

     

    But it is not so. IsRelated returns wrong result for bidirectional relations. I checked the source code all the way up to version 7. In src/umbraco.cms/businesslogic/relation/Relation.cs Line 141 says:

    int count = SqlHelper.ExecuteScalar<int>("SELECT count(*) FROM umbracoRelation WHERE childId = @childId AND parentId = @parentId",

    ... so I guess this is a known bug?

     

     

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies