Re: Me again with an insert trigger problem

From: Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Me again with an insert trigger problem
Date: 2024-02-27 22:38:54
Message-ID: 98009109-945e-4622-a512-869866eb222b@gelassene-pferde.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Am 27.02.2024 um 23:20 schrieb Adrian Klaver:
> On 2/27/24 14:11, Thiemo Kellner wrote:
>> It is a habit of mine to pad conditions in the where clause. This way,
>> it is easy to comment/uncomment parts of the clause for testing
>> purposes. Coming from Oracle, I missed that using "true" is also
>> possible and better because clearer.
>
>
> create table true_test(id integer);
> insert into true_test select * from generate_series(1, 10000);
>
> select count(*) from true_test where true;
>  count
> -------
>  10000
> (1 row)
>
> select count(*) from true_test where id < 100 and true;
>  count
> -------
>     99

I am not sure, what you want me to show with your test case. And I am
not sure whether I could not make myself clear. Please bear with me if I
try to make things clearer with an example.

-- bit-harder-to-test-statement
select count(*)
from TRUE_TEST
where ID < 100 -- if I want to deactivate that part of the clause, I
have to rewrite
and mod(ID, 5) = 0;

-- bit-easier-to-test-statement
select count(*)
from TRUE_TEST
where true
and ID < 100 -- if I want to deactivate that part of the clause, I
just comment it out
and mod(ID, 5) = 0
and true;

Cheers

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-02-27 23:23:00 Re: Me again with an insert trigger problem
Previous Message Adrian Klaver 2024-02-27 22:20:52 Re: Me again with an insert trigger problem