This morning I've been busy tracking a bug in my code, for which I have no explanation as to why it is a bug. The situation is I have an if-else test where, in case of a match, the if-block gets executed, but in case of a non-match, the else-block does NOT get executed. If I turn the whole test around by adding a NOT to the test, and swapping the if and else blocks, everything works.
This is the code which has the bug:
string key_name = "IssueID_shortname"; array qresult = myDB->Query("SHOW keys FROM dbFinalPublicationPassive.tbIssueDetails"); if (qresult && has_value(qresult->Key_name || ({}), key_name)) do_log("Index %O was already set", key_name); else { do_log("Adding index %O", key_name); myDB->Query("ALTER TABLE dbFinalPublicationPassive.tbIssueDetails" " ADD INDEX IssueID_shortname (IssueID, ShortName)"); } This code does not have the bug:
string key_name = "IssueID_shortname"; array qresult = myDB->Query("SHOW keys FROM dbFinalPublicationPassive.tbIssueDetails"); if (!(qresult && has_value(qresult->Key_name || ({}), key_name))) { do_log("Adding index %O", key_name); myDB->Query("ALTER TABLE dbFinalPublicationPassive.tbIssueDetails" " ADD INDEX IssueID_shortname (IssueID, ShortName)"); } else do_log("Index %O was already set", key_name);
Anyone has a clue? (Pike 7.4.464)
Regards,
Arjan
__________________________________________________________ Deze e-mail en de inhoud is vertrouwelijk en uitsluitend bestemd voor de geadresseerde(n). Indien u niet de geadresseerde bent van deze e-mail verzoeken wij u dit direct door te geven aan de verzender door middel van een reply e-mail en de ontvangen e-mail uit uw systemen te verwijderen. Als u geen geadresseerde bent, is het niet toegestaan om kennis te nemen van de inhoud, deze te kopieren, te verspreiden, bekend te maken aan derden noch anderszins te gebruiken.
The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Please notify us immediately if you have received it in error by reply e-mail and then delete this message from your system. __________________________________________________________