summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-24 10:16:49 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-24 10:16:49 +0100
commit76ae7991549a435a82784484389a113021c5a096 (patch)
tree1704c182e91b409c8efaf816f87763f84e49eda4
parent833b1ed5ed6808c9a054bd251387a1e309e2226b (diff)
downloadRustAndDust-76ae7991549a435a82784484389a113021c5a096.zip
RustAndDust-76ae7991549a435a82784484389a113021c5a096.tar.gz
DB: do not try to execute many commands in a row
-rw-r--r--core/src/ch/asynk/rustanddust/util/DB.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java
index ccbdced..25bfc18 100644
--- a/core/src/ch/asynk/rustanddust/util/DB.java
+++ b/core/src/ch/asynk/rustanddust/util/DB.java
@@ -75,7 +75,9 @@ public class DB
private static final String UPDATE_GAME = "update games set _p1=%d, _p2=%d, ts=current_timestamp where _id=%d;";
private static final String GET_STATE = "select payload from states where _g=%d;";
private static final String GET_GAMES = "select g.*, p1.name, p2.name, b.name from games g inner join players p1 on (g._p1=p1._id) inner join players p2 on (g._p2=p2._id) inner join battles b on (g._b=b._id);";
- private static final String DELETE_GAME = "delete from turns where _g=%d; delete from states where _g=%d; delete from games where _id=%d;";
+ private static final String DELETE_GAME = "delete from games where _id=%d;";
+ private static final String DELETE_STATE = "delete from states where _g=%d;";
+ private static final String DELETE_TURNS = "delete from turns where _g=%d;";
// private static final String DB_CRT = TBL_CFG_CRT + TBL_PLAYERS_CRT + TBL_BATTLES_CRT + TBL_GAMES_CRT + TBL_TURNS_CRT + TBL_STATES_CRT;
@@ -259,7 +261,9 @@ public class DB
{
RustAndDust.debug("deleteGame");
try {
- exec(String.format(DELETE_GAME, game.g, game.g, game.g));
+ exec(String.format(DELETE_TURNS, game.g));
+ exec(String.format(DELETE_STATE, game.g));
+ exec(String.format(DELETE_GAME, game.g));
} catch (SQLiteGdxException e) {
RustAndDust.error("deleteGame");
return false;