Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiPp8-0006Zy-FK for pgadmin-hackers@arkaria.postgresql.org; Tue, 22 Mar 2016 17:10:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aiPp7-0005Nk-8e for pgadmin-hackers@arkaria.postgresql.org; Tue, 22 Mar 2016 17:10:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aiPp6-0005Nb-L8 for pgadmin-hackers@postgresql.org; Tue, 22 Mar 2016 17:10:28 +0000 Received: from mail-io0-x230.google.com ([2607:f8b0:4001:c06::230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1aiPow-0007nS-2Z for pgadmin-hackers@postgresql.org; Tue, 22 Mar 2016 17:10:27 +0000 Received: by mail-io0-x230.google.com with SMTP id 124so97242496iov.3 for ; Tue, 22 Mar 2016 10:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=oosw4Ddg2DeM+5TOfhVCD8TUa1xN5kq8nrW5xkczZD8=; b=igdiNmIsXPUL7IpsJKlSTOoXe7YSgRXePz57Ac7xrmcYlCEfYALXX/64JS6MI62QXC E2pzsuri170si+4VHgyg+BFOREsUhQsRaBKHjh+JEo0QHGi3lR9GVJ1hA75DrK5QmYPJ BITgwV0evLC3M7zQGXkoedbBD5JhcYYmyF5OUVp3MIapmtTDVXF80ji1mFDeBwBe/JmD h0B5+FWXNW9FClsRpfBtFSU+FU+GTibw3wFTcJBeroT2aHb971lA42UDiy9fghN3gTKm AU5u/qZfyPE0AbsyxhETUZV+Hexz3ZKOCtdVtQYGpGJyKAFkcjxl8QDhwaVZ7iRhwqd0 lzDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=oosw4Ddg2DeM+5TOfhVCD8TUa1xN5kq8nrW5xkczZD8=; b=SWG9txv+ZopHSb0pJcobmgwhwH6hTDcIr4N/I8hmH4UPpEM/aFy1MQp57iz7I58lJ9 uyaXSVAMhda5vOyHjXaP7j74Lmx0y4Na0KGmto5n+B9x+S1NW1huprPvp6mThiBSrSD4 m33PB8Uqcw/p+VjAyJMrlJBkhXQg6+VYF/FMWe5/c1dHDMuS/AS1K5I+OSU5tNBYtkcI kDGkoP/5F/heTCXyYyl6e+1TlEjWb4h/URo2PzWDK/fqEfwSysP9x4/VSzS8xISJX8iI 0Wp9vQ41+TgpN+rMmSCVuog0vM+QUqI53zIYgmfwgUCupAe9mGVabVrk5dMNY3GaMipl RWVw== X-Gm-Message-State: AD7BkJKj4p2qdAD3wjO6TvrzBqymOThEL77kM1Glfx+9EesqwiFYWp2FQR3KSiqQ1B/W63xPQ26TicgvBeuF0w== MIME-Version: 1.0 X-Received: by 10.107.43.2 with SMTP id r2mr35760924ior.156.1458666617007; Tue, 22 Mar 2016 10:10:17 -0700 (PDT) Received: by 10.64.24.175 with HTTP; Tue, 22 Mar 2016 10:10:16 -0700 (PDT) In-Reply-To: References: Date: Tue, 22 Mar 2016 17:10:16 +0000 Message-ID: Subject: Re: pgAdmin4 PATCH: Domain Module From: Dave Page To: Khushboo Vashi Cc: pgadmin-hackers Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org On Mon, Mar 21, 2016 at 7:41 AM, Khushboo Vashi wrote: > Hi Dave, > > > On Fri, Mar 18, 2016 at 8:31 PM, Dave Page wrote: >> >> On Thu, Mar 17, 2016 at 5:39 PM, Khushboo Vashi >> 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 (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers