From 2d9d30e1e1c200e848c8153781d1cf0d220f5aa3 Mon Sep 17 00:00:00 2001 From: Kashiko Koibumi Date: Thu, 30 May 2024 01:12:23 +0900 Subject: [PATCH] fix one of database compatibility problems; others remained --- src/bitmessageqt/__init__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 64d24310..3dcfcef2 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -19,6 +19,8 @@ import six from six.moves import range as xrange if six.PY3: from codecs import escape_decode +if six.PY2: + import sqlite3 from unqstr import ustr, unic from dbcompat import dbstr @@ -2927,6 +2929,14 @@ class MyForm(settingsmixin.SMainWindow): return queryreturn = sqlQuery( 'SELECT message FROM inbox WHERE msgid=?', msgid) + # for compatibility + if len(queryreturn) < 1: + if six.PY3: + queryreturn = sqlQuery( + 'SELECT message FROM inbox WHERE msgid=CAST(? AS TEXT)', msgid) + else: # assume six.PY2 + queryreturn = sqlQuery( + 'SELECT message FROM inbox WHERE msgid=?', sqlite3.Binary(msgid)) try: lines_raw = queryreturn[-1][0].split('\n') lines = [] @@ -4154,6 +4164,22 @@ class MyForm(settingsmixin.SMainWindow): else ('inbox', 'msgid') ), msgid ) + # for compatibility + if len(queryreturn) < 1: + if six.PY3: + queryreturn = sqlQuery( + 'SELECT message FROM %s WHERE %s=CAST(? AS TEXT)' % ( + ('sent', 'ackdata') if folder == 'sent' + else ('inbox', 'msgid') + ), msgid + ) + else: # assume six.PY2 + queryreturn = sqlQuery( + 'SELECT message FROM %s WHERE %s=?' % ( + ('sent', 'ackdata') if folder == 'sent' + else ('inbox', 'msgid') + ), sqlite3.Binary(msgid) + ) try: message = queryreturn[-1][0].decode("utf-8", "replace")