#598: run_sql reports errors wrong
----------------------+-----------------
 Reporter:  jblayloc  |      Owner:
     Type:  defect    |     Status:  new
 Priority:  critical  |  Milestone:
Component:  MiscUtil  |    Version:
 Keywords:            |
----------------------+-----------------
 As far as I can tell, anyway.

 Its documentation says:
     163     @note: In case of problems, exceptions are returned according
 to
     164         the Python DB API 2.0.  The client code can import them
 from
     165         this file and catch them.

 And the Python DB API 2.0 at http://www.python.org/dev/peps/pep-0249/
 (first thing that came up when I googled "Python DB API 2.0") says:
     The module should make all error information available through
     these exceptions or subclasses thereof:

 ...which strongly implies that bad things done in SQL should produce
 exceptions rather than, for example, text output.  In particular, it looks
 like they should produce "ProgrammingError" for malformed SQL.

 This doesn't appear to be what's going on, however:
 {{{
 In[6]:
 try:
     run_sql('select id from bibrec where creation_date like "junk"')
 except Exception:
     print "OK!"
 Out[6]: ()
 }}}

 So you see, no exception object.  And, in a try block, no printed warning
 either.  Only when we run it straight at the prompt do we get a very mild
 and uncatchable textual warning:
 {{{
 run_sql('select id from bibrec where creation_date like "junk"')
 /usr/lib/python2.4/site-packages/invenio/dbquery.py:179: Warning:
 Incorrect datetime value: 'junk' for column 'creation_date' at row 1
 }}}

 Have I done something stupid?  Because if not, I think this is
 fundamentally broken and a serious problem.

-- 
Ticket URL: <https://invenio-software.org/ticket/598>
Invenio <http://invenio-software.org>

Reply via email to