Wrap DBI to for simpler new() , filtering of output , simpler queries

Bug #677658 reported by Dan MacNeil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MVHub
In Progress
Medium
Steven LeBoeuf

Bug Description

GOALS:
We want to sub class the standard build in DBI library to:

       1) simplify constructor
       2) simplify fetchall_ syntax
       3) create ouput filtered through HTML::Entities

 #3 is important because we accept chars like & or accent grave
    that aren't valid html and then spit them out

DOCS
 existing similar source code:
      more lib-mvhub/lib/MVHub/Wrap/ConfigSimple.pm

  man perltoot
  man perlobj

CODE TO ADD:
     lib-mvhub/lib/MVHub/Wrap/DBI.pm

  with methods:
  sub new() # to contain the functionality of:
                                # MVHub::Utils::DB::get_dbh()
                                # --and to use $ENV{MV_CONFIG_FILE}

                                # if no filename is passed as param
                                # use $ENV{MV_CONFIG_FILE}

        and replacements for:
                  selectall_arrayref
                     selectcol_arrayref
                     selectrow_array

 ...these replacements
             mvh_sall_aref
                    mvh_scol_aref
                    mvh_srow_aref

     1) includes functionality of:

  MVHub::Utils::DB::get_sql_select_statement();

          2) simplify parameter list to foo('QUERY_NAME',@bind_values);

   3) run the output from the database through:

    HTML::Entities::encode_entitites(...)

MODIFY CODE:

 1) lib-mvhub/lib/MVHub/CGIAppBase.pm

    a. probably all of CGIAppBase::retr_select_sql()
        can be removed

        2) most places that call
                        selectall_arrayref
                    selectcol_arrayref
                    selectrow_array

Note: it may be easier/better to replace selectrow_array with
selectall_arrayref than to write a replacement selectrow_array

 3) most places that call
   my $dbh = MVHub::Utils:DB::get_dbh()
  replaced with:
   my $dbh = MVHub::Wrap::DBI->new();
DELETE CODE:

# probably
 MVHub::Utils::DB.pm::get_sql_select_statement()

USEFUL GREPS

These commands will find places where calling code almost certainly must
be modified:

    cdw
    export $REGEX='\$dbh\->\selectrow_array|selectall|selectcol_arra|get_dbh'
    egrep $REGEX . -rl

 to filter out false positives:

    export SKIP_REGEX='README|foo.pl'
        egrep $REGEX . -rl | egrep -v $SKIP_REGEX

Tags: refactor
Changed in mvhub:
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.