Projet

Général

Profil

0001-logged-errors-fix-integrity-error-on-tech_id-53839.patch

Lauréline Guérin, 11 mai 2021 11:30

Télécharger (1,92 ko)

Voir les différences:

Subject: [PATCH] logged errors: fix integrity error on tech_id (#53839)

 wcs/logged_errors.py |  3 ---
 wcs/sql.py           | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)
wcs/logged_errors.py
87 87

  
88 88
        error.first_occurence_timestamp = now()
89 89
        error.tech_id = error.build_tech_id()
90
        existing_errors = list(cls.get_with_indexed_value('tech_id', error.tech_id))
91
        if existing_errors:
92
            error = existing_errors[0]
93 90
        error.occurences_count += 1
94 91
        error.latest_occurence_timestamp = now()
95 92
        error.store()
wcs/sql.py
3002 3002
                ', '.join(column_names),
3003 3003
                ', '.join(['%%(%s)s' % x for x in column_names]),
3004 3004
            )
3005
            cur.execute(sql_statement, sql_dict)
3005
            try:
3006
                cur.execute(sql_statement, sql_dict)
3007
            except psycopg2.IntegrityError:
3008
                # tech_id already used ?
3009
                conn.rollback()
3010
                existing_errors = list(self.get_with_indexed_value('tech_id', self.tech_id))
3011
                if not existing_errors:
3012
                    raise
3013
                error = existing_errors[0]
3014
                error.occurences_count += 1
3015
                error.latest_occurence_timestamp = self.latest_occurence_timestamp
3016
                return error.store()
3006 3017
            self.id = cur.fetchone()[0]
3007 3018
        else:
3008 3019
            column_names = sql_dict.keys()
3009
-