Skip to content

Commit

Permalink
DB Schema Update: Change lambda capture from 'by value' to 'by refere…
Browse files Browse the repository at this point in the history
…nce'

This fix corrects a program abort when updating from db version 1302 to 1303.
The problem is that the 'ORDER BY' column name is not specified, causing a
fatal SQL error. The column name should be either 'starttime' or '-starttime'
depending on your time zone.

This occurs because the lambda capture is 'by value' and takes on the value
at the time it was created (which is empty). Further updates to the local
variable are not available to the lambda expression.

Switching the lambda capture to 'by reference' resolves this issue.

Signed-off-by: Klaas de Waal <[email protected]>
  • Loading branch information
Patrick J. Maloney authored and kmdewaal committed Jan 1, 2024
1 parent 5f294a8 commit 7ec562f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/dbcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ static bool doUpgradeTVDatabaseSchema(void)

auto ss2ba = [](const auto & ss){ return QByteArray::fromStdString(ss); };
auto qs2ba = [](const auto & item){ return item.constData(); };
auto add_start_end = [order](const auto & field){
auto add_start_end = [&order](const auto & field){
return QString("UPDATE %1 "
"SET starttime = CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC'), "
" endtime = CONVERT_TZ(endtime, 'SYSTEM', 'Etc/UTC') "
"ORDER BY %2")
.arg(QString::fromStdString(field)).arg(order).toLocal8Bit(); };
auto add_start = [order](const auto & field){
auto add_start = [&order](const auto & field){
return QString("UPDATE %1 "
"SET starttime = CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC') "
"ORDER BY %2")
Expand Down

0 comments on commit 7ec562f

Please sign in to comment.