From: Kris Jurka <books@ejurka.com>
To: Andre Rothe <phosco@gmx.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Wrong column default values
Date: Sat, 26 Sep 2009 10:46:30 -0400 (EDT)
Message-ID: <alpine.BSO.2.00.0909261040360.2098@leary.csoft.net> (raw)
In-Reply-To: <2426021f-e049-40e1-910b-ff92c345135b@p23g2000vbl.googlegroups.com>
References: <db420c9c-2345-4c06-add7-10ea404e4008@g6g2000vbr.googlegroups.com>
<491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com>
<2426021f-e049-40e1-910b-ff92c345135b@p23g2000vbl.googlegroups.com>
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
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-jdbc@postgresql.org
Cc: books@ejurka.com, phosco@gmx.de
Subject: Re: Wrong column default values
In-Reply-To: <alpine.BSO.2.00.0909261040360.2098@leary.csoft.net>
References: <db420c9c-2345-4c06-add7-10ea404e4008@g6g2000vbr.googlegroups.com> <491f66a50909181307q147e92b4g58a6d5ef47cc0518@mail.gmail.com> <2426021f-e049-40e1-910b-ff92c345135b@p23g2000vbl.googlegroups.com> <alpine.BSO.2.00.0909261040360.2098@leary.csoft.net>
* 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