| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
- html
- python
- NPM
- V8
- Express
- Certbot
- 파이썬
- Generics
- Schema Registry
- https
- nodeJS
- MSA
- node.js
- Functional Programming
- Let's Encrypt
- javascript
- 함수형프로그래밍
- MSK
- 알고리즘
- 비주얼 스튜디오 코드
- docker
- 자료구조
- Linux
- typescript
- GIT
- nestjs
- vscode
- stream
- ChatGPT
- ES6
- Today
- Total
JangBaGeum.gif
[이슈해결] QueryFailedError: Error: Invalid usage of the option NEXT in the FETCH statement. 본문
[이슈해결] QueryFailedError: Error: Invalid usage of the option NEXT in the FETCH statement.
장바금 2023. 6. 6. 14:17TypeORM을 이용해서 SQL Server 2008 DB에 연결해 데이터를 가져오는 과정에서 문제가 생겼다.
QueryFailedError: Error: Invalid usage of the option NEXT in the FETCH statement.
SQL Server 2008 버전은 MS에서도 서비스를 종료했지만 작업 진행 중인 장비 특성상 DB의 버전을 변경할 수 없는 처지여서 원인을 찾고 해결해 보기로 했다.
SQL Server 2008 버전은 너무 구버전이어서 MS 홈페이지에서도 매뉴얼을 찾을 수 없다.
관련 내용을 찾아보니 OFFSET/FETCH 구문이 SQL Server 2011 버전 이후에 도입된 듯하다. 아래 링크는 관련 이슈 내용이다.
https://github.com/typeorm/typeorm/issues/4038
Why use findOne to report errors · Issue #4038 · typeorm/typeorm
**Issue type:** [ ] question Database system/driver: [ 4.0.4] mssql TypeORM version: [ ] latest Steps to reproduce or a small repository showing the problem: I use SQL Server 2008 r2 database, find...
github.com
특히 FETCH 구문은 TypeORM의 findOne(), findOneOrFail() 함수에서 사용이 되는데, 이 것이 문제의 원인이 되었다.
그러서 나는 간단하게 findOne(), findOneOrFail() 함수를 사용하지 않고 모두 find()로 수정하여 해결을 하였다.