@@ -1184,25 +1184,32 @@ class ApiGateway {
11841184 const startTime = new Date ( ) . getTime ( ) ;
11851185 const compilerApi = await this . getCompilerApi ( context ) ;
11861186
1187- const normalizedQueriesPreRewrite : NormalizedQuery [ ] = queries . map ( ( currentQuery ) => remapToQueryAdapterFormat ( normalizeQuery ( currentQuery , persistent ) ) ) ;
1188-
1189- let normalizedQueries : NormalizedQuery [ ] = await Promise . all (
1190- queries . map (
1191- async ( currentQuery ) => {
1192- const hasExpressionsInQuery =
1193- this . hasExpressionsInQuery ( currentQuery ) ;
1194-
1195- if ( hasExpressionsInQuery ) {
1196- if ( ! memberExpressions ) {
1197- throw new Error ( 'Expressions are not allowed in this context' ) ;
1198- }
1187+ const queryNormalizationResult : Array < {
1188+ query : Query ,
1189+ normalizedQuery : NormalizedQuery ,
1190+ hasExpressionsInQuery : boolean
1191+ } > = queries . map ( ( currentQuery ) => {
1192+ const hasExpressionsInQuery = this . hasExpressionsInQuery ( currentQuery ) ;
1193+
1194+ if ( hasExpressionsInQuery ) {
1195+ if ( ! memberExpressions ) {
1196+ throw new Error ( 'Expressions are not allowed in this context' ) ;
1197+ }
11991198
1200- currentQuery = this . parseMemberExpressionsInQuery ( currentQuery ) ;
1201- }
1199+ currentQuery = this . parseMemberExpressionsInQuery ( currentQuery ) ;
1200+ }
12021201
1203- const normalizedQuery = normalizeQuery ( currentQuery , persistent ) ;
1202+ return {
1203+ query : currentQuery ,
1204+ normalizedQuery : ( normalizeQuery ( currentQuery , persistent ) ) ,
1205+ hasExpressionsInQuery
1206+ } ;
1207+ } ) ;
12041208
1205- let evaluatedQuery = normalizedQuery ;
1209+ let normalizedQueries : NormalizedQuery [ ] = await Promise . all (
1210+ queryNormalizationResult . map (
1211+ async ( { query : currentQuery , normalizedQuery, hasExpressionsInQuery } ) => {
1212+ let evaluatedQuery = currentQuery ;
12061213
12071214 if ( hasExpressionsInQuery ) {
12081215 // We need to parse/eval all member expressions early as applyRowLevelSecurity
@@ -1260,7 +1267,7 @@ class ApiGateway {
12601267 }
12611268 }
12621269
1263- return [ queryType , normalizedQueries , normalizedQueriesPreRewrite ] ;
1270+ return [ queryType , normalizedQueries , queryNormalizationResult . map ( ( it ) => remapToQueryAdapterFormat ( it . normalizedQuery ) ) ] ;
12641271 }
12651272
12661273 public async sql ( {
0 commit comments