From f1377634b2606bc6b884a20e68cbe719159ccf1a Mon Sep 17 00:00:00 2001 From: Frederico Castro Date: Sat, 13 Dec 2025 17:22:50 -0300 Subject: [PATCH] Corrige insercao de JSON grande no Oracle usando CLOB --- backend/src/infrastructure/oracle/ranking_repository.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/infrastructure/oracle/ranking_repository.py b/backend/src/infrastructure/oracle/ranking_repository.py index 4aef226..2f66f57 100644 --- a/backend/src/infrastructure/oracle/ranking_repository.py +++ b/backend/src/infrastructure/oracle/ranking_repository.py @@ -15,6 +15,8 @@ class RankingOracleRepository: Insere ou atualiza um batch de consultores usando MERGE. Retorna o nĂºmero de registros processados. """ + import cx_Oracle + if not consultores: return 0 @@ -31,7 +33,7 @@ class RankingOracleRepository: :componente_d AS COMPONENTE_D, :ativo AS ATIVO, :anos_atuacao AS ANOS_ATUACAO, - :json_detalhes AS JSON_DETALHES + TO_CLOB(:json_detalhes) AS JSON_DETALHES FROM DUAL ) s ON (t.ID_PESSOA = s.ID_PESSOA) @@ -64,6 +66,8 @@ class RankingOracleRepository: cursor = conn.cursor() try: for consultor in consultores: + json_str = json.dumps(consultor.get("detalhes", {}), ensure_ascii=False) + cursor.setinputsizes(json_detalhes=cx_Oracle.CLOB) params = { "id_pessoa": consultor["id_pessoa"], "nome": consultor["nome"], @@ -74,7 +78,7 @@ class RankingOracleRepository: "componente_d": consultor["componente_d"], "ativo": "S" if consultor["ativo"] else "N", "anos_atuacao": consultor["anos_atuacao"], - "json_detalhes": json.dumps(consultor.get("detalhes", {}), ensure_ascii=False) + "json_detalhes": json_str } cursor.execute(merge_sql, params)