From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Andre Rothe <phosco(at)gmx(dot)de> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Wrong column default values |
Date: | 2009-09-26 14:46:30 |
Message-ID: | alpine.BSO.2.00.0909261040360.2098@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | J. W. Ulbts | 2009-09-27 10:39:03 | Re: DataSource.setMaxConnections() - Does not work |
Previous Message | Kris Jurka | 2009-09-26 14:38:00 | Re: Support for getting generated keys. |