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

Missing Results in Models from PostgreSQL Views #514

Open green3g opened 8 years ago

green3g commented 8 years ago

I've got a strange issue with retrieving results from a model that is based on an SQL view in Postgres.

Flask-Restless only returns 9 of the results in the view, even though there are over 1000 total, my page[size] = 10 and page[number] = 1

I have tested the model in a python console, by importing it and running myModel.query.all() and it returns results as expected.

Another interesting note is that specifying a filter like

filter[objects]:[{"op":"==","name":"status","val":"ACTIVE"}]

returns a different set of 9 results.

jfinkels commented 8 years ago

Hi @roemhildtg, thanks for the report. Could definitely be an issue with the pagination. Can you try with the development version, or with version 1.0.0b1, which I published on PyPI about ten days ago? If it is still an issue, can you provide a minimum working example that demonstrates the problem?

(If this is indeed specific to PostgreSQL, I now have the testing framework capable of handling PostgreSQL tests; see TestNetworkOperators, for example.)

green3g commented 8 years ago

Tried with the development version, same result. I'll take a stab at writing a test case.

I believe the root of the problem is that Postgres views don't have a primary key. Could that have something to do with it?

jfinkels commented 8 years ago

Definitely could be, Flask-Restless depends pretty heavily on primary keys in various places. I'd have to spend some time looking at an example, since I haven't tested against Postgres views yet.