Re: pgAdmin4 PATCH: Domain Module

From: Dave Page <dpage(at)pgadmin(dot)org>
To: Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: pgAdmin4 PATCH: Domain Module
Date: 2016-03-22 17:10:16
Message-ID: CA+OCxoyo97fCXo0KhkGSqkC9pusgDQ4sSggEw-D5GiW5pBhaGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

On Mon, Mar 21, 2016 at 7:41 AM, Khushboo Vashi
<khushboo(dot)vashi(at)enterprisedb(dot)com> wrote:
> 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?

Urgh, yes - I hadn't thought of that. Leave it unquoted please.

I guess we can add a hint to the field:

Enter an expression or value.

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

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

In response to

Browse pgadmin-hackers by date

  From Date Subject
Next Message Murtuza Zabuawala 2016-03-23 06:41:51 PATCH: To fix session decoding issue with Python3 [pgAdmin4]
Previous Message Dave Page 2016-03-22 17:05:03 Re: Subnode grid row close issue [pgAdmin4]