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
