Fix problem closing in-memory db connections
Fix 2 errors where postgresql is stricter than sqlite