From c9b72d4cd09751041ea547c39326a4869464ea69 Mon Sep 17 00:00:00 2001 From: Sergey Gaychuk Date: Thu, 3 Dec 2009 16:41:59 +0200 Subject: [PATCH] storage: add implementation of inserting filter condition to sql string --- storage/base/aaLoadRequest.cpp | 21 +++++++++++++++++++++ storage/base/aaLoadRequest.h | 1 + 2 files changed, 22 insertions(+) diff --git a/storage/base/aaLoadRequest.cpp b/storage/base/aaLoadRequest.cpp index 3dafa75..ac63a28 100644 --- a/storage/base/aaLoadRequest.cpp +++ b/storage/base/aaLoadRequest.cpp @@ -37,6 +37,7 @@ #include "aaISqlFilter.h" #include "aaOrderCondition.h" +#include "aaFilterCondition.h" aaLoadRequest::aaLoadRequest() :mSql(0), mSqlFiltered(0), mMap(0) @@ -86,6 +87,26 @@ aaLoadRequest::GetSql(nsACString & aSql) } aSql.Replace(offset, sizeof(AA_SQL_ORDER_MARK), str); } + //check for filter + offset = aSql.Find(AA_SQL_FILTER_MARK, sizeof(AA_SQL_FILTER_MARK) - 1); + if (-1 != offset) { + str.Truncate(); + rc = flter->GetParam(NS_LITERAL_CSTRING(FILTER_CONDITION_NAME), getter_AddRefs(pTmp)); + if (NS_SUCCEEDED(rc)) { + pCondition = do_QueryInterface(pTmp, &rc); + NS_ENSURE_SUCCESS(rc, rc); + + rc = GetCondition(pCondition, str); + NS_ENSURE_SUCCESS(rc, rc); + + if (!str.IsEmpty()) { + str.Insert(" ", 0); + } + } else { + rc = NS_OK; + } + aSql.Replace(offset, sizeof(AA_SQL_FILTER_MARK), str); + } } } else { aSql.Assign(mSql); diff --git a/storage/base/aaLoadRequest.h b/storage/base/aaLoadRequest.h index 98d75a4..8443281 100644 --- a/storage/base/aaLoadRequest.h +++ b/storage/base/aaLoadRequest.h @@ -34,6 +34,7 @@ class aaICondition; #endif #define AA_SQL_ORDER_MARK "%AA_ORDER%" +#define AA_SQL_FILTER_MARK "%AA_FILTER%" class aaLoadRequest : public aaISqlRequest, public aaIDataNode -- 2.11.4.GIT