-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fixes: Advanced Search Filter failing for Custom Properties at Database Schema level #27320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5fad370
e1692b9
7a13c0f
b49cee7
741bb8b
93ed024
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,17 +18,19 @@ import { | |
| OldJsonTree, | ||
| Utils as QbUtils, | ||
| } from '@react-awesome-query-builder/antd'; | ||
| import { isEmpty, isEqual, isNil, isString } from 'lodash'; | ||
| import { isEmpty, isArray, isEqual, isNil, isString } from 'lodash'; | ||
| import Qs from 'qs'; | ||
| import { | ||
| createContext, | ||
| useCallback, | ||
| useContext, | ||
| useEffect, | ||
| useMemo, | ||
| useRef, | ||
| useState, | ||
| } from 'react'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import { EntityType } from '../../../enums/entity.enum'; | ||
| import { SearchIndex } from '../../../enums/search.enum'; | ||
| import useCustomLocation from '../../../hooks/useCustomLocation/useCustomLocation'; | ||
| import { TabsInfoData } from '../../../pages/ExplorePage/ExplorePage.interface'; | ||
|
|
@@ -88,10 +90,36 @@ export const AdvanceSearchProvider = ({ | |
| null | ||
| ); | ||
|
|
||
| // Tracks which effectiveEntityType was used to populate the customProps cache | ||
| // (e.g., "databaseSchema" when the user is on the Database Schema explore tab, | ||
| // or undefined when showing all entity types). The cache must be invalidated | ||
| // whenever users switch between explore tabs so that extension field paths are | ||
| // rebuilt for the new entity type context. | ||
| const customPropsEntityTypeRef = useRef<string | undefined>(undefined); | ||
|
|
||
| const [searchIndex, setSearchIndex] = useState< | ||
| SearchIndex | Array<SearchIndex> | ||
| >(getSearchIndexFromTabInfo(tabsInfo, tab)); | ||
|
|
||
| // When entityType is not explicitly provided, derive it from the current searchIndex | ||
| // so that custom property extension field paths do not include the entity type namespace | ||
| // prefix. The Elasticsearch `extension` field uses the `flattened` type and stores data | ||
| // WITHOUT the entity type prefix (e.g., key is "informationOwners.displayName", not | ||
| // "databaseSchema.informationOwners.displayName"), so omitting the prefix is required | ||
| // for queries to match actual documents. | ||
| const effectiveEntityType = useMemo(() => { | ||
| if (entityType) { | ||
| return entityType; | ||
| } | ||
| if (isArray(searchIndex)) { | ||
| return undefined; | ||
| } | ||
| const mapping = searchClassBase.getSearchIndexEntityTypeMapping(); | ||
| const mapped = mapping[searchIndex]; | ||
| // EntityType.ALL represents a multi-entity context — preserve namespace prefixes | ||
| return mapped && mapped !== EntityType.ALL ? mapped : undefined; | ||
| }, [entityType, searchIndex]); | ||
|
Comment on lines
+104
to
+121
|
||
|
|
||
| const changeSearchIndex = useCallback( | ||
| (index: SearchIndex | Array<SearchIndex>) => { | ||
| setIsUpdating(true); | ||
|
|
@@ -231,7 +259,7 @@ export const AdvanceSearchProvider = ({ | |
| resEntityType, | ||
| fields, | ||
| subfields, | ||
| entityType, | ||
| effectiveEntityType, | ||
| searchOutputType | ||
| ); | ||
| }); | ||
|
|
@@ -249,10 +277,18 @@ export const AdvanceSearchProvider = ({ | |
| isExplorePage, | ||
| }); | ||
|
|
||
| let extensionSubField = customProps; | ||
| // Use cached custom properties only if the effective entity type matches the | ||
| // context used to build the cache. When users switch explore tabs the entity | ||
| // type changes, so the cache must be refetched to rebuild extension field paths | ||
| // with the correct namespace context for the new entity type. | ||
| let extensionSubField = | ||
| customPropsEntityTypeRef.current === effectiveEntityType | ||
| ? customProps | ||
| : null; | ||
| if (extensionSubField === null) { | ||
| extensionSubField = await fetchCustomPropertyType(); | ||
| setCustomProps(extensionSubField); | ||
| customPropsEntityTypeRef.current = effectiveEntityType; | ||
|
Comment on lines
+284
to
+291
|
||
| } | ||
|
Comment on lines
288
to
292
|
||
|
|
||
| if ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
effectiveEntityTypereturnsundefinedfor any arraysearchIndex, even when the array contains a single index. In flows that pass a single selected entity as an array (e.g.,onChangeSearchIndex([SearchIndex.TABLE])), this keeps the old extension namespace behavior and can reintroduce the same custom-property query mismatch. Consider deriving the entity type whensearchIndexis an array of length 1 (and only treating it as multi-entity when length > 1).