Git Product home page Git Product logo

Comments (4)

superlee007 avatar superlee007 commented on September 18, 2024

xml里面有order by的话,你再使用动态拼order by肯定有问题,sqlserver那种情况是同一份代码吗?如果是的话应该是jsqlparser拿到sql把order by截掉了

from choerodon-starters.

superlee007 avatar superlee007 commented on September 18, 2024

关于mysql和oracle的情况,后面会加上sql校验的,如果你xml里面写的有默认order by再用doPageAndSort方法抛异常,而不是直接放到数据库里面跑sql错误

from choerodon-starters.

RavenCM avatar RavenCM commented on September 18, 2024

是同一份代码,jsqlparser没有截掉,保留了这个排序。我说一下我这边的问题吧。。。

  1. 首先是一个SQL,简单的SELECT ... FROM ... JOIN ... WHERE,并且指定了默认排序是一个ID字段,在MySQL中没有问题。迁移到SqlServer中之后,报错:Ambiguous column name 'xxx'.。我查看原因的时候发现是SqlServerParser中默认的这个排序字段没有带上表别名,但是查询列中的字段是带表别名的,所以他认为这两个列不同,将这个不带表别名的列自动添加到了查询列中,也就是issue #7

  2. 解决上一个问题的时候,我发现如果我在自己的SQL中指定一个ORDER BY字段,这个字段是带表别名的(也是默认排序字段,我没有尝试其他字段),那么最终就能够正常执行。默认的不带表别名的排序字段并没有生效

  3. 当我添加排序之后,又切换回到MySQL中的时候,又出现issue #9所说的问题,所以我希望能够实现的效果应该和SQL Server中一样,解析到又ORDER BY字段的时候,不要添加默认的排序列。

from choerodon-starters.

superlee007 avatar superlee007 commented on September 18, 2024

首先,如果你xml里面自定义的sql有order by了,就不能用doPageAndSort方法了。如果你要自己做动态order by ,在xml里写${column}然后传参传过去就行,然后你只用分页doPage方法就行了。你用doPageAndSort,这个方法会拿你xml的sql先拼order by然后在拼分页参数。你原始sql有order by肯定是报错的,目前没做处理就报sql错误,如果我这边加上判断,也是抛个exception,不让这么用的

from choerodon-starters.

Related Issues (13)

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.