Skip to content

Discourse Context query error when source/destination and label/complement are the same #292

Description

@mdroidian

image

If Source and Destination are the same, and label and complement are the same, the query is incorrect.

This is correct:

{
    "label": "IsTo",
    "isComplement": false,
    "complement": "Is",
    "query": "[:find
      (pull ?B [:block/string :node/title :block/uid])
      (pull ?B [:block/uid])
    :where
      [?q51u-D_tL-DstPage :block/uid "bvkjLRgcq"]
      [?q51u-D_tL-LinkPage :node/title "Informs"]
      [?q51u-D_tL-DstPage :block/uid ?q51u-D_tL-bvkjLRgcq-uid]
      [?bvkjLRgcq :block/uid ?q51u-D_tL-bvkjLRgcq-uid]
      [?q51u-D_tL-DstBlock :block/refs ?q51u-D_tL-DstPage]
      [?q51u-D_tL-SrcBlock :block/refs ?q51u-D_tL-LinkPage]
      [?q51u-D_tL-SrcBlock :block/refs ?q51u-D_tL-SrcPage]
      [?q51u-D_tL-SrcPage :node/title ?q51u-D_tL-SrcPage-Title]
      [?q51u-D_tL-SrcPage :block/uid ?q51u-D_tL-B-uid]
      [?B :block/uid ?q51u-D_tL-B-uid]
      [?q51u-D_tL-SrcBlock :block/parents ?q51u-D_tL-DstBlock]  <---------------- here
      [(re-pattern "^\\[\\[B\\]\\] - (.*?)$") ?q51u-D_tL-B-.*?$-regex]
      [(re-find ?q51u-D_tL-B-.*?$-regex ?q51u-D_tL-SrcPage-Title)]
    ]"
}
{
    "label": "IsTo",
    "isComplement": true,
    "complement": "Is",
    "query": "[:find
      (pull ?B [:block/string :node/title :block/uid])
      (pull ?B [:block/uid])
    :where
      [?V7jh3UXLx-SrcPage :block/uid "bvkjLRgcq"]
      [?V7jh3UXLx-LinkPage :node/title "Informs"]
      [?V7jh3UXLx-SrcPage :block/uid ?V7jh3UXLx-bvkjLRgcq-uid]
      [?bvkjLRgcq :block/uid ?V7jh3UXLx-bvkjLRgcq-uid]
      [?V7jh3UXLx-SrcBlock :block/refs ?V7jh3UXLx-SrcPage]
      [?V7jh3UXLx-SrcBlock :block/refs ?V7jh3UXLx-LinkPage]
      [?V7jh3UXLx-SrcBlock :block/parents ?V7jh3UXLx-DstBlock]
      [?V7jh3UXLx-DstBlock :block/refs ?V7jh3UXLx-DstPage]
      [?V7jh3UXLx-DstPage :node/title ?V7jh3UXLx-DstPage-Title]
      [?V7jh3UXLx-DstPage :block/uid ?V7jh3UXLx-B-uid]
      [?B :block/uid ?V7jh3UXLx-B-uid] <-------------------------------- here
      [(re-pattern "^\\[\\[B\\]\\] - (.*?)$") ?V7jh3UXLx-B-.*?$-regex]
      [(re-find ?V7jh3UXLx-B-.*?$-regex ?V7jh3UXLx-DstPage-Title)]
    ]"
}

But when label and complement are the same, this is the query for the complement (well, both)

{
    "label": "IsTo",
    "isComplement": true,
    "complement": "IsTo",
    "query": "[:find
        (pull ?B [:block/string :node/title :block/uid])
        (pull ?B [:block/uid])
      :where
        [?MiOfaAb0r-DstPage :block/uid "bvkjLRgcq"]
        [?MiOfaAb0r-LinkPage :node/title "Informs"]
        [?MiOfaAb0r-DstPage :block/uid ?MiOfaAb0r-bvkjLRgcq-uid]
        [?bvkjLRgcq :block/uid ?MiOfaAb0r-bvkjLRgcq-uid]
        [?MiOfaAb0r-DstBlock :block/refs ?MiOfaAb0r-DstPage]
        [?MiOfaAb0r-SrcBlock :block/refs ?MiOfaAb0r-LinkPage]
        [?MiOfaAb0r-SrcBlock :block/refs ?MiOfaAb0r-SrcPage]
        [?MiOfaAb0r-SrcPage :node/title ?MiOfaAb0r-SrcPage-Title]
        [?MiOfaAb0r-SrcPage :block/uid ?MiOfaAb0r-B-uid]
        [?B :block/uid ?MiOfaAb0r-B-uid]
        [?MiOfaAb0r-SrcBlock :block/parents ?MiOfaAb0r-DstBlock] <---------------- here
        [(re-pattern "^\\[\\[B\\]\\] - (.*?)$") ?MiOfaAb0r-B-.*?$-regex]
        [(re-find ?MiOfaAb0r-B-.*?$-regex ?MiOfaAb0r-SrcPage-Title)]
      ]"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions