Re: Wrong column default values

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Wrong column default values
Дата
Msg-id alpine.BSO.2.00.0909261040360.2098@leary.csoft.net
обсуждение исходный текст
Ответ на Re: Wrong column default values  (Andre Rothe <phosco@gmx.de>)
Список pgsql-jdbc

On Sat, 19 Sep 2009, Andre Rothe wrote:

> I have exlicitly set the default value for every column, but if I ask
> the driver for the current value, it doesn't give me a simple NULL, but
> the described expression. For the moment I have translated the result
> with a
>
>    private String dropAnnotations(String defValue) {
>     String res = defValue;
>     if ((res != null) && (res.contains("::"))) {
>         res = res.substring(0, res.lastIndexOf("::"));
>     }
>     return res;
>    }
>
> But this is an ugly way to get a clean default value from the driver.
>

This isn't a really safe thing to do if you consider all the possible
default values, so I'm not sure there's much that the JDBC driver can do
to clean this up.  I think it just has to report what the server tells it.

Consider:

CREATE TEMP TABLE deftest (
     a text default 'a::b',
     b timestamptz default now() + 3 * '5 minutes'::interval
);

jurka=# \d deftest
                                       Table "pg_temp_1.deftest"
  Column |           Type           |                            Modifiers
--------+--------------------------+------------------------------------------------------------------
  a      | text                     | default 'a::b'::text
  b      | timestamp with time zone | default (now() + ((3)::double
precision * '00:05:00'::interval))


Kris Jurka

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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: Support for getting generated keys.
Следующее
От: "J. W. Ulbts"
Дата:
Сообщение: Re: DataSource.setMaxConnections() - Does not work