mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Add folder into the query parser
This commit is contained in:
parent
4a50d438d0
commit
5fa7da1e46
@ -11,20 +11,27 @@ const std::map<QueryParser::FieldType, std::vector<std::string>> QueryParser::fi
|
|||||||
{FieldType::text, {"title", "volume", "storyarc", "genere", "writer", "penciller", "inker", "colorist", "letterer",
|
{FieldType::text, {"title", "volume", "storyarc", "genere", "writer", "penciller", "inker", "colorist", "letterer",
|
||||||
"coverartist", "publisher", "format", "agerating", "synopsis", "characters", "notes"}},
|
"coverartist", "publisher", "format", "agerating", "synopsis", "characters", "notes"}},
|
||||||
{FieldType::boolean, {"isbis", "color"}},
|
{FieldType::boolean, {"isbis", "color"}},
|
||||||
{FieldType::date, {"date"} } };
|
{FieldType::date, {"date"}},
|
||||||
|
{FieldType::filename, {"filename"}},
|
||||||
|
{FieldType::folder, {"folder"}} };
|
||||||
|
|
||||||
int QueryParser::TreeNode::buildSqlString(std::string& sqlString, int bindPosition) const {
|
int QueryParser::TreeNode::buildSqlString(std::string& sqlString, int bindPosition) const {
|
||||||
if (t == "token") {
|
if (t == "token") {
|
||||||
++bindPosition;
|
++bindPosition;
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if (children[0].t == "all") {
|
if (toLower(children[0].t) == "all") {
|
||||||
oss << "(";
|
oss << "(";
|
||||||
for (const auto& field: fieldNames.at(FieldType::text)) {
|
for (const auto& field: fieldNames.at(FieldType::text)) {
|
||||||
oss << "UPPER(ci." << field << ") LIKE UPPER(:bindPosition" << bindPosition << ") OR ";
|
oss << "UPPER(ci." << field << ") LIKE UPPER(:bindPosition" << bindPosition << ") OR ";
|
||||||
}
|
}
|
||||||
oss << "UPPER(c.fileName) LIKE UPPER(:bindPosition" << bindPosition << ")) ";
|
oss << "UPPER(c.filename) LIKE UPPER(:bindPosition" << bindPosition << ") OR ";
|
||||||
|
oss << "UPPER(f.name) LIKE UPPER(:bindPosition" << bindPosition << ")) ";
|
||||||
} else if (isIn(fieldType(children[0].t), FieldType::numeric, FieldType::boolean)) {
|
} else if (isIn(fieldType(children[0].t), FieldType::numeric, FieldType::boolean)) {
|
||||||
oss << "ci." << children[0].t << " = :bindPosition" << bindPosition << " ";
|
oss << "ci." << children[0].t << " = :bindPosition" << bindPosition << " ";
|
||||||
|
} else if (fieldType(children[0].t) == FieldType::filename) {
|
||||||
|
oss << "(UPPER(c." << children[0].t << ") LIKE UPPER(:bindPosition" << bindPosition << ")) ";
|
||||||
|
} else if (fieldType(children[0].t) == FieldType::folder) {
|
||||||
|
oss << "(UPPER(f.name) LIKE UPPER(:bindPosition" << bindPosition << ")) ";
|
||||||
} else {
|
} else {
|
||||||
oss << "(UPPER(ci." << children[0].t << ") LIKE UPPER(:bindPosition" << bindPosition << ")) ";
|
oss << "(UPPER(ci." << children[0].t << ") LIKE UPPER(:bindPosition" << bindPosition << ")) ";
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ private:
|
|||||||
template<typename First, typename ... T>
|
template<typename First, typename ... T>
|
||||||
static bool isIn(First &&first, T && ... t) {return ((first == t) || ...);}
|
static bool isIn(First &&first, T && ... t) {return ((first == t) || ...);}
|
||||||
|
|
||||||
enum class FieldType {unknown, numeric, text, boolean, date};
|
enum class FieldType {unknown, numeric, text, boolean, date, folder, filename};
|
||||||
static FieldType fieldType(const std::string& str);
|
static FieldType fieldType(const std::string& str);
|
||||||
|
|
||||||
void tokenize (const std::string& expr);
|
void tokenize (const std::string& expr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user