Re: pgAdmin4 PATCH: Domain Module

Поиск
Список
Период
Сортировка
От Khushboo Vashi
Тема Re: pgAdmin4 PATCH: Domain Module
Дата
Msg-id CAFOhELe-NU89_LunRFgh2S7jcM7DuChx0mA4DuL_WG1HvJzMsQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pgAdmin4 PATCH: Domain Module  (Dave Page <dpage@pgadmin.org>)
Ответы Re: pgAdmin4 PATCH: Domain Module  (Dave Page <dpage@pgadmin.org>)
Список pgadmin-hackers
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?


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

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

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

Предыдущее
От: Harshal Dhumal
Дата:
Сообщение: Re: Control for selecting multiple columns [pgadmin4]
Следующее
От: Murtuza Zabuawala
Дата:
Сообщение: Suggestion on "External types" sql query in pgAdmin3