I'm trying to use flask-restless against an Informix database. Informix returns a decimal type for count. For example, "select count(id) as c1 from users" would return c1 as Decimal('26'). Because of this, flask-restless throws an exception when trying to create the JSON of num_results. I'm finding this against the 0.17 version.
Even though Informix returns a Decimal type for the count, it looks like it could be safely cast to an Int in the context of generating num_results. I see two possible files where this could be addressed: in the helpers.py in the count function the returns could be cast to int. Second option, and perhaps better, change views.py in the _pagination function where it looks up num_results = count... I added the cast as num_results = int(count...) in this file and that seems to fix the problem for Informix. It looks like the equivalent code for this is views/base.py in the 1.0.0 beta code. Based on skimming the code changes, this might be partially fixed by #363 when not using pagination, but the cast to int may still be helpful otherwise.
Based on researching this problem, it sounds like Oracle databases can also return Decimal types for count.
I'm trying to use flask-restless against an Informix database. Informix returns a decimal type for count. For example, "select count(id) as c1 from users" would return c1 as Decimal('26'). Because of this, flask-restless throws an exception when trying to create the JSON of num_results. I'm finding this against the 0.17 version.
Even though Informix returns a Decimal type for the count, it looks like it could be safely cast to an Int in the context of generating num_results. I see two possible files where this could be addressed: in the helpers.py in the count function the returns could be cast to int. Second option, and perhaps better, change views.py in the _pagination function where it looks up num_results = count... I added the cast as num_results = int(count...) in this file and that seems to fix the problem for Informix. It looks like the equivalent code for this is views/base.py in the 1.0.0 beta code. Based on skimming the code changes, this might be partially fixed by #363 when not using pagination, but the cast to int may still be helpful otherwise.
Based on researching this problem, it sounds like Oracle databases can also return Decimal types for count.
Tim