From c679c5cfd1e2dad3feba14bdfca831f98abd2869 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 2 Jun 2021 03:17:18 +0200 Subject: [PATCH] =?UTF-8?q?V=C3=BDsledek=20nem=C3=A1=20te=C4=8Dky,=20uprav?= =?UTF-8?q?eny=20dotazy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_compare.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/db_compare.py b/db_compare.py index bb29944d..e8c73008 100644 --- a/db_compare.py +++ b/db_compare.py @@ -64,7 +64,10 @@ def check_skola(): def check_resitel(): old_query = 'SELECT * FROM seminar_resitele ORDER BY id' - new_query = 'SELECT * FROM seminar_resitele JOIN seminar_osoby ON seminar_resitele.osoba_id = seminar_osoby.id ORDER BY seminar_resitele.id' + new_query = '''SELECT id, skola_id, rok_maturity, zasilat, poznamka, + o.jmeno AS jmeno, o.prijmeni AS prijmeni, o.user_id AS user_id, o.pohlavi_muz AS pohlavi_muz, o.email AS email, o.telefon AS telefon, o.datum_narozeni AS datum_narozeni, + o.datum_souhlasu_udaje AS datum_souhlasu_udaje, o.datum_souhlasu_zasilani AS datum_souhlasu_zasilani, o.datum_prihlaseni AS datum_prihlaseni, o.ulice AS ulice, o.mesto AS mesto, o.psc AS psc, o.stat AS stat + FROM seminar_resitele JOIN seminar_osoby AS o ON seminar_resitele.osoba_id = seminar_osoby.id ORDER BY seminar_resitele.id''' old_res, new_res = execute_simple(old_query,new_query) @@ -73,7 +76,7 @@ def check_resitel(): fields_osoba = [ 'jmeno', 'prijmeni', - 'user', + 'user_id', 'pohlavi_muz', 'email', 'telefon', @@ -93,20 +96,19 @@ def check_resitel(): 'zasilat', 'poznamka', ] - fields_old = fields_keep+fields_osoba - fields_new = fields_keep + ['seminar_osoby.'+f for f in fields_osoba] + fields = fields_keep+fields_osoba for o,n in res: - check_same(o,n,fields_old, fields_new) + check_same(o,n,fields) def check_reseni(): old_query = 'SELECT * FROM seminar_reseni ORDER BY id' - new_query = 'SELECT * FROM seminar_reseni JOIN seminar_hodnoceni AS hodnoceni ON hodnoceni_id = hodnoceni.id ORDER BY id' + new_query = 'SELECT id, forma, poznamka, cas_doruceni, hodnoceni.problem_id AS h_problem_id, hodnoceni.body AS h_body, hodnoceni.cislo_body_id AS h_cislo_body_id FROM seminar_reseni JOIN seminar_hodnoceni AS hodnoceni ON hodnoceni_id = hodnoceni.id ORDER BY id' same_fields = ['id', 'forma', 'poznamka'] renamed_fields = [('timestamp', 'cas_doruceni'), - ('problem_id', 'hodnoceni.problem_id'), - ('body', 'hodnoceni.body'), - ('cislo_body_id', 'hodnoceni.cislo_body_id'), + ('problem_id', 'h_problem_id'), + ('body', 'h_body'), + ('cislo_body_id', 'h_cislo_body_id'), ] old_fields = same_fields + [f[0] for f in renamed_fields] new_fields = same_fields + [f[1] for f in renamed_fields] @@ -133,14 +135,14 @@ def check_reseni(): def check_organizator(): old_query = 'SELECT * FROM seminar_organizatori ORDER BY id' - new_query = 'SELECT * FROM seminar_organizatori JOIN seminar_osoby AS osoba ON osoba_id = osoba.id JOIN auth_user AS user ON osoba.user_id = user.id ORDER BY id' + new_query = 'SELECT studuje, strucny_popis_organizatora, user.id AS uid, osoba.prezdivka AS o_prezdivka, osoba.foto AS o_foto, osoba.foto_male AS o_foto_male FROM seminar_organizatori JOIN seminar_osoby AS osoba ON osoba_id = osoba.id JOIN auth_user AS user ON osoba.user_id = user.id ORDER BY id' same_fields = ['studuje', 'strucny_popis_organizatora'] renamed_fields = [ - ('user_id', 'user.id'), - ('prezdivka', 'osoba.prezdivka'), - ('foto', 'osoba.foto'), - ('foto_male', 'osoba.foto_male'), + ('user_id', 'uid'), + ('prezdivka', 'o_prezdivka'), + ('foto', 'o_foto'), + ('foto_male', 'o_foto_male'), ] old_fields = same_fields + [f[0] for f in renamed_fields] new_fields = same_fields + [f[1] for f in renamed_fields]