Re: Tidying values on variable instantiation

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Tidying values on variable instantiation
Дата
Msg-id 20050826152027.GB16546@wolff.to
обсуждение исходный текст
Ответ на Tidying values on variable instantiation  ("Bath, David" <dave.bath@unix.net>)
Список pgsql-sql
On Fri, Aug 26, 2005 at 13:04:10 +1000,
> Desired Outcome(s):
> * I would like to have the convenience of declaring a column that obeys
>   a constraint (similar to using a domain), but allows a "tidy-up" as the
>   value is created BEFORE asserting the constraint.  This *might* be
>   termed a "domain trigger".  (Perhaps even a WORM is possible!).
> * I would like to able to declare columns as 
>   "trimmed_varchar(n)".
> * I'd like to be able to use the same approach for other "weak domains".
> 
> Question(s):
> * Am I being realistic, or should I grit my teeth and clone code from
>   trigger to trigger and column to column?
> * Is this something I should try and do using domains, types and
>   cast functions from "text" or some horrible combination of them all?
> * Has anybody got a code sample that might do something similar.

I think it is normal to expect the application to pass you clean data.

I think you can do what you want by creating a new type. I seem to remember
there are issues with creating whatever(n) types (my memory is that varchar(n)
is hardwired into the parser), but certainly you could make an alternate
version of text whose input function trimmed leading and trailing whitespace.
You could also create casts between this new type and text if you needed
that ability as well.


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Greg Patnude"
Дата:
Сообщение: Re: Tidying values on variable instantiation
Следующее
От: Chris Browne
Дата:
Сообщение: Re: Tidying values on variable instantiation