waliwali / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

_SelectLastRowIDMixin.getlastrowid() should be named _SelectLastRowIDMixin.get_lastrowid() #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Error in file: ibm_db_sa-0.3.0-py2.7.egg/ibm_db_sa/base.py:523
    def getlastrowid(self):
should be changed to:
    def get_lastrowid(self):

Reason:
_SelectLastRowIDMixin is used in pyodbc.py as base for:
class DB2ExecutionContext_pyodbc(_SelectLastRowIDMixin, DB2ExecutionContext)
and should redefine DB2ExecutionContext.get_lastrowid(self) initially derived 
from:
sqlalchemy.engine.default.DefaultExecutionContext.get_lastrowid(self)

With this error the redefinition does not take place -> wrong (not redefined) 
function is used.

This mechanism is used during discovery of the table keys that had been 
assigned by the DB2 during INSERTion.

Example code:

---CODE BEGIN---
db2 = sqlalchemy.create_engine(Connect_string, echo=True)
metadata = MetaData(bind=db2, schema=Schema, quote_schema=False)
users = MyTable('users', metadata,
    Column('key', Integer, nullable=False, unique=True, primary_key=True),
    Column('data', Boolean, nullable=True), # Table with the kay only gives error, when inserted, as it gives empty list of values
)
class Users(object):
    pass;
mapper(Users, users)
metadata.drop_all()
metadata.create_all()
Session=sessionmaker(bind=db2)
session=Session()
session.add(Users())
session.commit()
---CODE END---

Because of this error, INSERT issued on the last one fails with exception:
AttributeError: 'pyodbc.Cursor' object has no attribute 'lastrowid'

Detected with:
sqlalchemy-0.8.2-py2.7.egg
ibm_db-2.0.2-py2.7-win32.egg
ibm_db_sa-0.3.0-py2.7.egg

Original issue reported on code.google.com by Adam.J.M...@gmail.com on 22 Aug 2013 at 2:22

GoogleCodeExporter commented 9 years ago
This issue has been resolved by Jamiy and changes has been committed to Git 
branch, It will get included in next release.

Original comment by rahul.pr...@in.ibm.com on 2 Sep 2013 at 8:18

GoogleCodeExporter commented 9 years ago

Original comment by rahul.pr...@in.ibm.com on 18 Nov 2013 at 6:29