@@ -96,11 +96,13 @@ def _extract_type_name(full_type: str) -> str:
9696 full_type: Fully-qualified type string (e.g., "Namespace.Type")
9797
9898 Returns:
99- Just the type name portion
99+ Just the type name portion (without brackets)
100100 """
101101 if not full_type :
102102 return ""
103103
104+ result : str
105+
104106 # Handle bracket-quoted identifiers: "[Schema].[Type]" or "Namespace.[Type]"
105107 # Split on dots that are NOT inside brackets
106108 # Strategy: find the last segment, which may be bracket-quoted
@@ -110,7 +112,11 @@ def _extract_type_name(full_type: str) -> str:
110112 if last_bracket > 0 :
111113 # Check if there's a dot before the bracket
112114 if full_type [last_bracket - 1 ] == "." :
113- return full_type [last_bracket :]
115+ result = full_type [last_bracket :]
116+ # Strip surrounding brackets if present
117+ if result .startswith ("[" ) and result .endswith ("]" ):
118+ return result [1 :- 1 ]
119+ return result
114120 # If the whole thing starts with '[', it might be the full type name
115121 if full_type .startswith ("[" ):
116122 # Look for pattern like "[Schema].[Type]" - return last bracketed segment
@@ -133,7 +139,11 @@ def _extract_type_name(full_type: str) -> str:
133139 if current :
134140 parts .append (current )
135141 if parts :
136- return parts [- 1 ]
142+ result = parts [- 1 ]
143+ # Strip surrounding brackets if present
144+ if result .startswith ("[" ) and result .endswith ("]" ):
145+ return result [1 :- 1 ]
146+ return result
137147
138148 # Standard case: "Namespace.TypeName" -> "TypeName"
139149 return full_type .split ("." )[- 1 ]
@@ -437,6 +447,9 @@ def get_entity_properties(
437447 def _find_entity_type (self , type_name : str ) -> Optional [Dict [str , Any ]]:
438448 """Find EntityType by name with case-insensitive fallback.
439449
450+ Also handles bracket-quoted names where the type might be stored with
451+ a full name like '[Schema].[Type]' but we're searching for 'Type'.
452+
440453 Args:
441454 type_name: Name of the EntityType to find
442455
@@ -457,7 +470,19 @@ def _find_entity_type(self, type_name: str) -> Optional[Dict[str, Any]]:
457470 ),
458471 None ,
459472 )
460- return entity_type
473+ if entity_type :
474+ return entity_type
475+
476+ # Try matching against extracted type names (for bracket-quoted full names)
477+ # e.g., type_name='METADATA' should match stored name='[APICUST].[METADATA]'
478+ for name , et in self .schema ["entity_types" ].items ():
479+ extracted_name = self ._extract_type_name (name )
480+ if extracted_name == type_name :
481+ return et
482+ if extracted_name .lower () == type_name .lower ():
483+ return et
484+
485+ return None
461486
462487 def get_navigation_properties (self , entity_set_name : str ) -> List [str ]:
463488 """Return list of navigation property names for an EntitySet.
0 commit comments