Skip to content

Commit

Permalink
fix(search): check calculated columns at any depth (#310)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrice Bender <patrice.bender@sap.com>
  • Loading branch information
BobdenOs and patricebender authored Oct 20, 2023
1 parent 1c419b6 commit 8fd6153
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion db-service/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const getColumns = (
return columns
}

const _isColumnCalculated = (query, columnName) => {
if (!query) return false
if (query.SELECT?.columns?.find(col => col.xpr && col.as === columnName)) return true
return _isColumnCalculated(query._target?.query, columnName)
}

const _getSearchableColumns = entity => {
const columnsOptions = { removeIgnore: true, filterVirtual: true }
const columns = getColumns(entity, columnsOptions)
Expand Down Expand Up @@ -91,7 +97,7 @@ const _getSearchableColumns = entity => {
return (
annotatedColumnValue === undefined &&
column._type === DEFAULT_SEARCHABLE_TYPE &&
!entity?.query?.SELECT?.columns?.find(col => col.xpr && col.as === column.name)
!_isColumnCalculated(entity?.query, column.name)
)
})

Expand Down

0 comments on commit 8fd6153

Please sign in to comment.