Skip to content
Snippets Groups Projects
Commit 415bdcd7 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Merge branch 'V3.2' into 'devel'

#374 Fixed double game records while full sync to new device



See merge request !360
parents 5528bd93 0b5eda61
Branches
Tags
No related merge requests found
......@@ -166,7 +166,7 @@ public class GameDAO {
public static final String GAME_SELECT_FOR_RANK_MANAGER = "SELECT id, difficulty_number, game_number, start_time, end_time FROM game WHERE user_id = ? AND end_time IS NOT NULL AND end_time != 0 ORDER BY end_time ASC";
// classic statements
public static final String IMPORT_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, random_seed, start_time, end_time, sync_at) VALUES (%d, %d, %d, %d, %d, %d, %d)";
public static final String IMPORT_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, random_seed, start_time, end_time, sync_at) VALUES (%d, %d, %d, %d, %d, %s, %d)";
private static Long insertNewGame(User user, GameDifficulty difficulty, GameDefinition gameDefinition, TablexiaRandom random) {
......@@ -212,7 +212,9 @@ public class GameDAO {
try {
Long gameId = null;
Statement st = TablexiaStorage.getInstance().createStatement();
String sql = String.format(IMPORT_GAME_INSERT, user.getId(), difficulty, gameNumber, randomSeed, startTime, endTime, System.currentTimeMillis());
// workaround for sync error -> serialized JSON from server contains 0 instead of NULL
// String sql = String.format(IMPORT_GAME_INSERT, user.getId(), difficulty, gameNumber, randomSeed, startTime, endTime, System.currentTimeMillis());
String sql = String.format(IMPORT_GAME_INSERT, user.getId(), difficulty, gameNumber, randomSeed, startTime, endTime != 0 ? String.valueOf(endTime) : "NULL", System.currentTimeMillis());
st.executeUpdate(sql);
gameId = selectLastGameId();
st.close();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment