Fix chat order comparison.

GitOrigin-RevId: bf16c396fd837410124b59ea97f2953dcefd0bbc
This commit is contained in:
levlam 2020-03-16 16:32:27 +03:00
parent 07d6f17f33
commit 7a649c23f1

View File

@ -75,7 +75,7 @@ Status init_dialog_db(SqliteDb &db, int32 version, bool &was_created) {
TRY_STATUS(db.exec("DROP INDEX IF EXISTS dialog_by_dialog_order")); TRY_STATUS(db.exec("DROP INDEX IF EXISTS dialog_by_dialog_order"));
TRY_STATUS(db.exec("ALTER TABLE dialogs ADD COLUMN folder_id INT4")); TRY_STATUS(db.exec("ALTER TABLE dialogs ADD COLUMN folder_id INT4"));
TRY_STATUS(add_dialogs_in_folder_index()); TRY_STATUS(add_dialogs_in_folder_index());
TRY_STATUS(db.exec("UPDATE dialogs SET folder_id = 0 WHERE dialog_id < -1500000000000 AND dialog_order != 0")); TRY_STATUS(db.exec("UPDATE dialogs SET folder_id = 0 WHERE dialog_id < -1500000000000 AND dialog_order > 0"));
} }
return Status::OK(); return Status::OK();
@ -129,7 +129,7 @@ class DialogDbImpl : public DialogDbSyncInterface {
TRY_RESULT_ASSIGN( TRY_RESULT_ASSIGN(
get_secret_chat_count_stmt_, get_secret_chat_count_stmt_,
db_.get_statement( db_.get_statement(
"SELECT COUNT(*) FROM dialogs WHERE folder_id = ?1 AND dialog_order != 0 AND dialog_id < -1500000000000")); "SELECT COUNT(*) FROM dialogs WHERE folder_id = ?1 AND dialog_order > 0 AND dialog_id < -1500000000000"));
// LOG(ERROR) << get_dialog_stmt_.explain().ok(); // LOG(ERROR) << get_dialog_stmt_.explain().ok();
// LOG(ERROR) << get_dialogs_stmt_.explain().ok(); // LOG(ERROR) << get_dialogs_stmt_.explain().ok();