Re: Handling (None,) Query Results

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: hagen(at)datasundae(dot)com, psycopg(at)lists(dot)postgresql(dot)org, psycopg(at)postgresql(dot)org
Subject: Re: Handling (None,) Query Results
Date: 2020-12-05 16:19:32
Message-ID: 63e5c526-7e07-ad4b-f891-ac5272257507@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 12/5/20 8:14 AM, hagen(at)datasundae(dot)com wrote:
> I tried the COALESCE approach but I thought the query still returned (None,).

From docs:

https://www.postgresql.org/docs/12/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL

"The COALESCE function returns the first of its arguments that is not
null. Null is returned only if all arguments are null. ..."

So if it returned NULL/None then the first and second values both
resolved to NULL.

>
> However, I just tried it again and I got a (Decimal('0'),) return.
>
> I should be able to make that work.
>
> Thanks everyone for your rapid assistance.
>
> Best,
>
> Hagen
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse psycopg by date

  From Date Subject
Next Message hagen 2020-12-07 22:02:03 Inserting variable into
Previous Message hagen 2020-12-05 16:14:57 RE: Handling (None,) Query Results