Re: [Sqlrelay-discussion] Numeric types limited to 2147483647 and type of date field
Brought to you by:
mused
From: Firstworks/4access <dav...@fi...> - 2005-06-09 16:33:45
|
On Tue, 2005-06-07 at 15:39 +0200, Maciej Wi=C5=9Bniowski wrote: > Hi! >=20 > I'm using SQLRelay with Oracle database in python environment and Zope. >=20 > I've found that numeric data types are not returned correctly. > I have column ST_NUMBER in database of type NUMERIC(14), > with value 99999999999999. Value returned by SQLRelay getField > function is correct, but getRow and similiar functions return: 21474836= 47. >=20 > I realized that the problem is possibly in that line in CSQLRelay.C: >=20 > PyList_SetItem(my_list, counter, Py_BuildValue("i",=20 > charstring::toLong(row_data[counter]))); >=20 > toLong function defined in rudiments/charstring.C calls strtol function= =20 > which > is limited to return values between LONG_MIN and LONG_MAX > (http://home.att.net/~jackklein/c/inttypes.html). Am I correct?? > If so, then is it a bug or fature? Can I submit this thing somewhere? > Is it possible that SQLRelay source will be changed to support such num= bers? > or what are the availaible solutions of this problem (dirty hacks?) I believe you're right. It's a bug. I'll fix it in the next release. I believe you can change the charstring::toLong call to a charstring::toLongLong call and that should fix the problem. You also need to change the "i" to an "L" in the Py_BuildValue call. Note that long ago python didn't support long long's. I'm not sure what version they started supporting them in. >=20 >=20 > Another problem for applications in my company is date format. Is it > possible to change easily something in CSQLRelay.C (?) to return > date as DateTime object instead of string? > We're trying to move to SQLRelay from DCOracle2 and this incompability > is big problem in process of switch our existing applications. I've alr= eady > created simple Zope product to execute stored oracle procedures that > returns values (IN/OUT, result set) from within Zope, but few other > problems is still stopping us... This one is a little more challenging. It would be easier to modify PySQLRDB.py than CSQLRelay.C. Manipulating python objects from C is non-trivial. The real challenge though, even in python, is figuring out whether a column is a date type or not and then parsing the date string properly for each database. Databases have different names for their date/time type and format the date differently. Does Zope generally expect dates to come back as DateTime objects or as strings? Dave |