Project

General

Profile

0001-sql-don-t-add-the-same-string-multiple-time-in-FTS-7.patch

Pierre Ducroquet, 26 December 2022 12:52 PM

Download (2.45 KB)

View differences:

Subject: [PATCH] sql: don't add the same string multiple time in FTS (#72784)

 wcs/sql.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
wcs/sql.py
2884 2884
                cur.execute(sql_statement, sql_dict)
2885 2885
                evo._sql_id = cur.fetchone()[0]
2886 2886

  
2887
        fts_strings = {'A': [], 'B': [], 'C': [], 'D': []}
2888
        fts_strings['A'].append(str(self.id))
2889
        fts_strings['A'].append(self.get_display_id())
2890
        fts_strings['C'].append(self._formdef.name)
2887
        fts_strings = {'A': set(), 'B': set(), 'C': set(), 'D': set()}
2888
        fts_strings['A'].add(str(self.id))
2889
        fts_strings['A'].add(self.get_display_id())
2890
        fts_strings['C'].add(self._formdef.name)
2891 2891
        if self.tracking_code:
2892
            fts_strings['A'].append(self.tracking_code)
2892
            fts_strings['A'].add(self.tracking_code)
2893 2893

  
2894 2894
        def get_all_fields():
2895 2895
            for field in self._formdef.get_all_fields():
......
2919 2919
                    weight = 'B'
2920 2920
                if isinstance(value, str) and len(value) < 10000:
2921 2921
                    # avoid overlong strings, typically base64-encoded values
2922
                    fts_strings[weight].append(value)
2922
                    fts_strings[weight].add(value)
2923 2923
                elif type(value) in (tuple, list):
2924 2924
                    for val in value:
2925
                        fts_strings[weight].append(val)
2925
                        fts_strings[weight].add(val)
2926 2926
        if self._evolution:
2927 2927
            for evo in self._evolution:
2928 2928
                if evo.comment:
2929
                    fts_strings['D'].append(evo.comment)
2929
                    fts_strings['D'].add(evo.comment)
2930 2930
                for part in evo.parts or []:
2931
                    fts_strings['D'].append(part.render_for_fts() if part.render_for_fts else '')
2931
                    fts_strings['D'].add(part.render_for_fts() if part.render_for_fts else '')
2932 2932
        user = self.get_user()
2933 2933
        if user:
2934
            fts_strings['A'].append(user.get_display_name())
2934
            fts_strings['A'].add(user.get_display_name())
2935 2935

  
2936 2936
        fts_parts = []
2937 2937
        parameters = {'id': self.id}
2938
-