diff --git a/CHANGELOG.md b/CHANGELOG.md index e582465aa..c70d22f37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed the "too many bind variables in prepared statement" issue of the data range functionality (`getRange()`) in the market data service + ## 2.23.0 - 2023-11-15 ### Added diff --git a/apps/api/src/services/market-data/market-data.service.ts b/apps/api/src/services/market-data/market-data.service.ts index 01f8bb9aa..05172dfe1 100644 --- a/apps/api/src/services/market-data/market-data.service.ts +++ b/apps/api/src/services/market-data/market-data.service.ts @@ -64,7 +64,7 @@ export class MarketDataService { dateQuery: DateQuery; uniqueAssets: UniqueAsset[]; }): Promise { - return await this.prismaService.marketData.findMany({ + return this.prismaService.marketData.findMany({ orderBy: [ { date: 'asc' @@ -74,17 +74,17 @@ export class MarketDataService { } ], where: { - OR: uniqueAssets.map(({ dataSource, symbol }) => { - return { - AND: [ - { - dataSource, - symbol, - date: dateQuery - } - ] - }; - }) + dataSource: { + in: uniqueAssets.map(({ dataSource }) => { + return dataSource; + }) + }, + date: dateQuery, + symbol: { + in: uniqueAssets.map(({ symbol }) => { + return symbol; + }) + } } }); }