diff --git a/ChangeLog b/ChangeLog index 37dea3bc..267601f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22930,3 +22930,7 @@ 2022-03-02 Fred Gleason * Implemented sorting of the group list in the 'Rivendell Group List' dialog in rdadmin(1). +2022-03-04 Fred Gleason + * Fixed a bug in rdimport(1) that could create duplicate + Scheduler Code entries when using the '--to-cart' and + '--add-scheduler-code' switches simultaneously. diff --git a/lib/rdcart.cpp b/lib/rdcart.cpp index 900e26ba..9477e675 100644 --- a/lib/rdcart.cpp +++ b/lib/rdcart.cpp @@ -2,7 +2,7 @@ // // Abstract a Rivendell Cart. // -// (C) Copyright 2002-2021 Fred Gleason +// (C) Copyright 2002-2022 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -308,23 +308,36 @@ QStringList RDCart::schedCodesList() const } -void RDCart::setSchedCodesList(const QStringList &codes) const +void RDCart::setSchedCodesList(QStringList codes) const { - RDSqlQuery *q; QString sql; + RDSqlQuery *q; QString sched_codes=""; sql=QString("delete from `CART_SCHED_CODES` where ")+ QString::asprintf("`CART_NUMBER`=%u",cart_number); + RDSqlQuery::apply(sql); + + // + // Normalize Codes + // + sql=QString("select `CODE` from `SCHED_CODES`"); q=new RDSqlQuery(sql); + while(q->next()) { + for(int i=0;ivalue(0).toString().toLower()) { + codes[i]=q->value(0).toString(); + } + } + } delete q; + codes.removeDuplicates(); for(int i=0;i +// (C) Copyright 2002-2022 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -65,7 +65,7 @@ class RDCart QString schedCodes() const; void setSchedCodes(const QString &sched_codes) const; QStringList schedCodesList() const; - void setSchedCodesList(const QStringList &codes) const; + void setSchedCodesList(QStringList codes) const; void addSchedCode(const QString &code) const; void removeSchedCode(const QString &code) const; void updateSchedCodes(const QString &add_codes,