Re: [cx-oracle-users] Nulls returned as None and not as as "empty or zero lenght string"
Brought to you by:
atuining
From: Mihai I. <mi...@re...> - 2005-05-11 14:28:45
|
On Wed, May 11, 2005 at 07:15:23AM -0700, Chris Dunscombe wrote: > All, > > Is there anyway that Null values returned from a query can be an "empty or zero length string" > instead of None? > > This may seem a strange request as it's easy to use type to test if a null has been returned as > None. However I've a performance critical app where I need to output "nothing" (zero length / > empty string) if the value is null. Hence at present I have to perform this "type test" on ALL > columns that don't have a "Not Null" constraint in the database which is quite an overhead when in > some cases I need to do it millions and sometimes billions of times. You don't have to test with type. if val is None: val = '' Or, if val is always a string or None: val or '' will always return a string (empty string if object is None). Null objects are very well represented as None. Empty strings being represented as Null in Oracle is the weird part here, and I don't think it's something cx_Oracle (or any database libarries for that matter) should try to fix. Hope this helps. Misa |