zsql returning no results crashes dtml-call
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SQLAlchemy DA |
Fix Committed
|
Medium
|
Abdul Kader Maliyakkal |
Bug Description
If I have a dtml statement like:
<dtml-call "myzsqlmethod()">
and myzsqlmethod returns no results,
then I get this error:
Error Type: TypeError
Error Value: object of type 'NoneType' has no len()
This is only for zsql that returns "no results" (for example, an UPDATE statement), as opposed to a query that returns an empty list of rows.
I can trace the problem to SAWrapper.query() in SQLAlchemyDA.da, specifically, the lines:
if desc is None:
return [], None
The DocumentTemplate code (somewhere in cDocumentTemplate) wants to compute the len() of the second item in that returned tuple, which raises the error.
I couldn't find an official API for database adapters, but http://
return [], []
then it works. But I don't know if anything else relies on None in that spot to signify a query with no results.
I'm open to any sort of fix or workaround. Thanks!
SQLAlchemyDA 0.5.0 (but 0.5.1 has the same issue)
sqlalchemy-
DocumentTemplat
zope2-2.13.0a4
Changed in zope-sqlalchemy-da: | |
assignee: | nobody → Abdul Kader Maliyakkal (akm-mail) |
status: | New → Incomplete |
status: | Incomplete → Confirmed |
Changed in zope-sqlalchemy-da: | |
status: | Confirmed → Fix Committed |
importance: | Undecided → Medium |
I spoke with Kader and he said it was a one line change.
--- Products/ SQLAlchemyDA/ da.py (revision 119836) SQLAlchemyDA/ da.py (working copy)
LOG.debug( 'Execution time: %3.3f seconds' % (time.time() - ts_start))
+++ Products/
@@ -207,7 +207,7 @@
if desc is None:
- return [], None
+ return [], []