aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'odb/sqlite')
-rw-r--r--odb/sqlite/statement.cxx34
-rw-r--r--odb/sqlite/statement.hxx8
2 files changed, 21 insertions, 21 deletions
diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx
index 417a746..fc9e780 100644
--- a/odb/sqlite/statement.cxx
+++ b/odb/sqlite/statement.cxx
@@ -132,7 +132,7 @@ namespace odb
//
if (!truncated)
{
- *b.is_null = sqlite3_column_type (stmt_, j) != SQLITE_NULL;
+ *b.is_null = sqlite3_column_type (stmt_, j) == SQLITE_NULL;
if (*b.is_null)
continue;
@@ -200,15 +200,14 @@ namespace odb
if (stmt_ == 0) // Empty statement or comment.
return 0;
- if (int e = sqlite3_reset (stmt_))
- translate_error (e, conn_);
-
unsigned long long r (0);
int e;
for (e = sqlite3_step (stmt_); e == SQLITE_ROW; e = sqlite3_step (stmt_))
r++;
+ sqlite3_reset (stmt_);
+
if (e != SQLITE_DONE)
translate_error (e, conn_);
@@ -235,13 +234,15 @@ namespace odb
execute ()
{
done_ = false;
-
- if (int e = sqlite3_reset (stmt_))
- translate_error (e, conn_);
-
bind_param (cond_.bind, cond_.count);
}
+ void select_statement::
+ free_result ()
+ {
+ sqlite3_reset (stmt_);
+ }
+
bool select_statement::
next ()
{
@@ -254,6 +255,7 @@ namespace odb
case SQLITE_DONE:
{
done_ = true;
+ sqlite3_reset (stmt_);
break;
}
case SQLITE_ROW:
@@ -262,6 +264,7 @@ namespace odb
}
default:
{
+ sqlite3_reset (stmt_);
translate_error (e, conn_);
}
}
@@ -300,13 +303,12 @@ namespace odb
bool insert_statement::
execute ()
{
- if (int e = sqlite3_reset (stmt_))
- translate_error (e, conn_);
-
bind_param (data_.bind, data_.count);
int e (sqlite3_step (stmt_));
+ sqlite3_reset (stmt_);
+
if (e != SQLITE_DONE)
{
// SQLITE_CONSTRAINT error code covers more than just a duplicate
@@ -345,14 +347,13 @@ namespace odb
void update_statement::
execute ()
{
- if (int e = sqlite3_reset (stmt_))
- translate_error (e, conn_);
-
bind_param (data_.bind, data_.count);
bind_param (cond_.bind, cond_.count, data_.count);
int e (sqlite3_step (stmt_));
+ sqlite3_reset (stmt_);
+
if (e != SQLITE_DONE)
translate_error (e, conn_);
@@ -372,13 +373,12 @@ namespace odb
unsigned long long delete_statement::
execute ()
{
- if (int e = sqlite3_reset (stmt_))
- translate_error (e, conn_);
-
bind_param (cond_.bind, cond_.count);
int e (sqlite3_step (stmt_));
+ sqlite3_reset (stmt_);
+
if (e != SQLITE_DONE)
translate_error (e, conn_);
diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx
index 967ff3d..fe541e5 100644
--- a/odb/sqlite/statement.hxx
+++ b/odb/sqlite/statement.hxx
@@ -109,15 +109,15 @@ namespace odb
// Free the result set.
//
void
- free_result ()
- {
- }
+ free_result ();
// More fine-grained SQLite-specific interface that splits fetch()
// into next() and load().
//
public:
- // Return false if there is no more rows.
+ // Return false if there is no more rows. You should call next()
+ // until it returns false or, alternatively, call free_result ().
+ // Otherwise the statement will remain unfinished.
//
bool
next ();