After call to shallow() dictionary build_query is changed permamantly. Instead of changing internals of Database() object from outside it's better to have public method.
def unshallow() :
if ('shallow' in self.build_query):
del self.build_query['shallow']