Skip to content

Commit

Permalink
Fix compilation of new enum Database::BackupType for C++98
Browse files Browse the repository at this point in the history
  • Loading branch information
SRombauts committed Jul 9, 2019
1 parent 514d7d6 commit c1ab707
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,5 @@ Version ?
- #192 Add wrapper for bind parameter count
- #197 Add tuple_bind and execute_many
- #199 Fix #156 misleading error message in exception from Statement::exec
- #201 Add Statement::getExpandedSQL() to get the SQL text of prepared statement with bound parameters expanded
- #201 Add Statement::getExpandedSQL() to get the SQL text of prepared statement with bound parameters expanded
- #211 Implement Database::backup()
6 changes: 5 additions & 1 deletion include/SQLiteCpp/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ class Database
*/
static bool isUnencrypted(const std::string& aFilename);

/**
* @brief BackupType for the backup() method
*/
enum BackupType { Save, Load };

/**
* @brief Load or save the database content.
*
Expand All @@ -443,7 +448,6 @@ class Database
*
* @return SQLITE_OK on success or an error code from SQLite.
*/
enum class BackupType { Save, Load };
int backup(const char* zFilename, BackupType type);

private:
Expand Down
4 changes: 2 additions & 2 deletions src/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ int Database::backup(const char* zFilename, BackupType type) {
** Otherwise, if this is a 'save' operation (isSave==1), then data
** is copied from mpSQLite to pFile. Set the variables pFrom and
** pTo accordingly. */
sqlite3* pFrom = (type == BackupType::Save ? mpSQLite : pFile);
sqlite3* pTo = (type == BackupType::Save ? pFile : mpSQLite);
sqlite3* pFrom = (type == Save ? mpSQLite : pFile);
sqlite3* pTo = (type == Save ? pFile : mpSQLite);

/* Set up the backup procedure to copy from the "main" database of
** connection pFile to the main database of connection mpSQLite.
Expand Down
4 changes: 2 additions & 2 deletions tests/Database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ TEST(Database, import_export)

// Export the data into a file
remove("backup");
EXPECT_EQ(db.backup("backup", SQLite::Database::BackupType::Save), SQLITE_OK);
EXPECT_EQ(db.backup("backup", SQLite::Database::Save), SQLITE_OK);

// Trash the table
db.exec("DROP TABLE test;");
EXPECT_FALSE(db.tableExists("test"));

// Import the data back from the file
EXPECT_EQ(db.backup("backup", SQLite::Database::BackupType::Load), SQLITE_OK);
EXPECT_EQ(db.backup("backup", SQLite::Database::Load), SQLITE_OK);

EXPECT_TRUE(db.tableExists("test"));
}
Expand Down

0 comments on commit c1ab707

Please sign in to comment.