[SQLObject] [patch] support for tables with only 'id'
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Karl C. <qu...@no...> - 2004-06-18 14:41:02
|
The patch below adds support for tables which have only the 'id'
column. Such schema are occasionally useful (esp. for related
join to another table)
Index: dbconnection.py
===================================================================
--- dbconnection.py (revision 1138)
+++ dbconnection.py (working copy)
@@ -361,6 +361,12 @@
self.sqlrepr(so.id)))
def _SO_selectOne(self, so, columnNames):
+ if not columnNames:
+ return (self.queryOne("SELECT 1 FROM %s WHERE %s = %s" %
+ (so._table,
+ so._idName,
+ self.sqlrepr(so.id)))
+ and ())
return self.queryOne("SELECT %s FROM %s WHERE %s = %s" %
(", ".join(columnNames),
so._table,
Index: main.py
===================================================================
--- main.py (revision 1138)
+++ main.py (working copy)
@@ -603,7 +603,7 @@
if not selectResults:
dbNames = [col.dbName for col in self._SO_columns]
selectResults = self._connection._SO_selectOne(self, dbNames)
- if not selectResults:
+ if selectResults is None:
raise SQLObjectNotFound, "The object %s by the ID %s does not exist" % (self.__class__.__name__, self.id)
self._SO_selectInit(selectResults)
self._SO_createValues = {}
--
Karl 2004-06-18 07:30
|