utelle / wxsqlite3

wxSQLite3 - SQLite3 database wrapper for wxWidgets (including SQLite3 encryption extension)
http://utelle.github.io/wxsqlite3
Other
589 stars 178 forks source link

wxSQLite3Database::SetJournalMode always returns DELETE #107

Closed carlosrllodra closed 1 year ago

carlosrllodra commented 1 year ago

Hello.

I have found that calling wxSQLite3Database::SetJournalMode() always returns WXSQLITE_JOURNALMODE_DELETE (the default return value).

The reason is PRAGMA journal_mode is returning mode name as a lowercase string, but ConvertJournalMode(const wxString&...) called at the end of SetJournalMode() does case-sensitive comparisons against uppercase mode names, so they never match...

It is solved by just setting caseSensitve=false argument when calling mode.IsSameAs():

/ static / wxSQLite3JournalMode wxSQLite3Database::ConvertJournalMode(const wxString& mode) { wxSQLite3JournalMode journalMode; if (mode.IsSameAs(wxS("DELETE"), false)) journalMode = WXSQLITE_JOURNALMODE_DELETE; else if (mode.IsSameAs(wxS("PERSIST"), false)) journalMode = WXSQLITE_JOURNALMODE_PERSIST; // Etc etc...

Best regards

utelle commented 1 year ago

Thanks for reporting and analyzing the problem.

Commit 534e38a7cb92526471cde0af886349018c2122ca applies your suggested fix.