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
I was working on the methods next() and prev() and I found an issue when localised documents are present (like in the test suite). Add this test to documents/document_test.py
to expose it. The problem is that Document objects do not compare the locale in __eq__, so when the list of documents is scanned to find the current document at https://github.com/grow/grow/blob/main/grow/documents/document.py#L579 the returned document is the first of the localised, and the next is the next of the localised. In the testing suite, contact.yaml is localised in order in it, fr, and de, and the test always finds the it version, whose next() is the fr one.
Aside from the bug, I'm not sure what it the design choice here: shall next() be the next document in the collection including localisations or not?
The text was updated successfully, but these errors were encountered:
Further investigation makes me question how document comparison is handled. All comparison methods on Document (e.g. __ge__, __gt__, and so on) compare the tuple (self.pod_path, str(self.locale)), leading me to think that two documents are the same only if they have the same tuple of values. But __eq__ compares only the root_pod_path, ignoring the locale.
I was working on the methods
next()
andprev()
and I found an issue when localised documents are present (like in the test suite). Add this test todocuments/document_test.py
to expose it. The problem is that
Document
objects do not compare the locale in__eq__
, so when the list of documents is scanned to find the current document at https://github.com/grow/grow/blob/main/grow/documents/document.py#L579 the returned document is the first of the localised, and the next is the next of the localised. In the testing suite,contact.yaml
is localised in order init
,fr
, andde
, and the test always finds theit
version, whosenext()
is thefr
one.Aside from the bug, I'm not sure what it the design choice here: shall
next()
be the next document in the collection including localisations or not?The text was updated successfully, but these errors were encountered: