spacepy / dbprocessing

Automated processing controller for heliophysics data
5 stars 4 forks source link

getEntry is inconsistent if entry not found #80

Open jtniehof opened 3 years ago

jtniehof commented 3 years ago

getEntry attempts a lookup with the argument as a primary key (commonly integer in dbp, but also frequently a tuple). If this fails, it assumes the argument is a name, and checks for a gettableID method for the specified table. If that method does not exist, getEntry returns None. If it does exist, gettableID usually raises DBNoData if there are no results.

What that means is that getEntry('File', 0) will raise DBNoData (assuming no file ID 0) but getEntry('Inspector', 0) will simply return None, because getInspectorID does not exist, but getFileID does.

Minimal example to reproduce issue:

Do this in the unit tests directory:

import dbprocessing.DButils
dbu = dbprocessing.DButils.DButils('./emptyDB.sqlite')
dbu.getEntry('File', 0)  # Raises DBNoData
dbu.getEntry('Inspector', 0)  # Returns None

OS, Python version, and dependency version information:

Linux-4.15.0-143-generic-x86_64-with-Ubuntu-18.04-bionic
sys.version_info(major=2, minor=7, micro=17, releaselevel='final', serial=0)
sqlalchemy=1.1.11

Version of dbprocessing

Way off in a working branch

Closure condition

This issue should be closed when the desired behavior (returning None or raising error) is defined and codebase is checked for consistency. Both approaches are used and tested, so unit tests passing should be adequate (shouldn't need more.)