Browse Source

Výsledek nemá tečky, upraveny dotazy

middleware_test
Pavel "LEdoian" Turinsky 4 years ago
parent
commit
c679c5cfd1
  1. 30
      db_compare.py

30
db_compare.py

@ -64,7 +64,10 @@ def check_skola():
def check_resitel(): def check_resitel():
old_query = 'SELECT * FROM seminar_resitele ORDER BY id' 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) old_res, new_res = execute_simple(old_query,new_query)
@ -73,7 +76,7 @@ def check_resitel():
fields_osoba = [ fields_osoba = [
'jmeno', 'jmeno',
'prijmeni', 'prijmeni',
'user', 'user_id',
'pohlavi_muz', 'pohlavi_muz',
'email', 'email',
'telefon', 'telefon',
@ -93,20 +96,19 @@ def check_resitel():
'zasilat', 'zasilat',
'poznamka', 'poznamka',
] ]
fields_old = fields_keep+fields_osoba fields = fields_keep+fields_osoba
fields_new = fields_keep + ['seminar_osoby.'+f for f in fields_osoba]
for o,n in res: for o,n in res:
check_same(o,n,fields_old, fields_new) check_same(o,n,fields)
def check_reseni(): def check_reseni():
old_query = 'SELECT * FROM seminar_reseni ORDER BY id' 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'] same_fields = ['id', 'forma', 'poznamka']
renamed_fields = [('timestamp', 'cas_doruceni'), renamed_fields = [('timestamp', 'cas_doruceni'),
('problem_id', 'hodnoceni.problem_id'), ('problem_id', 'h_problem_id'),
('body', 'hodnoceni.body'), ('body', 'h_body'),
('cislo_body_id', 'hodnoceni.cislo_body_id'), ('cislo_body_id', 'h_cislo_body_id'),
] ]
old_fields = same_fields + [f[0] for f in renamed_fields] old_fields = same_fields + [f[0] for f in renamed_fields]
new_fields = same_fields + [f[1] 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(): def check_organizator():
old_query = 'SELECT * FROM seminar_organizatori ORDER BY id' 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'] same_fields = ['studuje', 'strucny_popis_organizatora']
renamed_fields = [ renamed_fields = [
('user_id', 'user.id'), ('user_id', 'uid'),
('prezdivka', 'osoba.prezdivka'), ('prezdivka', 'o_prezdivka'),
('foto', 'osoba.foto'), ('foto', 'o_foto'),
('foto_male', 'osoba.foto_male'), ('foto_male', 'o_foto_male'),
] ]
old_fields = same_fields + [f[0] for f in renamed_fields] old_fields = same_fields + [f[0] for f in renamed_fields]
new_fields = same_fields + [f[1] for f in renamed_fields] new_fields = same_fields + [f[1] for f in renamed_fields]

Loading…
Cancel
Save