Skip to content

Commit

Permalink
Send PRAGMA queries to SELECT handler (Android) (#91)
Browse files Browse the repository at this point in the history
Issue #65

Co-authored-by: Dev Null <dev@null.com>
  • Loading branch information
beeks and xenophile127 committed Mar 17, 2021
1 parent 38ce5f9 commit e768ea8
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void run() {
String sql = sqlQuery.getString(0);
ReadableArray queryArgs = sqlQuery.getArray(1);
try {
if (isSelect(sql)) {
if (isSelectOrPragmaQuery(sql)) {
results[i] = doSelectInBackgroundAndPossiblyThrow(sql, queryArgs, db);
} else { // update/insert/delete
if (readOnly) {
Expand Down Expand Up @@ -284,8 +284,10 @@ private static WritableNativeArray convertPluginResultToArray(SQLitePLuginResult
return data;
}

private static boolean isSelect(String str) {
return startsWithCaseInsensitive(str, "select");

private static boolean isSelectOrPragmaQuery(String str) {
return startsWithCaseInsensitive(str, "select") ||
(startsWithCaseInsensitive(str, "pragma") && !str.contains("="));
}
private static boolean isInsert(String str) {
return startsWithCaseInsensitive(str, "insert");
Expand Down

0 comments on commit e768ea8

Please sign in to comment.