I've seen this approach to "removing" SQL from code before. You're not actually achieving much.

  1. you still need to write/port the SQL to other databases, if you are doing a lot of queries this is a problem.
  2. and all your SQL ends up in one place which is a nightmare for management in larger programming projects; it needs to be closest to where it is being used and independant.
  3. You still are stuck if you want to represent complex ideas such as members that are lists, sets, etc.
  4. Every time you want to do a simple query you have to edit that central list!

Here's the real Perl code to do what you do in your POD, using Tangram:

# return an object representing the "remote" object, ie the # one in the object store my $remote_customer = $db->remote("Customer"); # get all customers whose name is like ?Wall my (@objs) = $db->select( $remote_customer, $remote_customer->{name}->like("?Wall") ); # set the first one's balance to 10000 $obj[0]->{balance} = 10000; $db->store($obj[0]);

Other things:

I would change:

croak "DBI::Pretty requires a valid DBI object" unless $dbi;

to:

croak "DBI::Pretty requires a valid DBI object" unless (ref $dbi and $dbi->isa("DBI"));

Wouldn't it also be cleaner to write:

sub new($$;$) { my ($class, $dbi, $hash) = (@_); croak "DBI::Pretty requires a valid DBI object" unless $dbi; $hash ||= {};

instead of:

sub new { my $class = shift; my $dbi = shift; croak "DBI::Pretty requires a valid DBI object" unless $dbi; my $hash = shift || {};

In reply to Re: DBI::Pretty by mugwumpjism
in thread DBIx::Pretty (was DBI::Pretty) by Masem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.