Skip to content

Commit

Permalink
[sqlite] implement disconnect method
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Apr 27, 2012
1 parent 7ab87c1 commit 26983c0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/DBDish/SQLite.pm6
Expand Up @@ -39,6 +39,11 @@ sub sqlite3_open(Str $filename, CArray[OpaquePointer] $handle)
is native('libsqlite3')
{ ... }

sub sqlite3_close(OpaquePointer)
returns Int
is native('libsqlite3')
{ * }


sub sqlite3_prepare_v2 (
OpaquePointer $handle,
Expand Down Expand Up @@ -143,6 +148,11 @@ class DBDish::SQLite::StatementHandle does DBDish::StatementHandle {
class DBDish::SQLite::Connection does DBDish::Connection {
has $!conn;
method BUILD(:$!conn) { }
method !handle-error($status) {
return if $status == SQLITE_OK;
my $errstr = SQLITE($status);
self!set_errstr($errstr);
}
method prepare(Str $statement, $attr?) {
DBDish::SQLite::StatementHandle.bless(*,
:$!conn,
Expand Down Expand Up @@ -200,7 +210,10 @@ class DBDish::SQLite::Connection does DBDish::Connection {
my $aref = @results;
return $aref;
}
method disconnect() { die 'disconnect NYI' }
method disconnect() {
self!handle_error(sqlite3_close($!conn));
return not self!errstr;
}
}

class DBDish::SQLite:auth<mberends>:ver<0.0.1> {
Expand Down

0 comments on commit 26983c0

Please sign in to comment.