Code Monkey home page Code Monkey logo

Comments (1)

iTanken avatar iTanken commented on May 29, 2024

注释到这几句就正常了, 没看明白这几行是用于什么场景的

用来在分页查询时如果没有指定排序方式的话使用主键作为默认排序方式。

在 Oracle 数据库中,如果你使用 OFFSET 进行分页查询,通常建议在查询中显式指定排序方式,尤其是在使用 OFFSETFETCH NEXT 进行分页时。

原因是,OFFSETFETCH NEXT 语法是和排序相关的,如果没有明确指定排序方式,查询结果的顺序可能是不确定的。在分页查询中,不确定的顺序可能导致在不同页之间的重复或遗漏的数据。

示例:

SELECT *
FROM your_table
ORDER BY your_column
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;

在上面的示例中,ORDER BY your_column 明确指定了排序方式,确保在进行分页查询时结果是可预测的。如果你省略了 ORDER BY 子句,查询结果的顺序可能会随数据库的实现而变化,可能不符合你的预期。

因此,为了确保分页查询的结果是有序的,建议在使用 OFFSETFETCH NEXT 进行分页时,总是显式指定排序方式。

明白了这个的作用了,但是为什么count函数会进到这里面来,count应该不需要排序, gorm/gen 的count,应该用的也是gorm的count函数。而且我有leftjoin,生成的语句没有 tablename前缀,所以不知道是哪张表的id

Originally posted by @SheltonZhu in #11 (comment)

@SheltonZhu 感谢反馈,问题已修复,详情请查看 v1.5.20

from gorm-oracle.

Related Issues (12)

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.