Log prepared search statements
This commit is contained in:
parent
6d00906fc9
commit
b2321f26b7
1 changed files with 12 additions and 2 deletions
14
script.js
14
script.js
|
@ -925,9 +925,14 @@
|
||||||
listState.showLoading('Searching…');
|
listState.showLoading('Searching…');
|
||||||
|
|
||||||
const offset = (state.page - 1) * state.pageSize;
|
const offset = (state.page - 1) * state.pageSize;
|
||||||
|
const effectiveSearchSql = searchSql[state.sort] || searchSql.rank;
|
||||||
let total = 0;
|
let total = 0;
|
||||||
let rows = [];
|
let rows = [];
|
||||||
try {
|
try {
|
||||||
|
console.debug('[Search] Preparing count query', {
|
||||||
|
sql: countSql.trim(),
|
||||||
|
params: [term],
|
||||||
|
});
|
||||||
const countStmt = db.prepare(countSql);
|
const countStmt = db.prepare(countSql);
|
||||||
countStmt.bind([term]);
|
countStmt.bind([term]);
|
||||||
if (countStmt.step()) {
|
if (countStmt.step()) {
|
||||||
|
@ -946,8 +951,13 @@
|
||||||
state.page = Math.max(1, Math.ceil(total / state.pageSize));
|
state.page = Math.max(1, Math.ceil(total / state.pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchStmt = db.prepare(searchSql[state.sort] || searchSql.rank);
|
const searchParams = [term, state.pageSize, (state.page - 1) * state.pageSize];
|
||||||
searchStmt.bind([term, state.pageSize, (state.page - 1) * state.pageSize]);
|
console.debug('[Search] Preparing row query', {
|
||||||
|
sql: effectiveSearchSql.trim(),
|
||||||
|
params: searchParams,
|
||||||
|
});
|
||||||
|
const searchStmt = db.prepare(effectiveSearchSql);
|
||||||
|
searchStmt.bind(searchParams);
|
||||||
const nextRows = [];
|
const nextRows = [];
|
||||||
while (searchStmt.step()) {
|
while (searchStmt.step()) {
|
||||||
nextRows.push(searchStmt.getAsObject());
|
nextRows.push(searchStmt.getAsObject());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue