pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: stan <stanb@panix.com>
Cc: pgsql-general@postgresql.org
Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
Date: Tue, 17 Sep 2019 06:48:25 -0700
Message-ID: <699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com> (raw)
In-Reply-To: <20190917093126.GA935@panix.com>
References: <20190915174649.GB2078@panix.com>
	<50d5b256-74b9-1949-a634-0df37cbfb783@aklaver.com>
	<20190916010439.GA7478@panix.com>
	<11b4428d-8740-07f4-a053-37f0bb0cd2fb@aklaver.com>
	<20190916185333.GB28966@panix.com>
	<b1b8bfde-a836-c05f-fa2f-01ee29d93032@aklaver.com>
	<20190916195543.GA16882@panix.com>
	<4b1da094-8342-6415-e0a4-ce87fd1331ab@aklaver.com>
	<20190917093126.GA935@panix.com>

On 9/17/19 2:31 AM, stan wrote:

>>> I am not certain what you mean by the check. As you can see, there is nor
>>> specific check clause. I was referring to the built in check of data being
>>> entered versus the legal values for the user defined type. Make sense?
>>>
>>
>> To be clear you are seeing an error because a value of say 'active' is being
>> rejected before your trigger has a chance to upper case it, correct?
>>
>> Also this happens whether you use \copy or manually INSERT the values?
> 
> That is correct. Sorry this was not clear from the beginning.
> 
> Any suggestions, including changing the design here, are welcome.

Suggestions:

1) Per Tom's post clean the data before it hits the database.

2) Enter the data directly into the database using something that forces 
the user to enter only the correct ENUM values.

3) If the status field is only ever going to be ACTIVE/INACTIVE change 
it to a BOOLEAN field active_status and be done with the ENUM dance.

4) If status may ever be more then ACTIVE/ACTIVE then change it to 
varchar and use the trigger to set case(if still important) and/or 
verify correct entries.


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (24+ messages)  latest in thread

Message-ID: <699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com>
Permalink:  ../699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com/
Also on:    postgresql.org/message-id/699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, stanb@panix.com
  Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
  In-Reply-To: <699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com>
  References: <20190915174649.GB2078@panix.com> <50d5b256-74b9-1949-a634-0df37cbfb783@aklaver.com> <20190916010439.GA7478@panix.com> <11b4428d-8740-07f4-a053-37f0bb0cd2fb@aklaver.com> <20190916185333.GB28966@panix.com> <b1b8bfde-a836-c05f-fa2f-01ee29d93032@aklaver.com> <20190916195543.GA16882@panix.com> <4b1da094-8342-6415-e0a4-ce87fd1331ab@aklaver.com> <20190917093126.GA935@panix.com> <699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox