Skip to content

Commit

Permalink
a fix which fixes the test, but doesn't clean up databases comprehens…
Browse files Browse the repository at this point in the history
…ively
  • Loading branch information
glyph authored and glyph committed May 12, 2020
1 parent 11c84fb commit e4a846f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions axiom/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,17 @@ def getItemByID(self, storeID, default=_noItem, autoUpgrade=True):
# for the moment we're going to assume no inheritance
attrs = self.querySQL(T._baseSelectSQL(self), [storeID])
if len(attrs) == 0:
# there was an oid allocation row with a type set to a valid
# type, but no accompanying data row.

# there are cases where items will be deleted but their oid
# allocation rows won't be. normally this should set the type
# to -1 but upgraders or old bugs may have left the database
# in a state where it's still set.

# do cleanup if we're not in a read-only transaction (haha
# there is no such thing as a read-only transaction)
self.executeSchemaSQL(_schema.CHANGE_TYPE, [-1, storeID])
if default is _noItem:
raise errors.ItemNotFound(
'No results for known-to-be-good object')
Expand Down

0 comments on commit e4a846f

Please sign in to comment.