Giter Club home page Giter Club logo

Comments (5)

j4mie avatar j4mie commented on September 28, 2024

Hi,

Thanks for the patch - I need to do a bit of research into how portable this is, as hardcoding a value like that seems a bit odd...

Jamie

from idiorm.

vifo avatar vifo commented on September 28, 2024

Hi j4mie,

yes, it also looked a bit odd to me, but since there's no way in standard SQL to ommit LIMIT, when also OFFSET is given, specifiying a LIMIT of 2^64 -1 == 18446744073709551615 (e.g. max value for an unsigned 64-bit integer, ULLONG_MAX from limits.h) seems to be the widely accepted solution (at least in MySQL - it is also shown in MySQL examples).

Postgres, however supports a LIMIT ALL.

Edit: Just checked the PHP docs; there does not seem to be a define for this value. Workaround:

define(ULLONG_MAX, '18446744073709551615');

from idiorm.

j4mie avatar j4mie commented on September 28, 2024

It's the portability that worries me. I can't add MySQL-only code to Idiorm, and adding "special cases" for every database is something I'm trying to avoid wherever possible

I'm actually struggling to see exactly why this is needed. Can't you just ensure that limit() is always called when offset() is called in your code? It feels like magically adding a limit to a query would be non-intuitive and surprising to a user.

from idiorm.

vifo avatar vifo commented on September 28, 2024

Hi j4mie,

actually, I agree with your concerns about portability. I can of course ensure, that I'll use limit() always, whenever I also use offset().

Apart from this LIMIT/OFFSET is supported by Postgres, MySQL and SQLite only (as far as I can tell - and LIMIT may be omitted only in Postgres). MSSQL / Oracle do not support it (yet) at all, so paging and limiting must be done there with other statements anyway. For the three mentioned, the above solution is fairly portable and commonly used (and you wouldn't have to distinguish between the underlying RDBMs).

Greetings
ViFo

from idiorm.

treffynnon avatar treffynnon commented on September 28, 2024

This should be controlled by the application and not at the ORM level in my opinion and I don't like having a hard coded value in the ORM like this.

from idiorm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.