jfinkels / flask-restless

NO LONGER MAINTAINED - A Flask extension for creating simple ReSTful JSON APIs from SQLAlchemy models.
https://flask-restless.readthedocs.io
GNU Affero General Public License v3.0
1.02k stars 301 forks source link

option for case insensitivity sorting #626

Open tarekziade opened 7 years ago

tarekziade commented 7 years ago

The JSON API spec does not tell if the sorting on string should be case sensitive.

The impact is that the sorting will be case sensitive by default on SA.

It would be great to have an option in flask_restless to allow case insensitive sorting.

See http://stackoverflow.com/a/17567525

I would assume a global config would be sufficient for this behaviour ?

jfinkels commented 7 years ago

I suppose this makes sense. I'm not sure which is better: a global configuration option or a per-model configuration option. In any case, I'd be willing to review a pull request that adds this. Once you figure out the configuration, you'd place it in the search module, probably here: https://github.com/jfinkels/flask-restless/blob/master/flask_restless/search/drivers.py#L122 (and in the other branch of the if/else as well).

tarekziade commented 7 years ago

I'm not sure which is better: a global configuration option or a per-model configuration option

Maybe we could have a global default that can be overwritten at the model-level

chfw commented 7 years ago

Hi, this use case caught me as well. Our tester flagged it up as a defect because they think the sorting on string terms should be case insensitive. However, flask-restless v0.16.0 does not allow me to do case-insensitive sorting on a particular api endpoint.

jfinkels commented 7 years ago

I have started to address this in pull request #631, in which I allow clients to request case-insensitive sorting on a per-request basis. I have not yet enabled server-side configuration of case-insensitive sorting by default.