Debug
This commit is contained in:
parent
81a1c04934
commit
fe7bb3545f
1 changed files with 11 additions and 8 deletions
|
|
@ -13,18 +13,24 @@ def is_ignored(name: str) -> bool:
|
||||||
"""Verifica se o nome contém a substring de filtro (case-insensitive)."""
|
"""Verifica se o nome contém a substring de filtro (case-insensitive)."""
|
||||||
if name is None:
|
if name is None:
|
||||||
return False
|
return False
|
||||||
|
# Garante que a comparação é feita em caixa alta para robustez
|
||||||
return FILTER_SUBSTRING in str(name).upper()
|
return FILTER_SUBSTRING in str(name).upper()
|
||||||
|
|
||||||
# --- FUNÇÃO HELPER PARA REMOÇÃO DE SOURCE_CODE ---
|
# --- FUNÇÃO HELPER PARA REMOÇÃO DE SOURCE_CODE (CORRIGIDA PARA CASE-INSENSITIVE) ---
|
||||||
|
|
||||||
def _remove_source_code(item: Dict) -> Dict:
|
def _remove_source_code(item: Dict) -> Dict:
|
||||||
"""
|
"""
|
||||||
Remove o campo 'SOURCE_CODE' de um item de dicionário.
|
Remove o campo 'SOURCE_CODE' ou 'source_code' de um item de dicionário.
|
||||||
Usado para garantir que o código-fonte nunca seja retornado/comparado.
|
|
||||||
"""
|
"""
|
||||||
item_copy = item.copy()
|
item_copy = item.copy()
|
||||||
|
|
||||||
|
# Verifica as chaves comuns (maioria dos bancos retorna em maiúsculas, mas o JSON pode ter minúsculas)
|
||||||
if 'SOURCE_CODE' in item_copy:
|
if 'SOURCE_CODE' in item_copy:
|
||||||
del item_copy['SOURCE_CODE']
|
del item_copy['SOURCE_CODE']
|
||||||
|
|
||||||
|
if 'source_code' in item_copy: # Tratamento para o caso reportado (minúsculas)
|
||||||
|
del item_copy['source_code']
|
||||||
|
|
||||||
return item_copy
|
return item_copy
|
||||||
|
|
||||||
# --- FUNÇÃO AUXILIAR PARA COMPARAÇÃO DE CAMPOS ---
|
# --- FUNÇÃO AUXILIAR PARA COMPARAÇÃO DE CAMPOS ---
|
||||||
|
|
@ -204,7 +210,6 @@ def compare_structures(standard_structure: Dict[str, Any], client_structure: Dic
|
||||||
client_elements_filtered.append(item)
|
client_elements_filtered.append(item)
|
||||||
|
|
||||||
# Criação de Sets a partir dos elementos normalizados (sem SOURCE_CODE)
|
# Criação de Sets a partir dos elementos normalizados (sem SOURCE_CODE)
|
||||||
# Usamos _remove_source_code para a comparação (como "normalizer")
|
|
||||||
standard_elements_normalized = [_remove_source_code(item) for item in standard_elements_filtered]
|
standard_elements_normalized = [_remove_source_code(item) for item in standard_elements_filtered]
|
||||||
client_elements_normalized = [_remove_source_code(item) for item in client_elements_filtered]
|
client_elements_normalized = [_remove_source_code(item) for item in client_elements_filtered]
|
||||||
|
|
||||||
|
|
@ -238,7 +243,6 @@ def compare_structures(standard_structure: Dict[str, Any], client_structure: Dic
|
||||||
|
|
||||||
class ShowDatabaseService:
|
class ShowDatabaseService:
|
||||||
|
|
||||||
# Novo Helper: Função dedicada para limpar a estrutura completa de debug antes do retorno
|
|
||||||
def _clean_full_structure_for_output(self, structure: Dict[str, Any]) -> Dict[str, Any]:
|
def _clean_full_structure_for_output(self, structure: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
"""Cria uma cópia limpa da estrutura, removendo 'SOURCE_CODE' em todos os elementos relevantes."""
|
"""Cria uma cópia limpa da estrutura, removendo 'SOURCE_CODE' em todos os elementos relevantes."""
|
||||||
# Garante deep copy de toda a estrutura
|
# Garante deep copy de toda a estrutura
|
||||||
|
|
@ -251,8 +255,7 @@ class ShowDatabaseService:
|
||||||
# Aplica a limpeza a cada item da lista usando a função helper _remove_source_code
|
# Aplica a limpeza a cada item da lista usando a função helper _remove_source_code
|
||||||
cleaned[key] = [_remove_source_code(item) for item in cleaned[key]]
|
cleaned[key] = [_remove_source_code(item) for item in cleaned[key]]
|
||||||
|
|
||||||
# Garante que, se houver campos (FIELDS) aninhados, eles também sejam limpos (apesar de SOURCE_CODE
|
# Garante que, se houver campos (FIELDS) aninhados, eles também sejam limpos
|
||||||
# não ser comum em FIELDS, é uma camada extra de segurança)
|
|
||||||
if 'tables' in cleaned and isinstance(cleaned['tables'], list):
|
if 'tables' in cleaned and isinstance(cleaned['tables'], list):
|
||||||
for table in cleaned['tables']:
|
for table in cleaned['tables']:
|
||||||
if 'FIELDS' in table and isinstance(table['FIELDS'], list):
|
if 'FIELDS' in table and isinstance(table['FIELDS'], list):
|
||||||
|
|
@ -286,7 +289,7 @@ class ShowDatabaseService:
|
||||||
client_structure
|
client_structure
|
||||||
)
|
)
|
||||||
|
|
||||||
# Filtra SOURCE_CODE das estruturas de DEBUG usando o novo helper
|
# Filtra SOURCE_CODE das estruturas de DEBUG antes de retornar
|
||||||
debug_cliente = self._clean_full_structure_for_output(client_structure)
|
debug_cliente = self._clean_full_structure_for_output(client_structure)
|
||||||
debug_padrao = self._clean_full_structure_for_output(standard_structure_data)
|
debug_padrao = self._clean_full_structure_for_output(standard_structure_data)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue