Skip to content

Commit

Permalink
Fix bug when query database with specific keys
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Oct 27, 2018
1 parent dbb8b8a commit f9e32a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions native/jni/daemon/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int get_db_settings(sqlite3 *db, int key, struct db_settings *dbs) {
char *err;
if (key > 0) {
char query[128];
sprintf(query, "SELECT key, value FROM settings WHERE key=%d", key);
sprintf(query, "SELECT key, value FROM settings WHERE key='%s'", DB_SETTING_KEYS[key]);
sqlite3_exec(db, query, settings_cb, dbs, &err);
} else {
sqlite3_exec(db, "SELECT key, value FROM settings", settings_cb, dbs, &err);
Expand Down Expand Up @@ -134,7 +134,7 @@ int get_db_strings(sqlite3 *db, int key, struct db_strings *str) {
char *err;
if (key > 0) {
char query[128];
sprintf(query, "SELECT key, value FROM strings WHERE key=%d", key);
sprintf(query, "SELECT key, value FROM strings WHERE key='%s'", DB_STRING_KEYS[key]);
sqlite3_exec(db, query, strings_cb, str, &err);
} else {
sqlite3_exec(db, "SELECT key, value FROM strings", strings_cb, str, &err);
Expand Down

0 comments on commit f9e32a1

Please sign in to comment.