public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dave Page <[email protected]>
To: Khushboo Vashi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: pgAdmin4 PATCH: Domain Module
Date: Tue, 22 Mar 2016 17:10:16 +0000
Message-ID: <CA+OCxoyo97fCXo0KhkGSqkC9pusgDQ4sSggEw-D5GiW5pBhaGQ@mail.gmail.com> (raw)
In-Reply-To: <CAFOhELe-NU89_LunRFgh2S7jcM7DuChx0mA4DuL_WG1HvJzMsQ@mail.gmail.com>
References: <CAFOhELf-n8mM4h8RZuqxUs-Z+f97N6Ux5KT6aoAdWFiHVVURyw@mail.gmail.com>
	<CAFOhELf-QTMAgNkTT8AsRwJ38Jn_1BSFRV_G5ZmcHnrKmPsTog@mail.gmail.com>
	<CACCA4P1caumXOrpEXrrETMuNGj3G3ctY-PN9=V6GUPF=dTBnWg@mail.gmail.com>
	<CAFOhELdgb566u+4XXOOP4pDCF4GGzK8JZzLrrTuPt=OprsqG5Q@mail.gmail.com>
	<CACCA4P06PrJ2-VodT133sheH1i+7zc_M_y_me6KfRHkLqrQ7gg@mail.gmail.com>
	<CAFOhELc1OAz3BDWkKC0e0xA8sPBKiO-4vWJQ7ipMYmKC-C6YzA@mail.gmail.com>
	<CACCA4P1uFijfEV6vvETXX=qjafhGZsOacdi7Og+7edaBb4erxA@mail.gmail.com>
	<CAFOhELePQ_m8zmbORLmO3PUY5yTA5o_9suQKk0Tox8A7Fb8ovw@mail.gmail.com>
	<CAFOhELcq3oiXAC3LVCvxVA5i8qjCh=Sk77MsVUnZB2VhwzmLKw@mail.gmail.com>
	<CA+OCxozpzStRAm=rm3s2ZdtehMt6WfQTVEFT3fssorNc5M2UHQ@mail.gmail.com>
	<CA+OCxoxkows1UUgaddq3+R2VcTW9Vmc3QCKdrtd1sNP+fDsHTg@mail.gmail.com>
	<CAFOhELfzRV1WoA7A87=g5Nb9uvU3rLL2jPUCEid66pqzFdrfRQ@mail.gmail.com>
	<CA+OCxoxWUGqp5P_KSUbKBXH-i2AD4E8STWcfxsy01iVAymU-Og@mail.gmail.com>
	<CAFOhELfA8rTWKJr_P9=Z6--oeE0m7E40nZFr=WFSs2g8=3RmAg@mail.gmail.com>
	<CAFOhELewp6_jT35CkG8u8-+K+H9AhFS_QpiwXfMcCib6vJyJBg@mail.gmail.com>
	<CA+OCxoyRLYFv_SxNNGdsGN=Up7d3WT_EQz0-h9P+S+0oRtjaYg@mail.gmail.com>
	<CAFOhELc0PU6yuMGRX5xDj=njVnqVj7Jj632VY4AS9j0NRn60Bg@mail.gmail.com>
	<CA+OCxoyRWtG4PR+jFgbDJi+S+Rbuazc7km+pXMK2zcCL4BzxUA@mail.gmail.com>
	<CAFOhELe-NU89_LunRFgh2S7jcM7DuChx0mA4DuL_WG1HvJzMsQ@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

On Mon, Mar 21, 2016 at 7:41 AM, Khushboo Vashi
<[email protected]> wrote:
> Hi Dave,
>
>
> On Fri, Mar 18, 2016 at 8:31 PM, Dave Page <[email protected]> wrote:
>>
>> On Thu, Mar 17, 2016 at 5:39 PM, Khushboo Vashi
>> <[email protected]> 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


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



view thread (29+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgAdmin4 PATCH: Domain Module
  In-Reply-To: <CA+OCxoyo97fCXo0KhkGSqkC9pusgDQ4sSggEw-D5GiW5pBhaGQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox