Unverified Commit 4b80bab8 authored by scienceasdf's avatar scienceasdf Committed by GitHub

fix: rebuilding tree error when the page number is large enough in sqlite (#2830)

When the total page number is large enough (usually about 80+), sqlite will throw error: "Too many variables". This commit reduces the chunk size for sqlite configuration.
parent 52304a81
...@@ -57,8 +57,14 @@ module.exports = async (pageId) => { ...@@ -57,8 +57,14 @@ module.exports = async (pageId) => {
await WIKI.models.knex.table('pageTree').truncate() await WIKI.models.knex.table('pageTree').truncate()
if (tree.length > 0) { if (tree.length > 0) {
// -> Save in chunks, because of per query max parameters (35k Postgres, 2k MSSQL, 1k for SQLite) // -> Save in chunks, because of per query max parameters (35k Postgres, 2k MSSQL, 1k for SQLite)
for (const chunk of _.chunk(tree, 100)) { if ((WIKI.config.db.type !== 'sqlite'))
await WIKI.models.knex.table('pageTree').insert(chunk) for (const chunk of _.chunk(tree, 100)) {
await WIKI.models.knex.table('pageTree').insert(chunk)
}
} else {
for (const chunk of _.chunk(tree, 60)) {
await WIKI.models.knex.table('pageTree').insert(chunk)
}
} }
} }
......
Markdown is supported
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