Skip to content

Commit

Permalink
mythdbcon: force QMetaType::QDateTime values to use MythDate::kDatabase
Browse files Browse the repository at this point in the history
This cares for a recent ibqt5sql5-mysql update in at least one
distribution where it isn't removing timezone information from
a query causing it to fail.

Log example without patch:
MSqlQuery::exec(DBManager16) UPDATE recorded SET recgroup = 'Deleted', recgroupid = 3 WHERE chanid = '10901' AND starttime = '2023-04-08T05:00:00.000Z' ; <<<< Took 0ms

Log example with patch:
MSqlQuery::exec(DBManager1) UPDATE recorded SET recgroup = 'Deleted', recgroupid = 3 WHERE chanid = '10901' AND starttime = '2023-04-07 05:30:00' ; <<<< Took 0ms

Results seen by users on the Forum and mailing list.

Credits to Mark, Roland and Klaas.

See: https://forum.mythtv.org/viewtopic.php?p=25833#p25833

The Debian solution is due 4/31/2023.
  • Loading branch information
Bill Meek committed May 15, 2023
1 parent 23e158c commit 7202424
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions mythtv/libs/libmythbase/mythdbcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,15 @@ bool MSqlQuery::testDBConnection()

void MSqlQuery::bindValue(const QString &placeholder, const QVariant &val)
{
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if (static_cast<QMetaType::Type>(val.type()) == QMetaType::QDateTime)
{
QSqlQuery::bindValue(placeholder,
MythDate::toString(val.toDateTime(), MythDate::kDatabase),
QSql::In);
return;
}
#endif
QSqlQuery::bindValue(placeholder, val, QSql::In);
}

Expand All @@ -896,6 +905,15 @@ void MSqlQuery::bindValueNoNull(const QString &placeholder, const QVariant &val)
QSqlQuery::bindValue(placeholder, QString(""), QSql::In);
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if (type == QMetaType::QDateTime)
{
QSqlQuery::bindValue(placeholder,
MythDate::toString(val.toDateTime(), MythDate::kDatabase),
QSql::In);
return;
}
#endif
QSqlQuery::bindValue(placeholder, val, QSql::In);
}

Expand Down

0 comments on commit 7202424

Please sign in to comment.