Skip to content
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

Ensure that date & relative date comparisons work in a consistent way across JSON, SQLite and MySQL #28

Open
ErisDS opened this issue Mar 2, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ErisDS
Copy link
Member

ErisDS commented Mar 2, 2022

NQL date handling is in an unmanageable state.

We have to manage across the following variables:

  • The format you use to insert into a DB (e.g. in fixtures) is different to what DBs return
  • The formats you can use to do a comparison like > or < is not consistent between SQLite and MySQL
  • The formats we return from the DB, and from our API endpoints can all be different
  • JSON comparisons seem to work in some cases and not others, but really we should be using ISODate
  • The mai use cases for dates are:
  1. get helpers, where the real use case looks like this:
    {{#get "posts" filter="published_at:<='{{published_at}}'+id:-{{id}}" limit="3"}}
    this means it depends what comes out of the API as to what goes back in...
    ref: https://ghost.org/docs/themes/helpers/get/#filter
  2. Prev & Next helpers which are builtins that do essentially the same thing, but they enforce that the right format
    ref: https://github.com/TryGhost/Ghost/blob/1cc38733ba6df8b8340420cff8fc7b643704c6ae/core/frontend/helpers/prev_post.js#L21
  3. relative date queries like last_seen_at>now-1d
    ref: Relative Dates #26

We need to make sure that dates work consistently in these 3 cases.

@ErisDS ErisDS changed the title Ensure that date and relative date comparisons actually work in a consistent way across JSON, SQLite and MySQL Ensure that date & relative date comparisons work in a consistent way across JSON, SQLite and MySQL Mar 3, 2022
@daniellockyer daniellockyer added the enhancement New feature or request label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants