ODM2 / ODM2PythonAPI

A set of Python functions that provides data read/write access to an ODM2 database by leveraging SQLAlchemy.
http://odm2.github.io/ODM2PythonAPI/
BSD 3-Clause "New" or "Revised" License
4 stars 13 forks source link

Fix person and organization filter for affiliations #96

Closed lsetiawan closed 7 years ago

lsetiawan commented 7 years ago

Overview

This PR addresses #95. It joins the necessary table to Affiliations table so that filter can actually occur. I have tested it and it seems to work.

emiliom commented 7 years ago

So, a join is necessary, and you can't use the relationships defined in the Affiliations model? eg, OrganizationObj = relationship(Organizations)

lsetiawan commented 7 years ago

@emiliom How do I go about that? Sorry.. not SQLAlchemy pro here 😉

emiliom commented 7 years ago

@emiliom How do I go about that? Sorry.. not SQLAlchemy pro here

Neither am I! But I'd look for similar examples in other query functions.

If it is in fact doable, it seems cleaner to reuse that "predefined" relationship rather than adding explicit joins.

emiliom commented 7 years ago

Hmm. That doesn't look better :disappointed:

After looking at what's used in readService.py, I can see that there's some variability, and the two join forms you've used (in the two commits) are what's used. Oh well.

If you've tested this, let's go with it. It would seem cleaner and possibly more efficient (in some cases) to do all the joining in the query statement, but let's not bother.

Thanks.

emiliom commented 7 years ago

Let me know if you've tested this commit, and I'll accept the PR.

lsetiawan commented 7 years ago

This has been tested and good to go with your approval. Thanks!