From faf34724e2a5744bdee16c853e047ee3c910aec9 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Thu, 4 Apr 2019 11:02:32 +0200 Subject: [PATCH] Limpa caracteres nulos de campos string --- sapl/legacy/migracao_dados.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sapl/legacy/migracao_dados.py b/sapl/legacy/migracao_dados.py index 4906263eb..654dc596c 100644 --- a/sapl/legacy/migracao_dados.py +++ b/sapl/legacy/migracao_dados.py @@ -839,13 +839,13 @@ def populate_renamed_fields(new, old): else: value = getattr(old, old_field_name) - if field_type in ['CharField', 'TextField']: - if value in [None, 'None']: + if field_type in ('CharField', 'TextField'): + if value in (None, 'None'): value = '' - else: + elif isinstance(value, str): # retira caracters nulos que o postgres não aceita # quando usamos bulk_create - value = value.strip('\0') + value = value.replace('\0', '') # ajusta tempos segundo timezone # os campos TIMESTAMP do mysql são gravados em UTC