summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-01 20:43:34 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-13 21:30:22 +0100
commit90fde5774f1e6ee1a3b649753fa7338e386a3c45 (patch)
tree70b39921518da5cd74997ca985b3fd294873cdfb /src
parent07c54805e8a4e9a0caafdd18af02628533764f2b (diff)
downloadmanaserv-90fde5774f1e6ee1a3b649753fa7338e386a3c45.tar.gz
manaserv-90fde5774f1e6ee1a3b649753fa7338e386a3c45.tar.bz2
manaserv-90fde5774f1e6ee1a3b649753fa7338e386a3c45.tar.xz
manaserv-90fde5774f1e6ee1a3b649753fa7338e386a3c45.zip
SQLite: Fixed SqLiteDataProvider::processSql handling of multiple rows
When a prepared SQL statement would have returned multiple rows, this function would try to set the column header names multiple times which throws the AlreadySetException. Currently it doesn't seem that any prepared statements are meant to return multiple rows. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src')
-rw-r--r--src/dal/sqlitedataprovider.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dal/sqlitedataprovider.cpp b/src/dal/sqlitedataprovider.cpp
index a47c9862..cc698f61 100644
--- a/src/dal/sqlitedataprovider.cpp
+++ b/src/dal/sqlitedataprovider.cpp
@@ -365,25 +365,27 @@ const RecordSet &SqLiteDataProvider::processSql()
throw std::runtime_error("not connected to database");
int totalCols = sqlite3_column_count(mStmt);
+
+ // ensure we set column headers before adding a row
Row fieldNames;
+ for (int col = 0; col < totalCols; ++col)
+ {
+ fieldNames.push_back(sqlite3_column_name(mStmt, col));
+ }
+ mRecordSet.setColumnHeaders(fieldNames);
while (sqlite3_step(mStmt) == SQLITE_ROW)
{
Row r;
for (int col = 0; col < totalCols; ++col)
{
- fieldNames.push_back(sqlite3_column_name(mStmt, col));
const unsigned char *txt = sqlite3_column_text(mStmt, col);
r.push_back(txt ? (char*)txt : std::string());
}
- // ensure we set column headers before adding a row
- mRecordSet.setColumnHeaders(fieldNames);
mRecordSet.add(r);
}
-
-
sqlite3_finalize(mStmt);
return mRecordSet;