diff --git a/pglab/ConnectionListModel.cpp b/pglab/ConnectionListModel.cpp index f129849..a346ecc 100644 --- a/pglab/ConnectionListModel.cpp +++ b/pglab/ConnectionListModel.cpp @@ -185,6 +185,25 @@ INSERT INTO connection_parameter (connection_uuid, pname, pvalue) stmt.Bind(4, b64.data(), b64.length()); } stmt.Step(); + + stmt = db.Prepare( + "DELETE FROM connection_parameter WHERE connection_uuid=?1"); + stmt.Bind(1, cc.uuid().toString()); + stmt.Step(); + + stmt = db.Prepare( + R"__(INSERT INTO connection_parameter (connection_uuid, pname, pvalue) + VALUES(?1, ?2, ?3))__"); + const std::unordered_map& params = cc.getParameters(); + for (auto && p : params) + { + stmt.Reset(); + stmt.Bind(1, cc.uuid().toString()); + stmt.Bind(2, p.first); + stmt.Bind(3, p.second); + stmt.Step(); + } + tx.Commit(); } } // end of unnamed namespace diff --git a/pglablib/ConnectionConfig.h b/pglablib/ConnectionConfig.h index e7d1817..b21e76a 100644 --- a/pglablib/ConnectionConfig.h +++ b/pglablib/ConnectionConfig.h @@ -135,6 +135,10 @@ public: void setParameter(const QString &name, const QString &value); QString getParameter(const QString &name) const; + const std::unordered_map& getParameters() const + { + return m_parameters; + } private: QUuid m_uuid; QString m_name;