xiaohutai / jsonapi

[Bolt Extension] JSON API for Bolt CMS
https://market.bolt.cm/view/bolt/jsonapi
MIT License
55 stars 18 forks source link

Bug: json sortorder datepublish / -datepublish not working #19

Closed peterboorsma closed 8 years ago

peterboorsma commented 8 years ago

@jadwigo discovered a bug in the ordering of content with datepublish.

Both http://programma.greatwideopen.nl/json/berichten?page%5Bsize%5D=10&sort=datepublish http://programma.greatwideopen.nl/json/berichten?page%5Bsize%5D=10&sort=-datepublish give the same results.

xiaohutai commented 8 years ago

Hi @peterboorsma,

I've made a potential fix: https://github.com/xiaohutai/jsonapi/commit/b2fe711f8f72c32e2e9d29e02b5edf3f04930bb6 (you could do this manually, but I'm not sure if this would interfere with updates in the future).

I'm not sure if the extension can be updated at the moment, as someone needs to trigger the marketplace update: [ pinging @bobdenotter ]

Once that's done, update to dev-master (or v3.0.0-beta2 if available).

Thanks

xiaohutai commented 8 years ago

Ping @Raistlfiren, do you perhaps know more about this? See https://github.com/xiaohutai/jsonapi/commit/b2fe711f8f72c32e2e9d29e02b5edf3f04930bb6 The sort didn't do anything, but with this change sort works, but you get an ambiguous error if this sort is not set.

Something with ORDER BY id ASC that DBAL doesn't know which id (contenttype vs taxonomy) it is. However, I'm afraid that don't have much time to dig into this.

xiaohutai commented 8 years ago

Should be fixed now. However, it may take a while for this to be updated in the stores. The dev-master version should work as far as I know.

All credits go to @Raistlfiren

Raistlfiren commented 8 years ago

I am closing this issue. If you run into the problem again please create a new issue.

bobdenotter commented 8 years ago

I don't think this has been fixed yet..

See: http://programma.greatwideopen.nl/json/berichten?page%5Bsize%5D=10

The config has this:

contenttypes:
    berichten:
        where-clause:
            status: 'published'
        order: -datepublish
        list-fields: [ id, title, subtitle, slug, teaser, body, video, embed, image, tags, categorieen, datepublish ]
bobdenotter commented 8 years ago

(And yes, I've double-checked that it's running version 3.0.1 of the extension)

xiaohutai commented 8 years ago

Are you sure that order worked in config.yml in the old version as I can't seem to be sure about that one.

If you call this: http://programma.greatwideopen.nl/json/berichten?page%5Bsize%5D=10&sort=-datepublish

it does work.