Skip to content

Commit

Permalink
Try to fix PostgreSQL specific unit test failure reported on list by …
Browse files Browse the repository at this point in the history
…Cymon
  • Loading branch information
peterjc committed Aug 31, 2010
1 parent 620cf3a commit 050963b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion BioSQL/BioSeqDatabase.py
Expand Up @@ -533,8 +533,14 @@ def __contains__(self, value):
"""Check if a primary (internal) id is this namespace (sub database)."""
sql = "SELECT COUNT(bioentry_id) FROM bioentry " + \
"WHERE biodatabase_id=%s AND bioentry_id=%s;"
#The bioentry_id field is an integer in the schema.
#PostgreSQL will throw an error if we use a non integer in the query.
try:
bioentry_id = int(value)
except ValueError:
return False
return bool(self.adaptor.execute_and_fetch_col0(sql,
(self.dbid, value))[0])
(self.dbid, bioentry_id))[0])

def __iter__(self):
"""Iterate over ids (which may not be meaningful outside this database)."""
Expand Down

0 comments on commit 050963b

Please sign in to comment.