Opened 12 years ago

Closed 12 years ago

#5347 closed defect (fixed)

channelutils.cpp construct an incomplete query to update/insert into dtv_multiplex

Reported by: hp@… Owned by: danielk
Priority: minor Milestone: unknown
Component: channelscan Version: head
Severity: medium Keywords: db
Cc: Ticket locked: no

Description

I get tons of errors while updating channels with new transports. the console window shows, that qt barks about "not set" parameters. A quick glance to channelutils.cpp:224 shows, that many parameters may be left unset - which probably worked fine in previous versions of qt?

I had to change that behaviour slightly... Always setting at least a null value solves the problem for me:

Index: libs/libmythtv/channelutil.cpp
===================================================================
--- libs/libmythtv/channelutil.cpp      (revision 17307)
+++ libs/libmythtv/channelutil.cpp      (working copy)
@@ -225,36 +225,28 @@
     query.bindValue(":SISTANDARD",        sistandard);
     query.bindValue(":FREQUENCY",         frequency);
 
-    if (!modulation.isNull())
-        query.bindValue(":MODULATION",    modulation);
+    query.bindValue(":MODULATION", (!modulation.isNull() ?  modulation : QVariant(QVariant::String)) );
     if (sistandard.lower() == "dvb")
     {
         query.bindValue(":TRANSPORTID",   transport_id);
         query.bindValue(":NETWORKID",     network_id);
     }
-    if (symbol_rate >= 0)
-        query.bindValue(":SYMBOLRATE",    symbol_rate);
-    if (bandwidth >= 0)
-        query.bindValue(":BANDWIDTH",     QString("%1").arg((char)bandwidth));
-    if (polarity >= 0)
-        query.bindValue(":POLARITY",      QString("%1").arg((char)polarity));
-    if (inversion >= 0)
-        query.bindValue(":INVERSION",     QString("%1").arg((char)inversion));
-    if (trans_mode >= 0)
-        query.bindValue(":TRANS_MODE",    QString("%1").arg((char)trans_mode));
+    else {
+        query.bindValue(":TRANSPORTID",   QVariant(QVariant::String));
+        query.bindValue(":NETWORKID",     QVariant(QVariant::String)); 
+    }
+    query.bindValue(":SYMBOLRATE", (symbol_rate >= 0 ? symbol_rate : QVariant(QVariant::Int)) );
+    query.bindValue(":BANDWIDTH", (bandwidth >= 0 ? QString("%1").arg((char)bandwidth) : QVariant(QVariant::String)));
+    query.bindValue(":POLARITY", (polarity >= 0 ? QString("%1").arg((char)polarity) : QVariant(QVariant::String)));
+    query.bindValue(":INVERSION", (inversion >= 0 ? QString("%1").arg((char)inversion) : QVariant(QVariant::String)) );
+    query.bindValue(":TRANS_MODE", (trans_mode >= 0 ? QString("%1").arg((char)trans_mode) : QVariant(QVariant::String)) );
 
-    if (!inner_FEC.isNull())
-        query.bindValue(":INNER_FEC",     inner_FEC);
-    if (!constellation.isNull())
-        query.bindValue(":CONSTELLATION", constellation);
-    if (hierarchy >= 0)
-        query.bindValue(":HIERARCHY",     QString("%1").arg((char)hierarchy));
-    if (!hp_code_rate.isNull())
-        query.bindValue(":HP_CODE_RATE",  hp_code_rate);
-    if (!lp_code_rate.isNull())
-        query.bindValue(":LP_CODE_RATE",  lp_code_rate);
-    if (!guard_interval.isNull())
-        query.bindValue(":GUARD_INTERVAL",guard_interval);
+    query.bindValue(":INNER_FEC", (!inner_FEC.isNull() ? inner_FEC : QVariant(QVariant::String)) );
+    query.bindValue(":CONSTELLATION", (!constellation.isNull() ? constellation : QVariant(QVariant::String)) );
+    query.bindValue(":HIERARCHY", (hierarchy >= 0 ? QString("%1").arg((char)hierarchy) : QVariant(QVariant::String)) );
+    query.bindValue(":HP_CODE_RATE", (!hp_code_rate.isNull() ? hp_code_rate : QVariant(QVariant::String)) );
+    query.bindValue(":LP_CODE_RATE", (!lp_code_rate.isNull() ? lp_code_rate : QVariant(QVariant::String)) );
+    query.bindValue(":GUARD_INTERVAL", (!guard_interval.isNull() ? guard_interval : QVariant(QVariant::String)) );
 
     if (!query.exec() || !query.isActive())
     {

Change History (1)

comment:1 Changed 12 years ago by danielk

Resolution: fixed
Status: newclosed

(In [17570]) Fixes #5347. Ports three sql queries bindings to Qt4's, QSqlQuery which treats null's differently than Qt3 did.

Note: See TracTickets for help on using tickets.