public inbox for [email protected]
help / color / mirror / Atom feedFrom: Ron Johnson <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: Is it correct to raise an exception in a domain check
Date: Tue, 10 Jun 2025 17:28:31 -0400
Message-ID: <CANzqJaBYUDRua2LYQHp6rZVAR2OUVe_65Hw-NFd_gA1pxksFzQ@mail.gmail.com> (raw)
In-Reply-To: <CANn=KGi1fU3rkEbwnOZX3_WNQJXa39tbkmn7N4tAMSf75r7nNw@mail.gmail.com>
References: <CANn=KGi1fU3rkEbwnOZX3_WNQJXa39tbkmn7N4tAMSf75r7nNw@mail.gmail.com>
On Tue, Jun 10, 2025 at 4:53 PM Logan Grosz <[email protected]> wrote:
> Hi,
>
> I have a `DOMAIN` on `JSONB`. I need to verify the shape of the JSON, so I
> have a check expression written in PL/pgSQL. The docs say
>
> > Each constraint must be an expression producing a Boolean result
>
> Would it be correct to raise an exception to indicate a failed check? I
> perform type-casts (that throw already) and other checks that would benefit
> from attaching a description to the client error.
>
Since PG will throw an error when any CHECK constraint fails, are you
hoping to provide more details by throwing your own exception?
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Is it correct to raise an exception in a domain check
In-Reply-To: <CANzqJaBYUDRua2LYQHp6rZVAR2OUVe_65Hw-NFd_gA1pxksFzQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox