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 from six.moves import range as xrange
if six.PY3: if six.PY3:
from codecs import escape_decode from codecs import escape_decode
if six.PY2:
import sqlite3
from unqstr import ustr, unic from unqstr import ustr, unic
from dbcompat import dbstr from dbcompat import dbstr
@ -2927,6 +2929,14 @@ class MyForm(settingsmixin.SMainWindow):
return return
queryreturn = sqlQuery( queryreturn = sqlQuery(
'SELECT message FROM inbox WHERE msgid=?', msgid) '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: try:
lines_raw = queryreturn[-1][0].split('\n') lines_raw = queryreturn[-1][0].split('\n')
lines = [] lines = []
@ -4154,6 +4164,22 @@ class MyForm(settingsmixin.SMainWindow):
else ('inbox', 'msgid') else ('inbox', 'msgid')
), 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: try:
message = queryreturn[-1][0].decode("utf-8", "replace") message = queryreturn[-1][0].decode("utf-8", "replace")