From b02c0ba0a2fa565d16b8f7c0cb008f1c2b467c45 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 25 Apr 2016 01:01:17 +0100 Subject: Generic entity where filter --- .../service/maintenance/ebuildMetaProcessor.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp index 48bd6cc..87cfd12 100644 --- a/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/ebuildMetaProcessor.cpp @@ -149,28 +149,33 @@ namespace Gentoo { } } - class EbuildWhereFilter : public DB::SqlWriter { + class EntityWhereFilter : public DB::SqlWriter { public: - EbuildWhereFilter(int64_t e) : ebuildId(e) { } + EntityWhereFilter(const std::string & en, int64_t e) : + entityId(e), + entityColName(en) + { + } void writeSql(AdHoc::Buffer & sql) override { - sql.append("b.ebuildId = ?"); + sql.appendbf("b.%s = ?", entityColName); } void bindParams(DB::Command * c, unsigned int & offset) override { - c->bindParamI(offset++, ebuildId); + c->bindParamI(offset++, entityId); } - const int64_t ebuildId; + const int64_t entityId; + const std::string entityColName; }; void EbuildMetaProcessor::perEbuildUpdates(DB::Connection * dbc, const EbuildCacheParser & ecp, int64_t ebuildId) const { - EbuildWhereFilter ewf(ebuildId); - // USE flags + EntityWhereFilter ewf("ebuildId", ebuildId); + // IUSE DB::TablePatch t; SplitEbuildProps sep_use("ebuildId", ebuildId, "use", ecp.get("IUSE")); t.dest = "gentoobrowse.ebuild_uses"; -- cgit v1.2.3