fix one of database compatibility problems; others remained

This commit is contained in:
Kashiko Koibumi 2024-05-30 01:12:23 +09:00
parent 6637f56ae7
commit 2d9d30e1e1
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4

View File

@ -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")