1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Better handling of settings

This commit is contained in:
Laurent Cozic
2017-07-25 22:55:26 +01:00
parent ce6ca38fa0
commit 81d4810018
5 changed files with 75 additions and 40 deletions

View File

@@ -230,8 +230,6 @@ class Database {
s.push('`' + n + '`=?');
}
where = s.join(' AND ');
// params.push(where.id);
// where = 'id=?';
}
return {
@@ -239,6 +237,23 @@ class Database {
params: params,
};
}
alterColumnQueries(tableName, fieldsAfter) {
let sql = `
CREATE TEMPORARY TABLE _BACKUP_TABLE_NAME_(_FIELDS_AFTER_);
INSERT INTO _BACKUP_TABLE_NAME_ SELECT _FIELDS_AFTER_ FROM _TABLE_NAME_;
DROP TABLE _TABLE_NAME_;
CREATE TABLE _TABLE_NAME_(_FIELDS_AFTER_);
INSERT INTO _TABLE_NAME_ SELECT _FIELDS_AFTER_ FROM _BACKUP_TABLE_NAME_;
DROP TABLE _BACKUP_TABLE_NAME_;
`;
sql = sql.replace(/_BACKUP_TABLE_NAME_/g, this.escapeField(tableName + '_backup'));
sql = sql.replace(/_TABLE_NAME_/g, this.escapeField(tableName));
sql = sql.replace(/_FIELDS_AFTER_/g, this.escapeFields(fieldsAfter).join(','));
return sql.trim().split("\n");
}
wrapQueries(queries) {
let output = [];