Fix message_user_initiated

This commit is contained in:
Fedor Indutny 2021-12-21 22:49:40 +01:00 committed by GitHub
parent f5312b9463
commit 9d04daff5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 0 deletions

View file

@ -1263,4 +1263,33 @@ describe('SQL migrations test', () => {
);
});
});
describe('updateToSchemaVersion48', () => {
it('creates usable index for hasUserInitiatedMessages', () => {
updateToVersion(48);
const details = db
.prepare(
`
EXPLAIN QUERY PLAN
SELECT COUNT(*) as count FROM
(
SELECT 1 FROM messages
WHERE
conversationId = 'convo' AND
isUserInitiatedMessage = 1
LIMIT 1
);
`
)
.all()
.map(({ detail }) => detail)
.join('\n');
assert.include(
details,
'SEARCH messages USING INDEX message_user_initiated (conversationId=? AND isUserInitiatedMessage=?)'
);
});
});
});