From 563c6423aa85a3867c0e5183c759a2f7365b1d6d Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Tue, 5 Dec 2017 16:58:00 -0200 Subject: [PATCH] =?UTF-8?q?Arruma=20tip=5Forigem=5Fexterna=20em=20mat?= =?UTF-8?q?=C3=A9ria=20legislativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Luciano Almeida --- sapl/legacy/migration.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sapl/legacy/migration.py b/sapl/legacy/migration.py index 136517e31..7be03af37 100644 --- a/sapl/legacy/migration.py +++ b/sapl/legacy/migration.py @@ -303,6 +303,28 @@ def unifica_autores_repetidos_no_legado(campo_agregador): tuple(apagar))) +def arruma_tip_origem_externa(): + + SQL_SELECT_TIPO_MATERIA = ''' + select tip_materia + from tipo_materia_legislativa; + ''' + + SQL_UPDATE_MATERIA = ''' + update materia_legislativa + set tip_origem_externa = NULL + where tip_origem_externa not in {}; + ''' + + cursor = exec_legado(SQL_SELECT_TIPO_MATERIA) + + tipo_materia = [r[0] for r in cursor if r[0]] + + if tipo_materia: + tipo_materia = str(tipo_materia).replace('[', '(').replace(']', ')') + cursor = exec_legado(SQL_UPDATE_MATERIA.format(tipo_materia)) + + def uniformiza_banco(): exec_legado(''' SELECT replace(@@sql_mode,"STRICT_TRANS_TABLES,","ALLOW_INVALID_DATES"); @@ -392,6 +414,8 @@ relatoria | tip_fim_relatoria = NULL | tip_fim_relatoria = 0 unifica_autores_repetidos_no_legado('cod_parlamentar') unifica_autores_repetidos_no_legado('cod_comissao') + arruma_tip_origem_externa() + def iter_sql_records(sql, db): class Record: