Issue609505

classification
Title: SQLWarning tuples not populated
Type: Severity: normal
Components: Library Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bzimmer Nosy List: bzimmer
Priority: normal Keywords:

Created on 2002-09-15.08:00:11 by anonymous, last changed 2002-12-24.17:17:27 by bzimmer.

Messages
msg737 (view) Author: Nobody/Anonymous (nobody) Date: 2002-09-15.08:00:11
There is a problem with the way that SQLWarnings are 
added in PyCursor.addWarning(SQLWarning).

The existing code is:

 PyTuple warn = new PyTuple();
 // there are three parts: (reason, state, vendorCode)
 warn.__add__(Py.java2py(warning.getMessage()));
 warn.__add__(Py.java2py(warning.getSQLState()));
 warn.__add__(Py.newInteger(warning.getErrorCode()));

However, PyTuple.__add__(PyObject) silently ignores 
any object that is not another PyTuple instance. This 
means that whilst there is an entry in the PyList for 
each warning, the tuple has a zero length and the 
warnings are effectively lost.



The fix is to replace the above code to use the PyTuple 
constructor that allows an array to be passed:

 PyObject[] msg = new PyObject[] {
     // there are three parts: (reason, state, vendorCode)
     Py.java2py(warning.getMessage()),
     Py.java2py(warning.getSQLState()),
     Py.newInteger(warning.getErrorCode())
 };
 PyTuple warn = new PyTuple(msg);
msg738 (view) Author: Brian Zimmer (bzimmer) Date: 2002-12-24.17:17:27
Logged In: YES 
user_id=37674

Patched as suggested.
History
Date User Action Args
2002-09-15 08:00:11anonymouscreate