Re: Converting yes or no to one letter strings.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Converting yes or no to one letter strings.
Date: 2019-06-04 23:29:27
Message-ID: CAKFQuwb+1NkFp1CdXBXN=sJSEoHcVY8qp49rLrv4HDC2wTV1xA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 4, 2019 at 4:01 PM Rich Shepard <rshepard(at)appl-ecosys(dot)com>
wrote:

> On Tue, 4 Jun 2019, Lou wrote:
>
> > To start off, I just need to convert true to 's'. false will have to be
> > manually changed to 'f' or 'p' or 'e' as appropriate.
>
> Second, if you need to display to the user something other than 't' and 'f'
> that should be done with your UI, not by changing postgres.
>

Actually, given that "f" is becoming multiple different values it seems
like the OP is improving upon their data model. That should very much be
done at the table level at not relegated to views, let alone a UI layer.

It is not unusual to want to convert something that was a simple boolean to
an enumeration of values. Though it is probably better to add a new column
to reflect the new model element and effectively deprecate the old column -
eventually removing it from use when it is no longer needed. Altering the
column type, while possible, is not usually desirable. In particular it
makes rolling back (or supporting older) client software more difficult
because the old version will not recognize the new field and the old field
will be gone.
David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2019-06-04 23:44:43 Re: Converting yes or no to one letter strings.
Previous Message David G. Johnston 2019-06-04 23:23:32 Re: Converting yes or no to one letter strings.