From 356025200317ce7718ac4a312bd132de9b97d5a9 Mon Sep 17 00:00:00 2001 From: Olivier Cavadenti Date: Mon, 8 Nov 2021 12:28:34 +0100 Subject: [PATCH] Add skipBinding option for offset and limit (#356) --- sections/builder.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/sections/builder.js b/sections/builder.js index 7097d5bf..a634b688 100644 --- a/sections/builder.js +++ b/sections/builder.js @@ -1568,28 +1568,54 @@ export default [ { type: "method", method: "offset", - example: ".offset(value)", - description: "Adds an offset clause to the query.", + example: ".offset(value, options={skipBinding: boolean})", + description: "Adds an offset clause to the query. An optional skipBinding parameter may be specified which would avoid setting offset as a prepared value (some databases don't allow prepared values for offset).", children: [ { type: "runnable", content: ` knex.select('*').from('users').offset(10) ` + }, + { + type: "runnable", + content: ` + knex.select('*').from('users').offset(10).toSQL().sql + ` + }, + { + type: "runnable", + content: ` + // Offset value isn't a prepared value. + knex.select('*').from('users').offset(10, {skipBinding: true}).toSQL().sql + ` } ] }, { type: "method", method: "limit", - example: ".limit(value)", - description: "Adds a limit clause to the query.", + example: ".limit(value, options={skipBinding: boolean})", + description: "Adds a limit clause to the query. An optional skipBinding parameter may be specified to avoid adding limit as a prepared value (some databases don't allow prepared values for limit).", children: [ { type: "runnable", content: ` knex.select('*').from('users').limit(10).offset(30) ` + }, + { + type: "runnable", + content: ` + knex.select('*').from('users').limit(10).offset(30).toSQL().sql + ` + }, + { + type: "runnable", + content: ` + // Limit value isn't a prepared value. + knex.select('*').from('users').limit(10, {skipBinding: true}).offset(30).toSQL().sql + ` } ] },