Pegase745 / sqlalchemy-datatables

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

Error while using outerjoin in query #47

Closed mbtronics closed 8 years ago

mbtronics commented 8 years ago

I'm using several "outerjoin"s in the query I use for DataTables. This results in the following error:

  File "venv/lib/python2.7/site-packages/datatables/__init__.py", line 126, in __init__
    self.run()
  File "venv/lib/python2.7/site-packages/datatables/__init__.py", line 196, in run
    tmp_row = get_attr(self.results[i], col.column_name)
  File "venv/lib/python2.7/site-packages/datatables/__init__.py", line 37, in get_attr
    output = getattr(output, x)
AttributeError: 'NoneType' object has no attribute 'Name'

The fix is very simple: replace line 37 in init.py output = getattr(output, x) with

if hasattr(output, x):
    output = getattr(output, x)
else:
    output = None

What is the best way to get this fixed, do I create a pull request myself?

Pegase745 commented 8 years ago

Be my guest :+1: I won't mind a quick unit test if you have the time

mbtronics commented 8 years ago

pull request: #48

mbtronics commented 8 years ago

Done.

And thanks for this excellent library!

2016-04-20 22:17 GMT+02:00 Michel Nemnom notifications@github.com:

Be my guest [image: :+1:] I won't mind a quick unit test if you have the time

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Pegase745/sqlalchemy-datatables/issues/47#issuecomment-212586313