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
{{ message }}
Repository navigation
Advanced query with :current-page return the same results with different values #4156
I can confirm that I also encounter this issue. It happens in MacOS desktop app, Windows desktop app as well as in mobile app on iOS.
The :current-page variable always remembers the first page it was used on (either it is somehow getting cached or it stops being updated after it gets initialized or used for the first time). Re-indexing the graph resets the variable but when it is used for the first time after re-indexing, it again keeps remembering the first page it was used on until next re-index.
My use case:
I have bunch of pages representing team members. On each of these pages there is this query - it's intention is to display tasks referencing (being assigned to) the particular person:
When I open the app and access John's page, the query correctly shows John's tasks. But when I then access Paul's page, it shows John's tasks (and continues showing John's tasks on all the persons' pages).
If I then re-index and go to Paul's page, it now correctly shows Paul's tasks. But when I then go to John's page, it still shows Paul's tasks and continues to do so until next re-index.
The issue is not limited to queries involving tasks. I was able to reproduce it with a different query involving the :current-page variable.
Hope this helps to determine the cause and fix it as it makes the queries using :current-page unusable at all.
Reacted by PDP-11, Ámbar Tenorio-Fornés and Mattias Petter Johansson
A workaround is to use the current page as part of the title of the query. This way, logseq knows they are different queries and calculate them independently.
Using templates makes it easy! the following query would work to list open tasks of current page (as it will add the name of the page to the title of the query:
I just stumbled upon this issue and it was pretty confusing! I am also on a mac and I was trying to reuse a query by referencing the block where the query is defined and using :current-page, but the query always shows the result of the first time it is run.
I don't like the workaround of having to define a template that gives a different title to each query, because then I will still have to duplicate the query many times (each time the template is instantiated) and it defeats the purpose of my strategy to only define the query in one place.
This problem has been driving me crazy for months! I use :current-page in a frequently used template, and couldn't understand why I have to do a full re-index every time I create a new page with the template. I hope this can be fixed. I'll try the workaround in the meantime!
People keep on bumping into this issue. This was just posted on Discuss. I also keep on seeing it come up on Discord. @logseq-cldwalker it might be a good idea to prioritize it.
changed the title [-]Advanced query with `:current-page` on macOS/iOS desktop app return wrong results when switching different pages[/-][+]Advanced query with :current-page return the same results with different values[/+]on Jan 10, 2023
@danilofaria
The current behavior of :current-page is "The current page of the main editing window", but with a cache issue (and fixed by #8263 thanks @oraluben !)
And there are another kind of report like #6528
They are expecting something like "The page that the query stored"?
Also wonder if there are users using this "The current page of the main editing window" as a trait (which fits the name :current-page) and the change of behavior would break the assumption.
I think it would be extremely useful to be able to take a block reference of a query and paste it in other places and the results change based on the current page where the query is being run.
This is the current behavior, except for this caching issue that shows one of the results only (not necessarily the result from the original page).
So fixing the caching issue and considering :current-page the page where the query is shown (not where it is stored) IMO is the expected behavior (and the current behavior too).
Adding a new custom input :query-page as suggested above also sounds good, as this would allow both things to be done.
Activity
ondrejpales commentedon Jul 18, 2022
I can confirm that I also encounter this issue. It happens in MacOS desktop app, Windows desktop app as well as in mobile app on iOS.
The :current-page variable always remembers the first page it was used on (either it is somehow getting cached or it stops being updated after it gets initialized or used for the first time). Re-indexing the graph resets the variable but when it is used for the first time after re-indexing, it again keeps remembering the first page it was used on until next re-index.
My use case:
I have bunch of pages representing team members. On each of these pages there is this query - it's intention is to display tasks referencing (being assigned to) the particular person:
#+BEGIN_QUERY {:title [:h3 "Taks mentioning this person"] :query [:find (pull ?b [*]) :in $ ?currentpage :where (page-ref ?b ?currentpage) (task ?b #{"NOW" "LATER" "TODO" "DOING"}) (or [?b :block/scheduled ?d] [?b :block/deadline ?d]) ] :result-transform (fn [result] (sort-by (fn [d] (get d :block/deadline) ) result )) :inputs [:current-page]} #+END_QUERYWhen I open the app and access John's page, the query correctly shows John's tasks. But when I then access Paul's page, it shows John's tasks (and continues showing John's tasks on all the persons' pages).
If I then re-index and go to Paul's page, it now correctly shows Paul's tasks. But when I then go to John's page, it still shows Paul's tasks and continues to do so until next re-index.
The issue is not limited to queries involving tasks. I was able to reproduce it with a different query involving the :current-page variable.
Hope this helps to determine the cause and fix it as it makes the queries using :current-page unusable at all.
atfornes commentedon Oct 20, 2022
This also happens in Linux, so it is not a macOS/iOS problem
I guess it is related to cached query results, as If I change the
:titleof the query, it recalculates the query with the expected results.atfornes commentedon Oct 20, 2022
A workaround is to use the current page as part of the title of the query. This way, logseq knows they are different queries and calculate them independently.
Using templates makes it easy! the following query would work to list open tasks of current page (as it will add the name of the page to the title of the query:
danilofaria commentedon Dec 4, 2022
I just stumbled upon this issue and it was pretty confusing! I am also on a mac and I was trying to reuse a query by referencing the block where the query is defined and using
:current-page, but the query always shows the result of the first time it is run.I don't like the workaround of having to define a template that gives a different title to each query, because then I will still have to duplicate the query many times (each time the template is instantiated) and it defeats the purpose of my strategy to only define the query in one place.
kerim commentedon Dec 28, 2022
This problem has been driving me crazy for months! I use :current-page in a frequently used template, and couldn't understand why I have to do a full re-index every time I create a new page with the template. I hope this can be fixed. I'll try the workaround in the meantime!
UPDATE: workaround seems to do the trick!
mpj commentedon Dec 31, 2022
God, this threw me out into a deep end, what a nasty subtle one, I thought I was going insane. The workaround works, but incredibly unintuitive.
danilofaria commentedon Jan 10, 2023
People keep on bumping into this issue. This was just posted on Discuss. I also keep on seeing it come up on Discord. @logseq-cldwalker it might be a good idea to prioritize it.
[-]Advanced query with `:current-page` on macOS/iOS desktop app return wrong results when switching different pages[/-][+]Advanced query with :current-page return the same results with different values[/+]cnrpman commentedon Jan 12, 2023
@danilofaria
The current behavior of
:current-pageis "The current page of the main editing window", but with a cache issue (and fixed by #8263 thanks @oraluben !)And there are another kind of report like #6528
They are expecting something like "The page that the query stored"?
Also wonder if there are users using this "The current page of the main editing window" as a trait (which fits the name
:current-page) and the change of behavior would break the assumption.oraluben commentedon Jan 12, 2023
This makes much more sense. The content of one page should be the same when it's embedded and not.
(and I think no one should expect the opposite!)
Edit: looks like a lot of people do rely on the current behavior🤔
bendyorke commentedon Jan 12, 2023
I've just submitted #8330 which proposes another custom input,
:query-page, that indeed will be the page the query is stored on.Hopefully having them live alongside each-other in the documentation will make it clear the difference and everyone get's both of best worlds :)
danilofaria commentedon Jan 12, 2023
I think it would be extremely useful to be able to take a block reference of a query and paste it in other places and the results change based on the current page where the query is being run.
This is the current behavior, except for this caching issue that shows one of the results only (not necessarily the result from the original page).
So fixing the caching issue and considering
:current-pagethe page where the query is shown (not where it is stored) IMO is the expected behavior (and the current behavior too).Adding a new custom input
:query-pageas suggested above also sounds good, as this would allow both things to be done.