Skip to content

Commit

Permalink
Merge pull request #56 from gisce/fix_load_translations
Browse files Browse the repository at this point in the history
Fix load translation method when loading tranlations without res_id
  • Loading branch information
eberloso authored Jan 30, 2025
2 parents e35537c + 31c6dda commit ea7f7be
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion oopgrade/oopgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,10 @@ def load_translation(cursor, lang, name, type, res_id, src, value):
ON CONFLICT (lang, src_md5, name, type, res_id) WHERE res_id = %(res_id)s DO UPDATE SET value = EXCLUDED.value
"""
else:
res_id = None # Per si ens arriba False, perque en SQL False != null
insert_sql = """
INSERT INTO ir_translation(lang, name, type, res_id, src, value)
VALUES (%(lang)s, %(name)s, %(type)s, %(res_id)s, %(src)s, %(value)s)
ON CONFLICT (lang, src_md5, name, type, res_id) WHERE res_id is null DO UPDATE SET value = EXCLUDED.value
ON CONFLICT (lang, src_md5, name, type) WHERE res_id is null DO UPDATE SET value = EXCLUDED.value
"""
cursor.execute(insert_sql, {'lang': lang, 'name': name, 'type': type, 'res_id': res_id, 'src': src, 'value': value})

0 comments on commit ea7f7be

Please sign in to comment.