File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
apps/nestjs-backend/src/features/record/query-builder Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -1370,9 +1370,20 @@ export class SelectColumnSqlConversionVisitor extends BaseSqlConversionVisitor<I
13701370 }
13711371
13721372 if ( selectionSql ) {
1373+ const normalizedSelection = this . normalizeLookupSelection (
1374+ selectionSql ,
1375+ fieldInfo ,
1376+ selectContext
1377+ ) ;
1378+
1379+ if ( normalizedSelection !== selectionSql ) {
1380+ return normalizedSelection ;
1381+ }
1382+
13731383 if ( preferRaw ) {
13741384 return this . coerceRawMultiValueReference ( selectionSql , fieldInfo , selectContext ) ;
13751385 }
1386+
13761387 return selectionSql ;
13771388 }
13781389 // Use table alias if provided in context
@@ -1389,6 +1400,49 @@ export class SelectColumnSqlConversionVisitor extends BaseSqlConversionVisitor<I
13891400 : fallbackExpr ;
13901401 }
13911402
1403+ private normalizeLookupSelection (
1404+ expr : string ,
1405+ fieldInfo : FieldCore ,
1406+ selectContext : ISelectFormulaConversionContext
1407+ ) : string {
1408+ if ( ! expr ) {
1409+ return expr ;
1410+ }
1411+
1412+ const dialect = this . dialect ;
1413+ if ( ! dialect ) {
1414+ return expr ;
1415+ }
1416+
1417+ if (
1418+ ! fieldInfo . isLookup ||
1419+ ! fieldInfo . lookupOptions ||
1420+ ! isLinkLookupOptions ( fieldInfo . lookupOptions )
1421+ ) {
1422+ return expr ;
1423+ }
1424+
1425+ const preferRaw = ! ! selectContext . preferRawFieldReferences ;
1426+ if ( preferRaw && selectContext . targetDbFieldType === DbFieldType . Json ) {
1427+ return expr ;
1428+ }
1429+
1430+ const trimmed = expr . trim ( ) ;
1431+ if ( ! trimmed || trimmed . toUpperCase ( ) === 'NULL' ) {
1432+ return expr ;
1433+ }
1434+
1435+ if ( fieldInfo . dbFieldType !== DbFieldType . Json ) {
1436+ return expr ;
1437+ }
1438+
1439+ const titlesExpr = dialect . linkExtractTitles ( expr , ! ! fieldInfo . isMultipleCellValue ) ;
1440+ if ( fieldInfo . isMultipleCellValue ) {
1441+ return dialect . formatStringArray ( titlesExpr ) ;
1442+ }
1443+ return titlesExpr ;
1444+ }
1445+
13921446 private coerceRawMultiValueReference (
13931447 expr : string ,
13941448 fieldInfo : FieldCore ,
You can’t perform that action at this time.
0 commit comments