[SQL-CVS] r1562 - in home/phd/SQLObject/paramstyles/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2006-02-03 19:08:55
|
Author: phd Date: 2006-02-03 12:08:46 -0700 (Fri, 03 Feb 2006) New Revision: 1562 Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py home/phd/SQLObject/paramstyles/sqlobject/tests/test_select.py Log: Merged patches from the revisions 1559:1561 from the trunk: applied the patch 1422132: do not allow selectBy(nonexistantcolumn=foo). Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2006-02-03 19:07:34 UTC (rev 1561) +++ home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2006-02-03 19:08:46 UTC (rev 1562) @@ -16,6 +16,7 @@ import sqlbuilder from cache import CacheSet import col +popKey = col.popKey from joins import sorter from converters import sqlrepr import classregistry @@ -695,16 +696,20 @@ ops = {None: "IS"} data = {} if 'id' in kw: - data[soClass.sqlmeta.idName] = kw['id'] + data[soClass.sqlmeta.idName] = popKey(kw, 'id') for key, col in soClass.sqlmeta.columns.items(): if key in kw: - data[col.dbName] = kw[key] + data[col.dbName] = popKey(kw, key) elif col.foreignName in kw: - obj = kw[col.foreignName] + obj = popKey(kw, col.foreignName) if obj is None: data[col.dbName] = None else: data[col.dbName] = obj.id + if kw: + # pick the first key from kw to use to raise the error, + raise TypeError, "got an unexpected keyword argument(s): %r" % kw.keys() + if not data: return None return ' AND '.join( Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_select.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/tests/test_select.py 2006-02-03 19:07:34 UTC (rev 1561) +++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_select.py 2006-02-03 19:08:46 UTC (rev 1562) @@ -91,6 +91,13 @@ b = IterTest(name='b') assert IterTest.selectBy().count() == 2 +def test_selectBy_kwargs(): + setupClass(IterTest) + try: + b = IterTest(nonexistant='b') + except TypeError: + return + assert False, "IterTest(nonexistant='b') should raise TypeError" class Counter2(SQLObject): |