From 060ba17b8105c72c3ce5399cfeb7d77e14b699e1 Mon Sep 17 00:00:00 2001 From: wangzhengyi Date: Fri, 2 Dec 2016 11:29:03 +0800 Subject: [PATCH] Fix Issue #509: Fix NullPointerException when user use delete with executeSingle Signed-off-by: wangzhengyi --- src/com/activeandroid/query/From.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/activeandroid/query/From.java b/src/com/activeandroid/query/From.java index ab3837a90..e5fa52b8c 100644 --- a/src/com/activeandroid/query/From.java +++ b/src/com/activeandroid/query/From.java @@ -312,7 +312,10 @@ public T executeSingle() { } else { limit(1); - SQLiteUtils.rawQuerySingle(mType, toSql(), getArguments()).delete(); + Model model = SQLiteUtils.rawQuerySingle(mType, toSql(), getArguments()); + if (model != null) { + model.delete(); + } return null; }