-
-
Notifications
You must be signed in to change notification settings - Fork 88
Implemented sort order for DAV documents #1434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented sort order for DAV documents #1434
Conversation
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #1431 by implementing sort order functionality in document fetching and updating the associated UI provider. Key changes include adding a new ordered query function to WebDavDocumentsDao, integrating sort order processing in DavDocumentsProvider, and updating documentation in WebDavDocument.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
app/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt | Implements sorting logic based on the sortOrder parameter |
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt | Introduces dynamic ordering via getChildrenOrdered |
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocument.kt | Adds documentation reminder for column name changes |
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
d7bdcb0
to
5b905dc
Compare
…io-files-via-android-document-provider-saf-via-playbook
…sing-audio-files-via-android-document-provider-saf-via-playbook' into 1431-file-order-issue-when-accessing-audio-files-via-android-document-provider-saf-via-playbook
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
I've created a new function for processing the order by request to make sure its format is correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a sort order for DAV documents by adding a new sorting method and integrating it within the document provider and DAO layer. Key changes include:
- Adding a processOrderByQuery method with its corresponding tests.
- Updating DavDocumentsProvider to use processOrderByQuery when fetching children.
- Modifying the DAO query in WebDavDocumentDao to accept a dynamic orderBy parameter and updating related documentation.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
DavDocumentsProviderTest.kt | Added tests for verifying the processOrderByQuery method's functionality. |
DavDocumentsProvider.kt | Implemented processOrderByQuery and integrated it into the children query flow. |
WebDavDocumentDao.kt | Updated the getChildren query to include an ORDER BY clause using a dynamic parameter. |
WebDavDocument.kt | Added a documentation note regarding column name changes. |
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, looks like it should be working, but this is really complex. Do we really need it to be a single method? ( @rfc2822 ) I can't help but think that we could reduce some complexity.
If not using multiple query methods, then maybe by using an enum to pass in the different combinations as arguments and hereby reduce some of the parsing and stringbuilding complexity.
Would be my preferred way since it's easier to reason about, but I think it should work like this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a test for ORDER BY
in the @Query
and it fails.
As I understand it, prepared statements / bind parameters don't work for identifiers / clauses. They can only replace values. Can you please double-check?
If that's true, I think we need to use @RawQuery
to construct a query (ideally with some helper like SQLiteQueryBuilder.buildQuery()
).
We should probably
- get arbitrary sorting with multiple fields working (+ test), and then
- write a function that parses the incoming sort order, takes the order fields and constructs a new ORDER BY with only the supported fields (will probably look very much like
processOrderByQuery
, maybe a bit more separated).
…io-files-via-android-document-provider-saf-via-playbook
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
…io-files-via-android-document-provider-saf-via-playbook
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
…io-files-via-android-document-provider-saf-via-playbook
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
…sing-audio-files-via-android-document-provider-saf-via-playbook' into 1431-file-order-issue-when-accessing-audio-files-via-android-document-provider-saf-via-playbook
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a sort order for DAV documents by integrating a new function in WebDavDocumentsDao along with a DocumentSortByMapper that validates and converts content provider sort directives into SQL clauses. Key changes include:
- Adding a new mapping function in DocumentSortByMapper and corresponding tests in DocumentSortByMapperTest.
- Refactoring DavDocumentsProvider to inject and use DocumentSortByMapper for preparing SQL order clauses.
- Extending WebDavDocumentDao with a RawQuery-based getChildren method that supports dynamic order clauses and updating tests accordingly.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
DocumentSortByMapperTest.kt | Added tests covering various column and direction mappings. |
DocumentSortByMapper.kt | Introduced logic to convert content provider order strings into validated SQL order clauses. |
DavDocumentsProvider.kt | Updated to use the new mapper and pass the computed SQL sort clause to the DAO. |
WebDavDocumentDao.kt | Extended with a new DAO method that accepts custom order clauses via a raw query. |
WebDavDocument.kt | Minor updates: comment update regarding column name changes. |
DavDocumentsProviderTest.kt, WebDavDocumentDaoTest.kt | Updated tests reflecting the new sort order logic. |
app/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt
Outdated
Show resolved
Hide resolved
…WebDavDocumentDao.DEFAULT_ORDER instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Implements configurable sort ordering for DAV documents by extending the DAO and wiring in a content‐provider–to–SQL mapping.
- Introduces
DocumentSortByMapper
to translate providersortOrder
strings to SQL clauses. - Extends
WebDavDocumentDao
with a raw-query–basedgetChildren(parentId, orderBy)
method and deprecates the old overload. - Integrates the new mapper and DAO method into
DavDocumentsProvider
and updates tests accordingly.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
app/src/main/kotlin/at/bitfire/davdroid/webdav/DocumentSortByMapper.kt | Adds mapper for translating content-provider sort fields to SQL. |
app/src/test/kotlin/at/bitfire/davdroid/webdav/DocumentSortByMapperTest.kt | Unit tests covering valid/invalid sort strings for mapper. |
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt | Adds raw-query–based getChildren(parentId, orderBy) and default. |
app/src/androidTest/kotlin/at/bitfire/davdroid/db/WebDavDocumentDaoTest.kt | Integration tests for DAO sorting behavior. |
app/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt | Hooks in the mapper and new DAO overload to apply sortOrder . |
app/src/androidTest/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProviderTest.kt | Adjusts expected child ordering in provider tests. |
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocument.kt | Adds a comment reminder for column-name dependencies. |
Comments suppressed due to low confidence (1)
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt:27
- Room’s @RawQuery usually expects a parameter of type SupportSQLiteQuery (or RoomSQLiteQuery). Please verify that
RoomRawQuery
is the correct type here or switch toSupportSQLiteQuery
to ensure Room can generate the implementation.
fun query(query: RoomRawQuery): List<WebDavDocument>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have
- moved the complex logic out into a new class (using Hilt for the logger),
- adapted the logic to be more understandable,
- added a default order by name when not specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor comments only, but I did not test it. How did you guys test it? Which app did you use?
app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProviderTest.kt
Show resolved
Hide resolved
AOSP Files from the emulator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good I think. Works as it should.
Purpose
See #1431, sort order is not being applied in
DavDocumentsProvider
.Short description
WebDavDocumentsDao
that takes a, order by argument.sortOrder
inDavDocumentsProvider
.Checklist