import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
import androidx.lifecycle.MutableLiveData;
public class MobileLedgerDatabase extends SQLiteOpenHelper {
public static final MutableLiveData<Boolean> initComplete = new MutableLiveData<>(false);
public static final String DB_NAME = "MoLe.db";
- private static final int LATEST_REVISION = 55;
+ private static final int LATEST_REVISION = 58;
private static final String CREATE_DB_SQL = "create_db";
private final Application mContext;
InputStreamReader isr = new InputStreamReader(res);
BufferedReader reader = new BufferedReader(isr);
- Pattern continuation = Pattern.compile("\\\\\\s*$");
+ Pattern endOfStatement = Pattern.compile(";\\s*(?:--.*)?$");
String line;
String sqlStatement = null;
- boolean eolPending;
int lineNo = 0;
while ((line = reader.readLine()) != null) {
lineNo++;
if (line.isEmpty())
continue;
- Matcher m = continuation.matcher(line);
- eolPending = false;
- if (m.find()) {
- line = m.replaceFirst("");
- eolPending = true;
- }
-
if (sqlStatement == null)
sqlStatement = line;
else
sqlStatement = sqlStatement.concat(line);
- if (eolPending)
+ Matcher m = endOfStatement.matcher(line);
+ if (!m.find())
continue;
try {
}
if (sqlStatement != null)
- throw new RuntimeException(
- String.format("Error applying %s: EOF after continuation", revFile));
+ throw new RuntimeException(String.format(
+ "Error applying %s: EOF after continuation. Line %s, Incomplete " +
+ "statement: %s", revFile, lineNo, sqlStatement));
}
catch (IOException e) {