Re: pgAdmin4 PATCH: Domain Module

Поиск
Список
Период
Сортировка
От Dave Page
Тема Re: pgAdmin4 PATCH: Domain Module
Дата
Msg-id CA+OCxoyo97fCXo0KhkGSqkC9pusgDQ4sSggEw-D5GiW5pBhaGQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pgAdmin4 PATCH: Domain Module  (Khushboo Vashi <khushboo.vashi@enterprisedb.com>)
Список pgadmin-hackers
On Mon, Mar 21, 2016 at 7:41 AM, Khushboo Vashi
<khushboo.vashi@enterprisedb.com> wrote:
> Hi Dave,
>
>
> On Fri, Mar 18, 2016 at 8:31 PM, Dave Page <dpage@pgadmin.org> wrote:
>>
>> On Thu, Mar 17, 2016 at 5:39 PM, Khushboo Vashi
>> <khushboo.vashi@enterprisedb.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


В списке pgadmin-hackers по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Subnode grid row close issue [pgAdmin4]
Следующее
От: Murtuza Zabuawala
Дата:
Сообщение: PATCH: To fix session decoding issue with Python3 [pgAdmin4]