history-lab / foiarchive-api

REST API for Freedom of Information Archive (FOIArchive)
3 stars 0 forks source link

__apply_query_filters #3

Open arpie71 opened 6 years ago

arpie71 commented 6 years ago

This function now returns the error "sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on SQL expression or this Session" when the query is returned to a specific function. I've replicated the behavior with find_docs_by_date, find_docs_by_country, find_docs_by_topic.

This comes about when filters are added to the SQL query. If I run the queries with the filters individually, each works.

mnyrop commented 6 years ago

@arpie71 can you list steps to reproduce?

arpie71 commented 6 years ago

I ran the following api request: http://127.0.0.1:5001/declass/v0.4/?start_date=1947-01-01&end_date=1950-12-01

I replace lines 1631 of controller.py to this:

            try:
                db_results_objects = session.q.all()    # returns all documents
            except (RuntimeError, TypeError, NameError) as err:
                print(err)
            except exc.UnboundExecutionError as e:
                print(e)
            except:
                print("Unknown error", sys.exc_info()[0])