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