From 11ae2717e6f9c9a86aff6007b94247105f8408d7 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Wed, 3 Apr 2019 16:13:15 -0300 Subject: [PATCH] Limpa caracters nulos de strings --- sapl/legacy/migracao_dados.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sapl/legacy/migracao_dados.py b/sapl/legacy/migracao_dados.py index b3d6063cb..4906263eb 100644 --- a/sapl/legacy/migracao_dados.py +++ b/sapl/legacy/migracao_dados.py @@ -52,7 +52,6 @@ from sapl.utils import normalize from .scripts.normaliza_dump_mysql import normaliza_dump_mysql - # BASE ###################################################################### # apps to be migrated, in app dependency order (very important) appconfs = [apps.get_app_config(n) for n in [ @@ -840,9 +839,13 @@ def populate_renamed_fields(new, old): else: value = getattr(old, old_field_name) - if (field_type in ['CharField', 'TextField'] - and value in [None, 'None']): - value = '' + if field_type in ['CharField', 'TextField']: + if value in [None, 'None']: + value = '' + else: + # retira caracters nulos que o postgres não aceita + # quando usamos bulk_create + value = value.strip('\0') # ajusta tempos segundo timezone # os campos TIMESTAMP do mysql são gravados em UTC