Skip Menu |

This queue is for tickets about the DBI-Shell CPAN distribution.

Report information
The Basics
Id: 53311
Status: resolved
Priority: 0/
Queue: DBI-Shell

People
Owner: DLAMBLEY [...] cpan.org
Requestors: mjp [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 11.95
Fixed in: 11.96_03



Subject: PATCH: configurable NULL and BOOLEAN representation
The attached patch adds two options to DBI::Shell to let the user control the representation of NULL ( '(NULL)', undef, '(unknown)', etc.) and BOOLEAN (1 and 0, 't' and 'f', 'TRUE' and 'FALSE', etc.) values.

This patch is a small step toward a cleaner (IMHO) DBI::Format::* design, with values' representation (what do NULLs look like?  what about INTERVALs?) distinct from encoding (do we HTML- or XML-encode?  URI-escape?  scrub ASCII non-printables?).  Additionally, some code duplicated across most formatter subclasses was moved into DBI::Format::Base, with SUPER::foo calls added as needed.

It wasn't clear to me how to unit test this change, though current tests pass.  I'm happy to polish this as needed.

    @dbi:Pg:mjp> /option
    ...
    bool_format: Y,N
    null_format: (NULL)

    @dbi:Pg:mjp> SELECT true, false, null;
    bool,bool,?column?
    'Y','N','(NULL)'
    [1 rows of 3 fields returned]

    @dbi:Pg:mjp> /option bool_format=TRUE,FALSE
    /option bool_format=TRUE,FALSE  (was Y,N)

    @dbi:Pg:mjp> /option null_format=UNKNOWN
    /option null_format=UNKNOWN  (was (NULL))

    @dbi:Pg:mjp> SELECT true, false, null;
    bool,bool,?column?
    'TRUE','FALSE','UNKNOWN'
    [1 rows of 3 fields returned]

Subject: DBI-Shell-11.95-nullbool-format.patch

Message body is not shown because it is too large.

On Sun Jan 03 01:58:25 2010, MJP wrote: Show quoted text
> The attached patch adds two options to DBI::Shell to let the user > control the > representation of NULL ( '(NULL)', undef, '(unknown)', etc.) and > BOOLEAN (1 and > 0, 't' and 'f', 'TRUE' and 'FALSE', etc.) values. > > This patch is a small step toward a cleaner (IMHO) DBI::Format::* > design, with > values' representation (what do NULLs look like? what about > INTERVALs?) > distinct from encoding (do we HTML- or XML-encode? URI-escape? scrub > ASCII > non-printables?). Additionally, some code duplicated across most > formatter > subclasses was moved into DBI::Format::Base, with SUPER::foo calls > added as > needed. > > It wasn't clear to me how to unit test this change, though current > tests pass. > I'm happy to polish this as needed. > > @dbi:Pg:mjp> /option > ... > bool_format: Y,N > null_format: (NULL) > > @dbi:Pg:mjp> SELECT true, false, null; > bool,bool,?column? > 'Y','N','(NULL)' > [1 rows of 3 fields returned] > > @dbi:Pg:mjp> /option bool_format=TRUE,FALSE > /option bool_format=TRUE,FALSE (was Y,N) > > @dbi:Pg:mjp> /option null_format=UNKNOWN > /option null_format=UNKNOWN (was (NULL)) > > @dbi:Pg:mjp> SELECT true, false, null; > bool,bool,?column? > 'TRUE','FALSE','UNKNOWN' > [1 rows of 3 fields returned]
Thank you for your patch! I have merged it into a branch to give a read through. https://repo.or.cz/perl-DBI-Shell.git/shortlog/refs/heads/nullbool Are you still making use of this module? Best regards, Dave
On Tue Jul 21 13:36:00 2020, DLAMBLEY wrote: Show quoted text
> On Sun Jan 03 01:58:25 2010, MJP wrote:
> > The attached patch adds two options to DBI::Shell to let the user > > control the > > representation of NULL ( '(NULL)', undef, '(unknown)', etc.) and > > BOOLEAN (1 and > > 0, 't' and 'f', 'TRUE' and 'FALSE', etc.) values. > > > > This patch is a small step toward a cleaner (IMHO) DBI::Format::* > > design, with > > values' representation (what do NULLs look like? what about > > INTERVALs?) > > distinct from encoding (do we HTML- or XML-encode? URI-escape? scrub > > ASCII > > non-printables?). Additionally, some code duplicated across most > > formatter > > subclasses was moved into DBI::Format::Base, with SUPER::foo calls > > added as > > needed. > > > > It wasn't clear to me how to unit test this change, though current > > tests pass. > > I'm happy to polish this as needed. > > > > @dbi:Pg:mjp> /option > > ... > > bool_format: Y,N > > null_format: (NULL) > > > > @dbi:Pg:mjp> SELECT true, false, null; > > bool,bool,?column? > > 'Y','N','(NULL)' > > [1 rows of 3 fields returned] > > > > @dbi:Pg:mjp> /option bool_format=TRUE,FALSE > > /option bool_format=TRUE,FALSE (was Y,N) > > > > @dbi:Pg:mjp> /option null_format=UNKNOWN > > /option null_format=UNKNOWN (was (NULL)) > > > > @dbi:Pg:mjp> SELECT true, false, null; > > bool,bool,?column? > > 'TRUE','FALSE','UNKNOWN' > > [1 rows of 3 fields returned]
> > > Thank you for your patch! I have merged it into a branch to give a > read through. > > https://repo.or.cz/perl-DBI-Shell.git/shortlog/refs/heads/nullbool > > Are you still making use of this module? > > Best regards, > Dave
I am releasing these changes in version 11.97. https://repo.or.cz/perl-DBI-Shell.git/commitdiff/d6e6efb09b5699283c156710a9f121d425dc72eb All the best, Dave