--- a/src/Connection.cpp Wed Dec 25 01:26:02 2019 +0100
+++ b/src/Connection.cpp Wed Dec 25 01:37:05 2019 +0100
@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <sqlite3.h>
+
#include "Connection.h"
namespace relpipe {
--- a/src/Connection.h Wed Dec 25 01:26:02 2019 +0100
+++ b/src/Connection.h Wed Dec 25 01:37:05 2019 +0100
@@ -16,8 +16,6 @@
*/
#pragma once
-#include <sqlite3.h>
-
#include "SqlException.h"
#include "PreparedStatement.h"
@@ -30,7 +28,7 @@
sqlite3* db;
void begin();
public:
- Connection(const char* filename);
+ Connection(const char* filename); // TODO: add DriverManager class + support connecting using a DSN or a connectString
virtual ~Connection();
PreparedStatement* prepareStatement(const char* sql);
bool getAutoCommit();
--- a/src/PreparedStatement.cpp Wed Dec 25 01:26:02 2019 +0100
+++ b/src/PreparedStatement.cpp Wed Dec 25 01:37:05 2019 +0100
@@ -17,6 +17,8 @@
#include <cstring>
+#include <sqlite3.h>
+
#include "PreparedStatement.h"
namespace relpipe {
@@ -99,6 +101,10 @@
return value ? value : ""; // TODO: support NULL values (when supported in relpipe format)
}
+bool PreparedStatement::isComplete(const char* sql) {
+ return sqlite3_complete(sql);
+}
+
}
}
}
--- a/src/PreparedStatement.h Wed Dec 25 01:26:02 2019 +0100
+++ b/src/PreparedStatement.h Wed Dec 25 01:37:05 2019 +0100
@@ -16,8 +16,6 @@
*/
#pragma once
-#include <sqlite3.h>
-
#include <relpipe/reader/typedefs.h>
#include <relpipe/reader/TypeId.h>
#include <relpipe/writer/TypeId.h>
@@ -43,6 +41,7 @@
std::string getColumName(int columnIndex);
relpipe::writer::TypeId getColumType(int columnIndex, relpipe::writer::TypeId defaultType = relpipe::writer::TypeId::STRING);
std::string getString(int columnIndex);
+ static bool isComplete(const char *sql); // TODO: use own implementation + move to a separate class
};
}
--- a/src/SqlHandler.h Wed Dec 25 01:26:02 2019 +0100
+++ b/src/SqlHandler.h Wed Dec 25 01:37:05 2019 +0100
@@ -27,8 +27,6 @@
#include <cassert>
#include <sys/stat.h>
-#include <sqlite3.h>
-
#include <relpipe/reader/typedefs.h>
#include <relpipe/reader/TypeId.h>
#include <relpipe/reader/handlers/RelationalReaderValueHandler.h>
@@ -67,7 +65,7 @@
for (wchar_t ch; *input >> ch;) {
*sql << ch;
- if (ch == L';' && sqlite3_complete(convertor.to_bytes(sql->str()).c_str())) return true;
+ if (ch == L';' && PreparedStatement::isComplete(convertor.to_bytes(sql->str()).c_str())) return true;
}
string_t remainingSql = sql->str();