Skip to content

Commit 6c99c9b

Browse files
committed
Fallback for old SQLite versions
1 parent 96b1230 commit 6c99c9b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

hdr/sqlite_modern_cpp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,13 @@ namespace sqlite {
157157
}
158158

159159
std::string sql() {
160+
#if SQLITE_VERSION_NUMBER >= 3014000
160161
auto sqlite_deleter = [](void *ptr) {sqlite3_free(ptr);};
161162
std::unique_ptr<char, decltype(sqlite_deleter)> str(sqlite3_expanded_sql(_stmt.get()), sqlite_deleter);
162163
return str ? str.get() : original_sql();
164+
#else
165+
return original_sql();
166+
#endif
163167
}
164168

165169
std::string original_sql() {

tests/exceptions.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ int main() {
2121
cerr << e.get_code() << ": " << e.what() << " during "
2222
<< quoted(e.get_sql()) << endl;
2323
expception_thrown = true;
24+
#if SQLITE_VERSION_NUMBER >= 3014000
2425
if(e.get_sql() != "INSERT INTO person (id,name) VALUES (1,'jack')") {
26+
#else
27+
if(e.get_sql() != "INSERT INTO person (id,name) VALUES (?,?)") {
28+
#endif
2529
cerr << "Wrong statement failed\n";
2630
exit(EXIT_FAILURE);
2731
}

0 commit comments

Comments
 (0)