fetchone() triggers an exception after a sql.delete() on postgresql

Issue #1246 resolved
Former user created an issue

This is using sqlalchemy-0.4.8

Consider this statement:

foo_table.delete(foo_table.c.id==1).execute().fetchone()

It will return None using sqlite as engine, while using postgresql it will trigger an exception:

  File "/home/turbogears/jails/knowledgeplaza/lib/python2.5/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/base.py", line 1653, in fetchone
    self.connection._handle_dbapi_exception(e, None, None, self.cursor)
  File "/home/turbogears/jails/knowledgeplaza/lib/python2.5/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/base.py", line 934, in _handle_dbapi_exception
    self.invalidate(e)
  File "/home/turbogears/jails/knowledgeplaza/lib/python2.5/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/engine/base.py", line 641, in invalidate
    if self.__connection.is_valid:
AttributeError: 'Connection' object has no attribute '_Connection__connection'

The fix is to not fetchone() after the execute(), but imho it shouldn't trigger an exception under postgresql

Comments (1)

  1. Log in to comment