Re: pgAdmin4 PATCH: Domain Module

From: Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: pgAdmin4 PATCH: Domain Module
Date: 2016-03-21 07:41:34
Message-ID: CAFOhELe-NU89_LunRFgh2S7jcM7DuChx0mA4DuL_WG1HvJzMsQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi Dave,

On Fri, Mar 18, 2016 at 8:31 PM, Dave Page <dpage(at)pgadmin(dot)org> wrote:

> On Thu, Mar 17, 2016 at 5:39 PM, Khushboo Vashi
> <khushboo(dot)vashi(at)enterprisedb(dot)com> wrote:
> > Hi Dave,
> >
> > I have a query regarding your below feedback :
> >
> > - Default values should be auto-quoted when necessary (ie. strings, on a
> > text-based domain).
> >
> > To resolve this, I have checked the typcategory field from pg_type for
> the
> > base_type selected for the Domain.
> > If the typcategory is String type (i.e. S), then only I have used
> qtLiteral
> > function to quote the default value.
> >
> > Is this right approach or not?
>
> Yes, I think that's a good approach (at least, I don't see any
> downsides right now :-) )
>
>
After implementing above approach, I found some issues:

1> If I put quotes explicitly, user can not set any expression as a default
value
For example,

CREATE OR REPLACE FUNCTION test_text_return() RETURNS TEXT AS
$$
SELECT now()::text;
$$ LANGUAGE 'sql';

CREATE DOMAIN text_domin AS TEXT DEFAULT public.test_text_return();

In this case, if I put quotes for default value, it will be set as a
string rather than an expression.

2> When I set any string for the default value, it is getting stored with
the datatype like 'test_default'::text
So, in the Default Value (Properties Dialogue), it is showing
'test_default'::text

I have tried pg_get_expr(typdefaultbin, 0) to fetch only default
value (without datatype), but it returns the whole expression.

As per my discussion with Ashesh, we feel - we should not quote the default
value after looking at the above example.

Please, let me know what should I do further?

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Murtuza Zabuawala 2016-03-21 10:55:11 Suggestion on "External types" sql query in pgAdmin3
Previous Message Harshal Dhumal 2016-03-21 06:05:30 Re: Control for selecting multiple columns [pgadmin4]