Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: ORDER BY NULLS (FIRST | LAST) for SQLServer #10860

Open
1 of 18 tasks
awaismehmood88 opened this issue Apr 30, 2024 · 0 comments · May be fixed by #10861
Open
1 of 18 tasks

Bug: ORDER BY NULLS (FIRST | LAST) for SQLServer #10860

awaismehmood88 opened this issue Apr 30, 2024 · 0 comments · May be fixed by #10861

Comments

@awaismehmood88
Copy link

Issue description

Feature for order by nulls does't work for SQLServer

Expected Behavior

when using addOrderBy feature in query builder for SQLServer following query show in console, NULLS LAST does't work in SQLServer

SELECT "__root"."CountryCode" AS "__root_CountryCode", "__root"."Sequence" AS "__root_Sequence" FROM "Countries" "__root"
ORDER BY "__root"."Sequence" ASC NULLS LAST, "__root_CountryCode" ASC

Actual Behavior

QueryFailedError: Error: Invalid usage of the option NEXT in the FETCH statement.
at /code/src/driver/sqlserver/SqlServerQueryRunner.ts:261:30
at /code/node_modules/mssql/lib/base/request.js:440:25
at Request.userCallback (/code/node_modules/mssql/lib/tedious/request.js:492:15)
at Request.callback (/code/node_modules/tedious/src/request.ts:379:14)
at Parser.onEndOfMessage (/code/node_modules/tedious/src/connection.ts:3591:22)
at Object.onceWrapper (node:events:628:28)
at Parser.emit (node:events:514:28)
at Readable. (/code/node_modules/tedious/src/token/token-stream-parser.ts:30:12)
at Readable.emit (node:events:514:28)
at endReadableNT (node:internal/streams/readable:1589:12)

Steps to reproduce

  1. First createQueryBuilder
  2. Then add addOrderBy with 'NULLS LAST' | 'NULLS FIRST'

My Environment

Dependency Version
Operating System
Node.js version 20.10.0
Typescript version 5.2.2
TypeORM version 0.3.17

Additional Context

issue #685 already created and this feature added but not for SQLServer.
I'll create this feature for SQLServer

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant