Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAffiliation always returns None #65

Closed
Castronova opened this issue May 13, 2016 · 3 comments
Closed

getAffiliation always returns None #65

Castronova opened this issue May 13, 2016 · 3 comments

Comments

@Castronova
Copy link
Contributor

There is a bug in readService.getAffiliation that causes it to always returns None.

q = self._session.query(Affiliations)
if ids: q = q.filter(Affiliations.AffiliationID.in_(ids))
if orgcode: q = q.filter(Organizations.OrganizationCode.ilike(orgcode))
if personfirst: q = q.filter(People.PersonFirstName.ilike(personfirst))
if personlast: q = q.filter(People.PersonLastName.ilike(personlast)).first()
try:
    return q.all()
except:
    return None

to fix, change the PersonLastName filter to:

if personlast: q = q.filter(People.PersonLastName.ilike(personlast))

Additionally, the following exception is raised AttributeError: 'Affiliations' object has no attribute 'all', but the user is not informed because all of the api functions return None without any error message. Is there a reason for this? The function above could be rewritten as:

q = self._session.query(Affiliations)
if ids: q = q.filter(Affiliations.AffiliationID.in_(ids))
if orgcode: q = q.filter(Organizations.OrganizationCode.ilike(orgcode))
if personfirst: q = q.filter(People.PersonFirstName.ilike(personfirst))
if personlast: q = q.filter(People.PersonLastName.ilike(personlast))

try:
    res = q.all() or None
except AttributeError as e:
    print(e)
    res = None
return res

I suggest that someone update/implement unit tests for all api functions to make sure they work as expected.

@emiliom
Copy link
Member

emiliom commented Nov 23, 2017

@Castronova or @lsetiawan, can you check if this issue has been addressed? It looks like it was addressed a while ago. Just want to see if we can close this issue. Thanks.

@lsetiawan
Copy link
Member

@emiliom See: #68

@emiliom
Copy link
Member

emiliom commented Nov 23, 2017

Thanks for identifying the PR. Closing.

@emiliom emiliom closed this as completed Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants