question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allowing raw limits

See original GitHub issue

Environment

Knex version: 0.95.11 Database + version: Materialize 0.9.10 (based on Postgres) OS: Ubuntu 20

Feature discussion / request

  1. Explain what is your use case

Materialize (https://github.com/MaterializeInc/materialize) doesn’t allow prepared values for LIMIT. As far as I can tell, Knex always makes the LIMIT value a prepared value. The only way to hardcode it in the query is something like:

knex('foo')
  .orderByRaw(`1 limit ${limit}`);

Would it be possible to have a raw limit value?

  1. Explain what kind of feature would support this

Allow .limit(raw(10)).

  1. Give some API proposal, how the feature should work

Make .limit() accept raw() or add .limitRaw()

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
OlivierCavadenticommented, Nov 6, 2021

@Linksku I made a PR where you can make this two syntaxes :

knex('foo')
  .orderBy('1')
  .limit(1, { skipBinding: true })
  .offset(2, { skipBinding: true });

or shorter:

knex('foo')
  .orderBy('1')
  .limit(1, true)
  .offset(2, true);

Feel free to post comments on the PR

0reactions
sebastianoblomcommented, Sep 19, 2022

I ran into this problem today. SphinxQL, which is a dialect for SphinxSearch ( fulltext search server - http://sphinxsearch.com/ ) uses for format offset, limit instead of limit 1 offset 2 when using limits.

The only way I have found using knex qb around this problem is to append raw sql to the raw query-string. Like so;

let query = sphinx
  .select(['id'])
  .from('myIndex')
  .orderBy([{ column: 'createdAt', order: 'desc' }])
  .boundingBox({ ne, sw })
  .match(text)
  
  // append offset, limit shorthand style as sphinx does not support offset ${offset}
  const result = await sphinx.raw(`${query.toQuery()} limit ${offset}, ${limit};SHOW META;`)

The ability to extend the qb with something like limitRaw(offset, limit) => ´${offset}, ${limit}´ would really help, but seems not possible with current restrictions. Or am I missing something or any other ideas?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rate limits on raw endpoints - GitLab Docs
This setting defaults to 300 requests per minute, and allows you to rate limit the requests to raw endpoints: On the top bar,...
Read more >
My Photo Stream and Shared Albums limits - Apple Support
iCloud limits the number of photos that can be uploaded to My Photo ... Images for My Photo Stream: JPEG, TIFF, PNG, and...
Read more >
Rate limits on raw endpoints · Settings · Admin area - ETSI Forge
This setting defaults to 300 requests per minute, and allows you to rate limit the requests to raw endpoints: On the top bar,...
Read more >
State-by-State Raw Milk Laws - Milk - ProCon.org
Sales of raw milk are legal with a permit and only on the farm directly to the consumer who may not resell the...
Read more >
raw forest products permit conditions (rs)
Maximum GVW permit weight 98,000 lbs. RS PERMIT CONDITION SHEET. RAW FOREST PRODUCTS @ 98,000 Pounds on 6 or more axles ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found