Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (let i = orderByExpressionsAndDirections.length - 1; i >= 0; i--) {
const [sqlExpression, ascending] = orderByExpressionsAndDirections[i];
// If ascending and isAfter then >
// If ascending and isBefore then <
const comparison =
Number(ascending) ^ Number(!isAfter)
? sql.fragment`>`
: sql.fragment`<`;
const sqlOldFilter = sqlFilter;
sqlFilter = sql.fragment`\
(\
(${sqlExpression} ${comparison} ${sqlCursors[i] || sql.null})
OR\
(\
${sqlExpression} = ${sqlCursors[i] || sql.null}\
AND\
${sqlOldFilter}\
)\
)`;
}
// Check the cursor prefixes apply
// TODO:v5: we should be able to do this in JS-land rather than SQL-land
sqlFilter = sql.fragment`(((${sql.join(
getPgCursorPrefix(),
", "
)}) = (${sql.join(
rawPrefixes.map(val => sql.value(val)),
", "
)})) AND (${sqlFilter}))`;
queryBuilder.whereBound(sqlFilter, isAfter);
}
let sqlFilter = sql.fragment`false`;
const sqlCursors = rawCursors.map(val => sql.value(val));
for (let i = orderByExpressionsAndDirections.length - 1; i >= 0; i--) {
const [sqlExpression, ascending] = orderByExpressionsAndDirections[i];
// If ascending and isAfter then >
// If ascending and isBefore then <
const comparison =
Number(ascending) ^ Number(!isAfter)
? sql.fragment`>`
: sql.fragment`<`;
const sqlOldFilter = sqlFilter;
sqlFilter = sql.fragment`\
(\
(${sqlExpression} ${comparison} ${sqlCursors[i] || sql.null})
OR\
(\
${sqlExpression} = ${sqlCursors[i] || sql.null}\
AND\
${sqlOldFilter}\
)\
)`;
}
// Check the cursor prefixes apply
// TODO:v5: we should be able to do this in JS-land rather than SQL-land
sqlFilter = sql.fragment`(((${sql.join(
getPgCursorPrefix(),
", "
)}) = (${sql.join(
rawPrefixes.map(val => sql.value(val)),