mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
DBD-SQLite: started using install_method(); ported last_insert_rowid as the first attempt
This commit is contained in:
parent
7315981580
commit
16d3af7794
3 changed files with 20 additions and 2 deletions
|
@ -24,6 +24,8 @@ list_tables(dbh)
|
|||
IV
|
||||
last_insert_rowid(dbh)
|
||||
SV *dbh
|
||||
ALIAS:
|
||||
DBD::SQLite::db::sqlite_last_insert_rowid = 1
|
||||
CODE:
|
||||
{
|
||||
D_imp_dbh(dbh);
|
||||
|
|
|
@ -24,13 +24,23 @@ BEGIN {
|
|||
|
||||
__PACKAGE__->bootstrap($VERSION);
|
||||
|
||||
my $methods_are_installed;
|
||||
|
||||
sub driver {
|
||||
$drh or
|
||||
return $drh if $drh;
|
||||
|
||||
if (!$methods_are_installed && $DBI::VERSION >= 1.608) {
|
||||
DBI->setup_driver('DBD::SQLite');
|
||||
DBD::SQLite::db->install_method('sqlite_last_insert_rowid');
|
||||
$methods_are_installed++;
|
||||
}
|
||||
|
||||
$drh = DBI::_new_drh( "$_[0]::dr", {
|
||||
Name => 'SQLite',
|
||||
Version => $VERSION,
|
||||
Attribution => 'DBD::SQLite by Matt Sergeant et al',
|
||||
} );
|
||||
return $drh;
|
||||
}
|
||||
|
||||
sub CLONE {
|
||||
|
|
|
@ -7,7 +7,7 @@ BEGIN {
|
|||
}
|
||||
|
||||
use t::lib::Test;
|
||||
use Test::More tests => 12;
|
||||
use Test::More tests => 14;
|
||||
use Test::NoWarnings;
|
||||
|
||||
my $dbh = connect_ok();
|
||||
|
@ -30,6 +30,12 @@ SCOPE: {
|
|||
is( $dbh->last_insert_id(undef, undef, undef, undef), 4 );
|
||||
is( $dbh->func('last_insert_rowid'), 4, 'last_insert_rowid should be 4' );
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip( 'method installation requires DBI v1.608', 2 ) if $DBI::VERSION < 1.608;
|
||||
can_ok($dbh, 'sqlite_last_insert_rowid');
|
||||
is( $dbh->sqlite_last_insert_rowid, 4, 'last_insert_rowid should be 4' );
|
||||
}
|
||||
}
|
||||
|
||||
is( $dbh->do("delete from f where f1='test'"), 3 );
|
||||
|
|
Loading…
Add table
Reference in a new issue