Pegase745 / sqlalchemy-datatables

SQLAlchemy integration of jQuery DataTables >= 1.10.x (Pyramid and Flask examples)
MIT License
159 stars 67 forks source link

Not working for flask #91

Closed fnokeke closed 7 years ago

fnokeke commented 7 years ago

I tried with existing flask tables (postgres database) but got error below. Then I copied over the user and addresses models in flask_tut examples & populated database with dummy records but still same error.

Error received: "Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Address.id has an attribute 'cast'"}

The issue seems to be with the exact data returned as the other parameters in results appear fine: result: {'recordsTotal': '13', 'recordsFiltered': '0', 'draw': '1', 'error': "Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Address.id has an attribute 'cast'"}

This error is typically an sqlalchemy error that typically happens with tables that have relationships with other tables. However, I still get this error with a simple db.model that has only two attributes and no relationships with other tables.

I looked through the datatables src and I was wondering if this project is only supposed to work with sqlite database?

Any tips would be appreciated.

Pegase745 commented 7 years ago

Other than for the examples, I always used it with Postgres so don't really know if maybe a regression was introduced lately. I will have to look at it asap

tdamsma commented 7 years ago

Can you post the model and the columns query? I think the problem is there somewhere. Unfortunately I am not familiar with Flask-SQLAlchemy, but I'll give it a shot, also for https://github.com/Pegase745/sqlalchemy-datatables/issues/90

louking commented 7 years ago

FWIW, https://github.com/louking/rrwebapp/blob/master/rrwebapp/crudapi.py is a working example of Flask using Flask-SQLAlchemy and sqlalchemy-datatables (with mysql). Unfortunately this uses the old sqlalchemy-datatables api as I haven't had time to convert, and also it's a class which has some specifics to my application. This runs on my fork https://github.com/louking/sqlalchemy-datatables, and no I don't plan to continue the development of the old api :) .

Having said all that, there may be something helpful in there for @fnokeke and other flask users who also use sqlalchemy-datatables.

tdamsma commented 7 years ago

@fnokeke, what SQLAlchemy version are you using?

fnokeke commented 7 years ago

@tdamsma SQLAlchemy==0.8.3

tdamsma commented 7 years ago

I just tested with SQLAlchemy 0.8, and that seemed to work (0.7 definitively doesn't). Can you try to upgrade SQLAlchemy to e.g. 1.1?

lhayhurst commented 7 years ago

I've verified that it works with 1.1 (and not with 0.9.9)

AshishVerma7690 commented 7 years ago

for my case it is not working with 1.1

tdamsma commented 7 years ago

closing this as i cannot reproduce