[SQL-CVS] r1572 - in home/phd/SQLObject/paramstyles/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2006-02-06 18:24:27
|
Author: phd Date: 2006-02-06 11:24:18 -0700 (Mon, 06 Feb 2006) New Revision: 1572 Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py home/phd/SQLObject/paramstyles/sqlobject/tests/test_basic.py Log: Merged patches from the revisions 1569:1570 from the trunk: fixed the bug 1410910: __getattr__ should raise AttributeError. Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2006-02-06 18:22:10 UTC (rev 1571) +++ home/phd/SQLObject/paramstyles/sqlobject/sqlbuilder.py 2006-02-06 18:24:18 UTC (rev 1572) @@ -397,6 +397,8 @@ raise AttributeError if attr == 'id': return self.FieldClass(self.tableName, self.soClass.sqlmeta.idName, attr) + elif attr not in self.soClass.sqlmeta.columns: + raise AttributeError("%s instance has no attribute '%s'" % (self.soClass.__name__, attr)) else: return self.FieldClass(self.tableName, self.soClass.sqlmeta.columns[attr].dbName, Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_basic.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/tests/test_basic.py 2006-02-06 18:22:10 UTC (rev 1571) +++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_basic.py 2006-02-06 18:24:18 UTC (rev 1572) @@ -281,4 +281,12 @@ bob = TestSO1.selectBy(name='bob')[0] assert bob.sqlmeta.asDict() == { 'passwd': 'tbq', 'name': 'bob', 'id': bob.id} - + +def test_nonexisting_attr(): + setupClass(Student) + try: + Student.select(Student.q.nonexisting) + except AttributeError: + pass + else: + assert 0, "Expected an AttributeError" |