ZOracleDA-beta5 problem; possible bug running NT
Hello, I'm running; Zope 2.3.2 (binary release, python 1.5.2, win32-x86) Yesterday i installed ZoracleDA-beta5 after having run the alfa5 for some time. After installing the update I noticed that things were not what they should or even used to be. Problem one. This was there with the alfa-version. If you encounter a null value in the datbase zope returns the value None under NT. At least if it is an integer field. I tried to work around this by using NVL(field,0) where field is an integer. When the database value is null zope responds 0.0 under NT! Performing the same trick direcly in the Oracle DB and the answer is 0 like it should be. OK, so I try a simple workaround by using ROUND(NVL(field,0),0) which should give the answer 0. The answer is still 0.0, in addition all non-null values gets a decimal ending! Some time ago i fiddled with an zope-on-linux installation where the null value provide by zope was 0. Solutions, explanations or workarounds anyone? Problem two. New with beta5!!! Integer field value changed from 12108 to 12108L. This happens for some of of my integer fields but not for all. Is there anyone out there who knows of a solution or has seen this behavior before. -- Stig-Arne Nordin Fysik och teknisk fysik CHALMERS | Göteborgs Universitet
Stig-Arne Nordin wrote:
If you encounter a null value in the datbase zope returns the value None under NT. At least if it is an integer field.
I gather this is something new with the new DBAPI 2.0-based adapters. In any event, the way to handle it is like so: <dtml-var field null> "null" tells DTML to render "None" (which means no object) as an empty string. IMO, the whole "None" thing with SQL does violate the principle of least surprise, though. -- Matt Behrens <matt.behrens@kohler.com> System Analyst, Baker Furniture
On Tue, Sep 04, 2001 at 10:27:12AM -0400, Behrens Matt - Grand Rapids wrote: | IMO, the whole "None" thing with SQL does violate the principle of least | surprise, though. I honestly can't see why... The SQL 'NULL' is "an unknown value" - as distinct from a 0 ´empty string'. To me, 'None' is an entirely obvious response - it represents the fact that we do not know the state of that value; in a quantum world, it's representing every state at once :) Still, if not the Principle of Least Surprise, it's certainly violating the Principle of Not Being a Tedius Pain :) It would be far more convenient for it to return '0' for a NULL in a Numeric-type column, '' when in a String-type column, and EOF for a Binary-type column. (If you see what I'm getting at) Perhaps something for the next rev of the DB API? :) -Z
I don't know about other databases, but you can get the result you want in Oracle with the nvl function, by selecting nvl(optional_number, 0) from the database. If you couldn't control the replacement value and 0 had an exisiting meaning, I would think that disastrous. At 01:28 05/09/01 +1000, Zac Stevens wrote: <snip>
Still, if not the Principle of Least Surprise, it's certainly violating the Principle of Not Being a Tedius Pain :) It would be far more convenient for it to return '0' for a NULL in a Numeric-type column, '' when in a String-type column, and EOF for a Binary-type column. (If you see what I'm getting at)
"J. Cone" wrote:
I don't know about other databases, but you can get the result you want in Oracle with the nvl function, by selecting
nvl(optional_number, 0)
from the database. If you couldn't control the replacement value and 0 had an exisiting meaning, I would think that disastrous.
I know the NVL trick, it works. Almost. It yields 0.0 for an integer, I want it to be 0. I tried Round(nvl(optional_number, 0), 0) got me 0.0 for null -- Stig-Arne Nordin | Projektledare Fysik och teknisk fysik CHALMERS | Göteborgs Universitet tel 031 772 32 07 | fax 772 3202 http://www.fysiksidan.nu
Horrible bodgy hack: does <dtml-var "Integer(Float(field))"> work? I don't know why Oracle numbers get promoted into Long's and Float's, but I agree it's annoying. At 17:47 04/09/01 +0200, Stig-Arne Nordin wrote: <snip>
I know the NVL trick, it works. Almost. It yields 0.0 for an integer, I want it to be 0. I tried Round(nvl(optional_number, 0), 0) got me 0.0 for null
On Tue, Sep 04, 2001 at 04:42:32PM +0100, J. Cone wrote:
I don't know about other databases, but you can get the result you want in Oracle with the nvl function, by selecting
nvl(optional_number, 0)
from the database. If you couldn't control the replacement value and 0 had an exisiting meaning, I would think that disastrous.
Which the OP did :) That was his other point, which no-one else has addressed. He noted that when using the above function that although the desired '0' was being returned, all numbers were now floats - ie, '0.0' instead of '0'. That's purely as a result of the Python type that the column is cast into. It would seem that the NVL function changes that from an int to a float in that case. Again, a pain to deal with but entirely logical nonetheless. -Z
On Wed, Sep 05, 2001 at 12:51:35PM +1000, Zac Stevens wrote: | That's purely as a result of the Python type that the column is cast into. | It would seem that the NVL function changes that from an int to a float in | that case. | | Again, a pain to deal with but entirely logical nonetheless. And then in all the excitement I didn't post my own solution - just add a fmt string to your dtml-var. -Z
participants (5)
-
Behrens Matt - Grand Rapids -
J. Cone -
Stig-Arne Nordin -
Zac Stevens -
Zac Stevens