DBIx::SQLEngine::Driver::NullP - Extends SQLEngine for Simple Testing
DBI Wrapper: Adds methods to a DBI database handle.
my $sqldb = DBIx::SQLEngine->new( 'dbi:NullP:' );
Testing Subclass: To allow basic framework testing.
$sqldb->next_result( rowcount => 1, hashref => [ { id => 201, name => "Dave Jones" } ], ); my $rows = $sqldb->fetch_select( table => 'students' ); ok( $sqldb->last_query, 'select * from students' ); ok( scalar @$rows == $sqldb->last_result->{rowcount} );
This package provides a subclass of DBIx::SQLEngine which works with the DBI's DBD::NullP to provide a simple testing capability. See the "t/null.t" test script for a usage example.
Queries using the NullP driver and subclass keep track of the SQL statements that are executed against them, allowing a simple way of checking whether the SQL generation code is working as expected. You can also provide raw results to be returned by the next query, in order to confirm that other aspects of the result processing are operational.
To simulate normal driver operation, before executing your query, load the results you would expect to receive using next_result, and afterwards confirm that the SQL statement and parameters used matched what you expected.
$sqldb->next_result( rowcount => $number, hashref => $array_of_hashes, arrayref => $array_of_arrays, columns => $array_of_hashes, )
Sets up the values that will be returned by the next query.
$sqldb->last_query() : $statement_and_params
Returns the most recent query and parameters captured by prepare_execute(). Parameters are joined by "/" characters.
$sqldb->last_result() : $result_hash_ref
Returns the values set with next_result() and used by the most recent query.
$sqldb->prepare_execute ($sql, @params) : $sth
Captures the statement and parameters that would otherwise have been sent to the Null driver to be used for later reporting by last_query().
$sqldb->done_with_query ($sth) : ()
Clears the values stored by next_result.
$sqldb->get_execute_rowcount ($sth) : $row_count
Returns the value stored by next_result() using the key "rowcount".
$sqldb->fetchall_hashref ($sth) : $array_of_hashes
Returns the value stored by next_result() using the key "hashref".
$sqldb->fetchall_hashref ($sth) : $array_of_hashes $sqldb->fetchall_hashref ($sth) : ( $array_of_hashes, $column_info )
Returns the value stored by next_result() using the key "hashref", and if called in a list context, also returns the value for the key "columns".
$sqldb->fetchall_arrayref ($sth) : $array_of_arrays
Returns the value stored by next_result() using the key "arrayref".
$sqldb->fetchall_hashref ($sth) : $array_of_arrays $sqldb->fetchall_hashref ($sth) : ( $array_of_arrays, $column_info )
Returns the value stored by next_result() using the key "arrayref", and if called in a list context, also returns the value for the key "columns".
$sqldb->retrieve_columns ($sth) : $column_info
Retrieves the value stored by next_result() using the key "columns".
$sqldb->visitall_hashref ($sth, $coderef) : ()
Uses the value stored by next_result() using the key "hashref". Calls the coderef on each row with values as a hashref, and returns a list of their results.
$sqldb->visitall_array ($sth, $coderef) : ()
Uses the value stored by next_result() using the key "arrayref". Calls the coderef on each row with values as a list, and returns a list of their results.
See DBIx::SQLEngine for the overall interface and developer documentation.
See DBIx::SQLEngine::Docs::ReadMe for general information about this distribution, including installation and license information.
To install DBIx::SQLEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::SQLEngine
CPAN shell
perl -MCPAN -e shell install DBIx::SQLEngine
For more information on module installation, please visit the detailed CPAN module installation guide.