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
Filter _between is not returning correct results on uploaded_on field for uploaded files #16336
Comments
This seems to be specific to SQLite, as I was not able to reproduce this on PostgreSQL. Additional findings: When we look at the Whereas PostgreSQL stores them in the same format (likely why not reproducible on PostgreSQL): when we inspect the SQL query formed during select
`directus_files`.`id`, `directus_files`.`modified_on`, `directus_files`.`type`, `directus_files`.`title`, `directus_files`.`filesize`
from `directus_files`
where ((`directus_files`.`uploaded_on` between ? and ?) and (`directus_files`.`type` is not null and `directus_files`.`folder` is null))
order by `directus_files`.`uploaded_on` desc
limit ?
[1667750400000, 1667836800000, 25] which might be why it worked on This is likely because directus/api/src/database/system-data/fields/files.yaml Lines 97 to 103 in 7899f6a
but directus/api/src/database/system-data/fields/files.yaml Lines 116 to 119 in 7899f6a
I then tested adding the following special to special:
- date-created So now when we upload a new file, The filter then seems to work properly for SQLite afterwards. However not 100% sure if this is the correct fix or the actual root cause (needs more testing with other non |
nice work! thank you for looking into this. if this is affecting sqlite, it makes me wonder what other db types are affected by this. what's the story behind "special" is it the same as this here? https://docs.directus.io/reference/system/fields.html i'm still new to the codebase and can't find more details on what options are available for it. |
IIRC other db types has been resolved in past (unless you meant db vendors), so this should just be something that somehow flew under the radar for SQLite 👍 especially since both of the fields have the same directus/api/src/database/seeds/07-files.yaml Lines 34 to 35 in c303bdc
directus/api/src/database/seeds/07-files.yaml Lines 43 to 44 in c303bdc
Yeah that's correct!
Generally it shouldn't be something to be tinkered by a user, so there isn't much explicit detail on it in the docs (but could be a good thing to include nonetheless!). Ideally Directus will handle it seamlessly for you so there shouldn't be a need to modify/know them, but just to share more info in terms of codebase, they are primarily being "processed" (or cast/transform) over here: directus/api/src/services/payload.ts Lines 51 to 139 in c303bdc
|
Linear: ENG-143 |
Here's what i noticed, both modified on and uploaded on are datetime with When i tried inserting manually Fields without special are not inserted/updated from app, hence for Sqlite doesnt enforce any specific type on datetime applications can insert in one of the allowed formats so, 1 of these 3 approaches is what we probably can take
|
Describe the Bug
Both my modified_on field and upload_on field have roughly the same timestamps (+/- a few seconds or minutes) and I'll count them as the same for this example.
I can filter on the following and get results:
However, when I replace it with "uploaded_on" I don't get any results. This is also reflected in the UI via the search bar.
To Reproduce
Errors Shown
No response
What version of Directus are you using?
9.20.4
What version of Node.js are you using?
18
What database are you using?
sqlite
What browser are you using?
msedge
How are you deploying Directus?
official container
The text was updated successfully, but these errors were encountered: