Permalink
Browse files

Merge branch 'sqlite-tests' into no-dsn

  • Loading branch information...
2 parents 033acbc + eccbcf5 commit 38d18078d2fd5f5d6d468db283707149cc0c5712 @moritz moritz committed Apr 26, 2012
Showing with 23 additions and 8 deletions.
  1. +8 −5 lib/MiniDBD/SQLite.pm6
  2. +12 −0 t/40-sqlite-common.t
  3. +3 −3 t/99-common.pl6
View
@@ -92,7 +92,7 @@ class MiniDBD::SQLite::StatementHandle does MiniDBD::StatementHandle {
die $errstr if $.RaiseError;
}
- submethod BUILD(:$!conn) {
+ submethod BUILD(:$!conn, :$!statement) {
my @stmt := CArray[OpaquePointer].new;
@stmt[0] = OpaquePointer;
my $status = sqlite3_prepare_v2(
@@ -117,23 +117,25 @@ class MiniDBD::SQLite::StatementHandle does MiniDBD::StatementHandle {
method rows() {
die 'Cannot determine rows of closed connection' unless $!conn.DEFINITE;
- sqlite3_changes($!conn);
+ my $rows = sqlite3_changes($!conn);
+ $rows == 0 ?? '0E0' !! $rows;
}
method fetchrow_array {
my @row;
return @row if $!row_status == SQLITE_DONE;
for ^sqlite3_column_count($!statement_handle) {
- @row.push: sqlite3_column_text($!statement_handle);
+ @row.push: sqlite3_column_text($!statement_handle, $_);
}
$!row_status = sqlite3_step($!statement_handle);
+
@row;
}
method fetchrow_arrayref {
self.fetchrow_array.item;
}
method fetch() { self.fetchrow_arrayref }
- method fetchall_arrayref {
+ method _fetchall_arrayref {
my @rows;
while self.fetchrow_arrayref -> $r {
@rows.push: $r;
@@ -169,7 +171,8 @@ class MiniDBD::SQLite::Connection does MiniDBD::Connection {
method rows() {
die 'Cannot determine rows of closed connection' unless $!conn.DEFINITE;
- sqlite3_changes($!conn);
+ my $rows = sqlite3_changes($!conn);
+ $rows == 0 ?? '0E0' !! $rows;
}
method selectrow_arrayref(Str $statement, $attr?, *@bind is copy) {
View
@@ -0,0 +1,12 @@
+# MiniDBI/t/40-SQLite-common.t
+use v6;
+use Test;
+use MiniDBI;
+
+# Define the only database specific values used by the common tests.
+my ( $*mdriver, %*opts) = 'SQLite';
+%*opts<database> = 'minidbi-test.sqlite3';
+my $dbh;
+
+# Detect and report possible errors from eval of the common test script
+warn $! if "ok 99-common.pl6" ne eval slurp 't/99-common.pl6';
View
@@ -98,7 +98,7 @@ if 'fetchall_arrayref' eq any($sth.^methods) {
[ 'BEOM', 'Medium size orange juice', '2', '1.20', '2.40' ] ],
"selected data matches what was written"; # test 18
}
-else { skip 2, 'fetchall_arrayref not implemented' }
+else { skip 'fetchall_arrayref not implemented', 2 }
ok $sth = $dbh.prepare("SELECT * FROM nom WHERE name='TAFM';"),
'prepare new select for fetchrow_hashref test'; #test 19
@@ -120,7 +120,7 @@ if 'fetchrow_arrayref' eq any ($sth.^methods) {
#is $arrayref, [ 'TAFM', 'Mild fish taco', '1', '4.85' ],
#'selected data matches test data'; #test 23
}
-else { skip 2, 'fetchrow_arrayref not implemented' }
+else { skip 'fetchrow_arrayref not implemented', 2 }
#TODO: I made piña colada (+U00F1) at first to test unicode. It gets properly
# inserted and selected, but a comparison within arrayref fails.
@@ -143,7 +143,7 @@ if 'fetchrow_arrayref' eq any ($sth.^methods) {
is $arrayref, [ 'PICO', 'Delish pina colada', '5', '7.90' ],
'selected data matches test data of fetchrow_arrayref'; #test 32
}
-else { skip 2, 'fetchrow_arrayref not implemented' }
+else { skip 'fetchrow_arrayref not implemented', 2 }
# TODO: weird sth/dbh behavior workaround again.
if 'fetchrow_arrayref' eq any ($sth.^methods) {

0 comments on commit 38d1807

Please sign in to comment.